| Summary: | [1.7] Error in JDT Core during AST creation | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Deepak Azad <deepakazad> |
| Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | amj87.iitr, Olivier_Thomann |
| Version: | 3.7 | ||
| Target Milestone: | 3.7.1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Problem is coming from the invocation of invokeGeneric(..). typesAsString(..) must be adjusted to handle polymorphic methods. Released in BETA_JAVA7 branch. Verified using Eclipse Java 7 Support(Beta) feature patch v20110623-0900. |
With BETA_JAVA7 branch I get the following exception -------------------------------------------------------------------------------- java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.typesAsString(ProblemReporter.java:6825) at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.deprecatedMethod(ProblemReporter.java:1409) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:519) at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:210) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:463) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:252) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:422) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1148) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1258) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:539) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1181) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:681) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1183) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:809) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480) at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128) at org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.getOverrideIndicators(OverrideIndicatorLabelDecorator.java:161) at org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.computeAdornmentFlags(OverrideIndicatorLabelDecorator.java:136) at org.eclipse.jdt.ui.OverrideIndicatorLabelDecorator.decorate(OverrideIndicatorLabelDecorator.java:273) at org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:269) at org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:81) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:365) at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:347) at org.eclipse.ui.internal.decorators.DecorationScheduler$1.ensureResultCached(DecorationScheduler.java:370) at org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:330) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) -------------------------------------------------------------------------------- Code snippet ------------------------------------------------------------------------------- package org.eclipse; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; public class InvokeExactAndGeneric2 { public static void main(String[] args) throws Throwable { MethodHandles.Lookup lookup = MethodHandles.lookup(); MethodType mt = MethodType.methodType(String.class, String.class, char.class); MethodHandle mh = lookup.findStatic(InvokeExactAndGeneric2.class, "append", mt); String s = (String) mh.invokeExact("follo",'w'); System.out.println(s); mt = MethodType.methodType(int.class, Object[].class); mh = lookup.findVirtual(InvokeExactAndGeneric2.class, "arrayLength", mt); int i = (int) mh.invokeExact(new InvokeExactAndGeneric2(), new Object[] {1, 'A', "foo"}); System.out.println(i); mt = MethodType.methodType(void.class, String.class); mh = lookup.findStatic(InvokeExactAndGeneric2.class, "hello", mt); mh.invokeExact("world"); mt = MethodType.methodType(Object.class, String.class, int.class); mh = lookup.findVirtual(InvokeExactAndGeneric2.class, "foo", mt); Object o = mh.invokeGeneric(new InvokeExactAndGeneric2(), (Object)"foo:", i); mt = MethodType.methodType(void.class); mh = lookup.findStatic(InvokeExactAndGeneric2.class, "bar", mt); mh.invokeExact(); } public static void bar() { System.out.println("bar"); } public Object foo(String s, int i) { System.out.println(s + i); return s + i; } public static String append(String s, char c) { return s + c; } public int arrayLength(Object[] array) { return array.length; } public static void hello(String name) { System.out.println("Hello, "+ name); } } -------------------------------------------------------------------------------