changeset 12453:8970574702a4

Truffle-DSL: fixed type comparison of inner classes fails with ECJ when class was loaded from binary file.
author Christian Humer <christian.humer@gmail.com>
date Wed, 16 Oct 2013 18:27:11 +0200
parents 5f022aa41631
children ce4836e0212d
files graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Utils.java
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Utils.java	Wed Oct 16 18:25:16 2013 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Utils.java	Wed Oct 16 18:27:11 2013 +0200
@@ -400,7 +400,19 @@
     }
 
     public static String getQualifiedName(TypeElement element) {
-        return element.getQualifiedName().toString();
+        String qualifiedName = element.getQualifiedName().toString();
+        if (qualifiedName.contains("$")) {
+            /*
+             * If a class gets loaded in its binary form by the ECJ compiler it fails to produce the
+             * proper canonical class name. It leaves the $ in the qualified name of the class. So
+             * one instance of a TypeElement may be loaded in binary and one in source form. The
+             * current type comparison in #typeEquals compares by the qualified name so the
+             * qualified name must match. This is basically a hack to fix the returned qualified
+             * name of eclipse.
+             */
+            qualifiedName = qualifiedName.replace('$', '.');
+        }
+        return qualifiedName;
     }
 
     public static String getQualifiedName(TypeMirror mirror) {
@@ -866,6 +878,8 @@
             return true;
         } else if (type1 == null || type2 == null) {
             return false;
+        } else if (type1 == type2) {
+            return true;
         }
         String qualified1 = getQualifiedName(type1);
         String qualified2 = getQualifiedName(type2);