From 9d6708adf9d1a57d32f15ecd5bf2063790d83244 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Sun, 26 Jun 2016 17:10:23 +0200 Subject: [PATCH] Fix DSL JDT compiler support for Eclipse Neon. --- .../processor/java/compiler/JDTCompiler.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java b/truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java index 939655a58a9f..c8805f9f28ad 100644 --- a/truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java +++ b/truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java @@ -42,7 +42,7 @@ public class JDTCompiler extends AbstractCompiler { public static boolean isValidElement(Element currentElement) { try { - Class elementClass = Class.forName("org.eclipse.jdt.internal.compiler.apt.model.ElementImpl"); + Class elementClass = currentElement.getClass().getClassLoader().loadClass("org.eclipse.jdt.internal.compiler.apt.model.ElementImpl"); return elementClass.isAssignableFrom(currentElement.getClass()); } catch (ClassNotFoundException e) { return false; @@ -145,8 +145,9 @@ private static List lookupDeclarationOrder(TypeElement type) { List declarationOrder; try { Object binding = field(type, "_binding"); - Class sourceTypeBinding = Class.forName("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding"); - Class binaryTypeBinding = Class.forName("org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding"); + ClassLoader classLoader = binding.getClass().getClassLoader(); + Class sourceTypeBinding = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding"); + Class binaryTypeBinding = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding"); declarationOrder = null; if (sourceTypeBinding.isAssignableFrom(binding.getClass())) { @@ -190,9 +191,10 @@ public int compare(Object o1, Object o2) { } }); - Class binaryMethod = Class.forName("org.eclipse.jdt.internal.compiler.env.IBinaryMethod"); - Class binaryField = Class.forName("org.eclipse.jdt.internal.compiler.env.IBinaryField"); - Class nestedType = Class.forName("org.eclipse.jdt.internal.compiler.env.IBinaryNestedType"); + ClassLoader classLoader = binding.getClass().getClassLoader(); + Class binaryMethod = classLoader.loadClass("org.eclipse.jdt.internal.compiler.env.IBinaryMethod"); + Class binaryField = classLoader.loadClass("org.eclipse.jdt.internal.compiler.env.IBinaryField"); + Class nestedType = classLoader.loadClass("org.eclipse.jdt.internal.compiler.env.IBinaryNestedType"); List bindings = new ArrayList<>(); for (Object sortedElement : sortedElements) { @@ -304,8 +306,9 @@ private static char[] getSource(Element element) throws Exception { */ Object binding = field(element, "_binding"); - Class methodBindingClass = Class.forName("org.eclipse.jdt.internal.compiler.lookup.MethodBinding"); - Class referenceBindingClass = Class.forName("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding"); + ClassLoader classLoader = binding.getClass().getClassLoader(); + Class methodBindingClass = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.MethodBinding"); + Class referenceBindingClass = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding"); char[] source = null; if (methodBindingClass.isAssignableFrom(binding.getClass())) {