Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 434607

Summary: [compiler][null]IllegalStateException in annotation processing system when working with generic methods
Product: [Eclipse Project] JDT Reporter: Alex W <awang060843>
Component: CoreAssignee: shankha banerjee <shankhba>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: manoj.palat, shankhba, stephan.herrmann
Version: 4.4   
Target Milestone: 4.4 RC3   
Hardware: PC   
OS: Mac OS X   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=434600
Whiteboard:
Attachments:
Description Flags
Example project where bug should be able to be duplicated none

Description Alex W CLA 2014-05-12 01:37:45 EDT
Created attachment 242951 [details]
Example project where bug should be able to be duplicated

On Eclipse Luna M7 Build ID 20140508-1440, Java 1.8.0_05.

This bug has been a little more difficult to isolate. It appears several factors affect it, and changing pretty much anything will result in the exception vanishing.

Essentially, I wanted to remove a default implementation of a method in an interface. Went fine until I tried to save, upon which I got an IllegalStateException:

eclipse.buildId=4.4.0.I20140501-0200
java.version=1.8.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.standard.product -keyring /Users/awang/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.standard.product -keyring /Users/awang/.eclipse_keyring -showlocation

org.eclipse.jdt.core
Error
Mon May 12 01:31:07 EDT 2014
Errors running builder 'Java Builder' on project 'IllegalStateBug'.

java.lang.IllegalStateException
	at org.eclipse.jdt.internal.compiler.lookup.AnnotatableTypeSystem.getAnnotatedType(AnnotatableTypeSystem.java:271)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createAnnotatedType(LookupEnvironment.java:988)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.substitute(ParameterizedGenericMethodBinding.java:742)
	at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:489)
	at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:618)
	at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:507)
	at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:618)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.substitute(Scope.java:442)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.<init>(ParameterizedGenericMethodBinding.java:500)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createParameterizedGenericMethod(LookupEnvironment.java:831)
	at org.eclipse.jdt.internal.compiler.lookup.MethodBinding.asRawMethod(MethodBinding.java:208)
	at org.eclipse.jdt.internal.compiler.lookup.MethodVerifier.computeSubstituteMethod(MethodVerifier.java:682)
	at org.eclipse.jdt.internal.compiler.lookup.MethodVerifier.isParameterSubsignature(MethodVerifier.java:846)
	at org.eclipse.jdt.internal.compiler.lookup.MethodVerifier.areMethodsCompatible(MethodVerifier.java:77)
	at org.eclipse.jdt.internal.compiler.lookup.MethodVerifier.doesMethodOverride(MethodVerifier.java:745)
	at org.eclipse.jdt.internal.compiler.lookup.ImplicitNullAnnotationVerifier.collectOverriddenMethods(ImplicitNullAnnotationVerifier.java:196)
	at org.eclipse.jdt.internal.compiler.lookup.ImplicitNullAnnotationVerifier.findAllOverriddenMethods(ImplicitNullAnnotationVerifier.java:181)
	at org.eclipse.jdt.internal.compiler.lookup.ImplicitNullAnnotationVerifier.checkImplicitNullAnnotations(ImplicitNullAnnotationVerifier.java:98)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.createArgumentBindings(SourceTypeBinding.java:2003)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor(SourceTypeBinding.java:1970)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.methods(SourceTypeBinding.java:1463)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:851)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:422)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:763)
	at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
	at java.lang.Thread.run(Thread.java:745)

Attached is a project where you might be able to duplicate this. The interface in question is located in ast.visitor.AbstractNodeVisitor. The default method and its replacement are at the bottom of the file.

Deleting CopyableNode and all references to it results in no error. Removing some methods from the AbstractNodeVisitor interface and SizeVisitor results in no error. Removing SizeVisitor results in no error. The error only occurs consistently when going from the default implementation to no implementation, and only at the transition (i.e. only the first compile after removing the default implementation and uncommenting the non-default signature will result in the error).
Comment 1 Manoj N Palat CLA 2014-05-12 02:04:50 EDT
thanks for taking a look, shankha
Comment 2 shankha banerjee CLA 2014-05-21 09:16:11 EDT
I was able to reproduce. My scenario is a little different from what Alex has reported. This is with the latest release: 

Version: Luna (4.4)
Build id: I20140427-2030

Thanks
Comment 3 shankha banerjee CLA 2014-05-21 09:18:46 EDT
(In reply to shankha banerjee from comment #2)
> I was able to reproduce. My scenario is a little different from what Alex
> has reported. This is with the latest release: 
> 
> Version: Luna (4.4)
> Build id: I20140427-2030
> 
> Thanks

Comment the function:

default R visit(final NonNode node) {
		throw new IllegalStateException(node.getClass().getSimpleName()
				+ " instances should never be visited by a "
				+ this.getClass().getSimpleName());
	}

in AbstractNodeVisitor.java and save. 

You would notice the error. Does not happen with Project clean.

Thanks
Comment 4 shankha banerjee CLA 2014-05-21 10:21:11 EDT
Please see Bug 435399.
Comment 5 shankha banerjee CLA 2014-05-21 13:30:58 EDT
(In reply to shankha banerjee from comment #3)
> (In reply to shankha banerjee from comment #2)

The issue cannot be reproduced by the compiler. It can only be reproduced by through the reconciler.
Comment 6 Stephan Herrmann CLA 2014-05-22 14:40:46 EDT
shankha, what kind of type binding did you observe in this bug? 
Was kind() == INTERSECTION_TYPE like in the other bug?
Comment 7 shankha banerjee CLA 2014-05-23 00:44:05 EDT
Hi Stephan,
It is INTERSECTION_TYPE.
I don't see the Illegal State Exception after applying your patch in Bug 435399.

Thanks
Comment 8 shankha banerjee CLA 2014-05-23 00:45:00 EDT

*** This bug has been marked as a duplicate of bug 435399 ***