Community
Participate
Working Groups
Restoring a ITypeBinding form key Ljava/util/Vector<-TT;>; result in a class cast exception. The key was provided by a binding generated from the following declaration: java.util.Vector<? super T extends java.lang.Object> Thread [main] (Suspended (exception ClassCastException)) BindingKey.getCompilerBinding(CompilationUnitDeclaration) line: 165 BindingKey.getCompilerBinding() line: 211 CompilationUnitResolver.resolve(ICompilationUnit[], String[], ASTRequestor, int, Map, WorkingCopyOwner, IProgressMonitor) line: 667 CompilationUnitResolver.resolve(ICompilationUnit[], String[], ASTRequestor, int, Map, IJavaProject, WorkingCopyOwner, IProgressMonitor) line: 436 ASTParser.createASTs(ICompilationUnit[], String[], ASTRequestor, IProgressMonitor) line: 651 TypeEnvironment.createTypeBindings(TType[], IJavaProject) line: 103 TypeEnvironmentTests.performGenericAssignmentTest() line: 196 TypeEnvironmentTests.testStandardAssignments() line: 204 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object[]) line: 324 TypeEnvironmentTests(TestCase).runTest() line: 154 TypeEnvironmentTests(TestCase).runBare() line: 127 TestResult$1.protect() line: 106 TestResult.runProtected(Test, Protectable) line: 124 TestResult.run(TestCase) line: 109 TypeEnvironmentTests(TestCase).run(TestResult) line: 118 TestSuite.runTest(Test, TestResult) line: 208 TestSuite.run(TestResult) line: 203 TypeEnvironmentTests$MyTestSetup(TestDecorator).basicRun(TestResult) line: 22 TestSetup$1.protect() line: 19 TestResult.runProtected(Test, Protectable) line: 124 TypeEnvironmentTests$MyTestSetup(TestSetup).run(TestResult) line: 23 RemotePluginTestRunner(RemoteTestRunner).runTests(String[], String) line: 474 RemotePluginTestRunner(RemoteTestRunner).run() line: 342 RemotePluginTestRunner.main(String[]) line: 36 UITestApplication$1.run() line: 110 RunnableLock.run() line: 35 UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 118 Display.runAsyncMessages(boolean) line: 2787 Display.readAndDispatch() line: 2458 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1575 Workbench.runUI() line: 1541 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 287 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 144 IDEApplication.run(Object) line: 102 UITestApplication.run(Object) line: 39 PlatformActivator$1.run(Object) line: 220 EclipseStarter.run(Object) line: 274 EclipseStarter.run(String[], Runnable) line: 129 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object[]) line: 324 Main.basicRun(String[]) line: 185 Main.run(String[]) line: 684 Main.main(String[]) line: 668
Jerome, I hope it is OK to assign PRs like this directly to you.
I cannot reproduce. Also java.util.Vector<? super T extends java.lang.Object> is not a valid declaration. Do you have more details ?
I simply took the toString() output. The correct declaration looks like this: class A<T> { Vector<? extends T> vector; }
So is it: - java.util.Vector<? super T extends java.lang.Object> ? - Vector<? extends T> ? - something else ? :-) Can I assume that java.util.Vector is in binary form ?
- vector is in binary form - the fetched the key from the type binding for the field vector in the example above. So it is Vector<? extends T> where T is a type argument with a default bound of Object.
For Vector<? extends T>, the binding key is "Ljava/lang/Vector<+TT;>;" (and not "Ljava/util/Vector<-TT;>;"). However I still don't get a ClassCastException trying to restore "Ljava/lang/Vector<+TT;>;". I assume you used v_532 of JDT Core. Did I assume correctly ? If I did, I don't see how a ClassCastException can be thrown. However I get an invalid binding (the bound of the wildcard binding is null). I will fix that.
Sorry, I meant Vector<? super T> I will check which version of JDT/Core I use
Note that the format of the binding key has now changed. The null bound problem in the wildcard binding is now fixed. Please try with org.eclipse.jdt.core v_532c or greater. If you don't get a ClassCastException with this version, let me know and I will close this bug.
Jerome, I retested it with JDT/Core from todays integration build an now I get an NPE when restoring Ljava/util/Vector<+Lgeneric/TestStandardAssignments<TT;TU;>;:TT;>; You can test it using the test case TypeEnvironmentTests from jdt.ui.test.refactoring. You have to uncomment the code: /* ITypeBinding[] restoredBindings= TypeEnvironment.createTypeBindings(types, RefactoringTestSetup.getProject()); assertEquals("Not same length", restoredBindings.length, bindings.length); for (int i= 0; i < restoredBindings.length; i++) { assertTrue("Not same binding", bindings[i].isEqualTo(restoredBindings[i])); } */ Running this reveals a second problem. The key Ljava/util/List<+[Ljava/lang/Object;>; obtained from the binding public interface List<? extends java.lang.Object[]> extends java.lang.Object implements : Collection<? extends java.lang.Object[]>NULL FIELDSNULL METHODS will be restored to public interface List<? extends java.lang.Object[][]> extends NULL TYPENULL SUPERINTERFACESNULL FIELDSNULL METHODS
I don't see any commented code in TypeEnvironmentTests v200501250800. Also what is the NPE that you're getting.
You have to take the version from HEAD. I released it yesterday evening. The stack trace is: Thread [main] (Suspended (exception NullPointerException)) BindingKey.getCompilationUnitDeclaration() line: 401 BindingKey.getCompilerBinding() line: 465 BindingKey.getWildCardBinding(ReferenceBinding, int) line: 674 BindingKey.getParameterizedTypeBinding(ReferenceBinding, ReferenceBinding) line: 584 BindingKey.getCompilerBinding(CompilationUnitDeclaration) line: 427 BindingKey.getCompilerBinding() line: 469 CompilationUnitResolver.resolve(ICompilationUnit[], String[], ASTRequestor, int, Map, WorkingCopyOwner, IProgressMonitor) line: 674 CompilationUnitResolver.resolve(ICompilationUnit[], String[], ASTRequestor, int, Map, IJavaProject, WorkingCopyOwner, IProgressMonitor) line: 443 ASTParser.createASTs(ICompilationUnit[], String[], ASTRequestor, IProgressMonitor) line: 651 TypeEnvironment.createTypeBindings(TType[], IJavaProject) line: 104 TypeEnvironmentTests.testBindings(ITypeBinding[]) line: 227 TypeEnvironmentTests.performGenericAssignmentTest() line: 196 TypeEnvironmentTests.testStandardAssignments() line: 268 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object[]) line: 324 TypeEnvironmentTests(TestCase).runTest() line: 154 TypeEnvironmentTests(TestCase).runBare() line: 127 1.protect() line: 106 TestResult.runProtected(Test, Protectable) line: 124 TestResult.run(TestCase) line: 109 TypeEnvironmentTests(TestCase).run(TestResult) line: 118 TestSuite.runTest(Test, TestResult) line: 208 TestSuite.run(TestResult) line: 203 MyTestSetup(TestDecorator).basicRun(TestResult) line: 22 1.protect() line: 19 TestResult.runProtected(Test, Protectable) line: 124 MyTestSetup(TestSetup).run(TestResult) line: 23 RemotePluginTestRunner(RemoteTestRunner).runTests(String[], String) line: 474 RemotePluginTestRunner(RemoteTestRunner).run() line: 342 RemotePluginTestRunner.main(String[]) line: 36 1.run() line: 110 RunnableLock.run() line: 35 UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 118 Display.runAsyncMessages(boolean) line: 2787 Display.readAndDispatch() line: 2458 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1575 Workbench.runUI() line: 1541 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 287 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 144 IDEApplication.run(Object) line: 102 UITestApplication.run(Object) line: 39 1.run(Object) line: 220 EclipseStarter.run(Object) line: 274 EclipseStarter.run(String[], Runnable) line: 129 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object[]) line: 324 Main.basicRun(String[]) line: 255 Main.run(String[]) line: 811 Main.main(String[]) line: 795 The variable is binding= SourceTypeBinding (id=88) compoundName= char[2][] (id=103) constantPoolName= char[31] (id=104) fields= FieldBinding[63] (id=105) fileName= char[66] (id=106) fPackage= PackageBinding (id=107) genericReferenceTypeSignature= char[41] (id=109) id= 2147483647 memberTypes= ReferenceBinding[0] (id=110) methods= MethodBinding[1] (id=111) modifiers= 1073741825 scope= null signature= char[33] (id=114) sourceName= char[23] (id=115) superclass= BinaryTypeBinding (id=116) superInterfaces= ReferenceBinding[0] (id=118) synthetics= null tagBits= 8589952768 typeVariables= TypeVariableBinding[2] (id=119)
Sorry, this doesn't compile. I'll have to wait for a stable version.
Fixed NPE problem in BindingKeyResolver#getCompilationUnit() by returning null if the scope is null. Added regression test BatchASTCreationTests#test045().
Added regression test BatchASTCreationTests#test050() to ensure that "java/util/List<+[Ljava/lang/Object;>;" is correctly restored.
Verified in I20050214-0927