Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348050 - [1.7] Error in JDT Core during AST creation
Summary: [1.7] Error in JDT Core during AST creation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-02 04:28 EDT by Deepak Azad CLA
Modified: 2011-08-05 02:54 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2011-06-02 04:28:11 EDT
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);
	}
}
-------------------------------------------------------------------------------
Comment 1 Olivier Thomann CLA 2011-06-02 11:15:02 EDT
Problem is coming from the invocation of invokeGeneric(..). typesAsString(..) must be adjusted to handle polymorphic methods.
Comment 2 Olivier Thomann CLA 2011-06-08 14:06:04 EDT
Released in BETA_JAVA7 branch.
Comment 3 Ayushman Jain CLA 2011-06-29 05:06:44 EDT
Verified using Eclipse Java 7 Support(Beta) feature patch v20110623-0900.