Bug 92477 - [1.5][compiler] Internal compiler error: NullPointerException in ReferenceBinding.findSuperTypeErasingTo
Summary: [1.5][compiler] Internal compiler error: NullPointerException in ReferenceBin...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-22 23:42 EDT by Jean-François Morin CLA
Modified: 2005-05-11 09:55 EDT (History)
1 user (show)

See Also:


Attachments
Test case for reproducing the bug (1.39 MB, application/octet-stream)
2005-04-27 06:45 EDT, Jean-François Morin CLA
no flags Details
Test case, Zip archive instead of 7-Zip (1.63 MB, application/zip)
2005-04-27 08:31 EDT, Jean-François Morin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-François Morin CLA 2005-04-22 23:42:47 EDT
After migrating a project to JDK 1.5, which involved introducing generics and
enhanced for loops, everything compiles properly except for the class
com.additifs.brac.App (see below). If I remove this class, the error occurs on
the next one. If I remove all classes from this package, the error transfers to
the first class encountered in a subpackage (like a breadth-first search of the
package tree structure).

The whole exception detail is as follows:

Severity	Description	Resource	In Folder	Location	Creation Time
2	Internal compiler error	App.java	brac25/src/com/additifs/brac	line 0	22 avril
2005 22:50:41

java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.findSuperTypeErasingTo(ReferenceBinding.java:504)
	at
org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.boundCheck(TypeVariableBinding.java:90)
	at
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.resolve(ParameterizedTypeBinding.java:654)
	at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:53)
	at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.superclass(BinaryTypeBinding.java:771)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.detectHierarchyCycle(ClassScope.java:956)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.detectHierarchyCycle(ClassScope.java:918)
	at
org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:42)
	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:141)
	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:104)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1050)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperclass(ClassScope.java:719)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:856)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:243)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:195)
	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:307)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:321)
	at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:239)
	at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:189)
	at
org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:49)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:212)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:140)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:581)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1021)
	at org.eclipse.core.runtime.Platform.run(Platform.java:757)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:160)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:198)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:227)
	at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1021)
	at org.eclipse.core.runtime.Platform.run(Platform.java:757)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:230)
	at
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:249)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:278)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:139)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:200)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:67)

If you need any further information, please feel free to ask me. Thanks...
Comment 1 Jean-François Morin CLA 2005-04-22 23:52:38 EDT
I am trying to specify 3.1M6 as the target version but the Bugzilla system does
not let me do so even though I am the bug submitter. A bug in Bugzilla too?
Comment 2 Jean-François Morin CLA 2005-04-23 01:18:07 EDT
Some classes specific to my project, generated with a code generation
application, are in a Jar archive. The Jar was generated by an Ant script. If I
unjar them into a source folder and remove the Jar from the build path,
everything works, compiles, and executes properly. There seems to be a clue
around the presence of my core files in a Jar...
Comment 3 Philipe Mulet CLA 2005-04-23 05:34:47 EDT
Please provide steps to reproduce, then reopen.
Comment 4 Jean-François Morin CLA 2005-04-27 06:45:28 EDT
Created attachment 20396 [details]
Test case for reproducing the bug
Comment 5 Jean-François Morin CLA 2005-04-27 07:01:51 EDT
I just attached a test case for reproducing the bug. It is an Eclipse project
you just have to include into an existing workspace. It will not run since
several libraries required by some JARs (e.g., Struts) are missing, but it can
still compile without errors.

In the project, the bugtest.jar and src2 source folder have exactly the same
contents. The project is currently configured to include bugtest jar (and
exclude src2 folder), which reproduces the bug. If I change it to include the
non-JARred src2 folder (and exclude bugtest.jar), the bug does not occur anymore
and everthing compiles correctly.

By the way, bugtest.jar is a JAR I created manually with the JDK 1.5 jar
utility. My previous remark about an Ant script thus does not hold anymore.

The dbfw15.jar library is a database framework that makes extensive use of
Generics, and bugtest.jar uses the generic classes of this library. In my
original project, I saw that if I use non-generic classes in my specific classes
JAR (the equivalent of bugtest.jar), even with the same Generics-based
dbfw15.jar library, the bug won't occur. Several warnings will be issued, but no
errors.

This is why I see a clue in the combined use of Generics-based classes in JARs.
Comment 6 Philipe Mulet CLA 2005-04-27 08:06:06 EDT
Could you please redo the attachment using standard archive file (zip or jar) ? 
I cannot read it.
Comment 7 Jean-François Morin CLA 2005-04-27 08:31:21 EDT
Created attachment 20399 [details]
Test case, Zip archive instead of 7-Zip

Here is a Zip version. My first attachment was in 7-Zip format.
Comment 8 Philipe Mulet CLA 2005-04-27 10:28:02 EDT
Problems come from the fact that we lazily resolve some binary parameterized
type during hierarchy connecting stage. In sources, we do not perform bound
checks, in binaries we do them eagerly.
Comment 9 Philipe Mulet CLA 2005-04-27 10:53:51 EDT
My aggressive take on the problem would be: we stop checking bounds in
unresolved types. These can only occur through binaries.
In addition to performance gain, I wonder how invalid classfiles could be
created with problem parameterized type arguments. Need to double check
Comment 10 Philipe Mulet CLA 2005-04-27 10:57:11 EDT
Currently, our problem type creation will persist invalid parameterized types:
public class X<U extends Exception> {
	X<String> xs; // --> X<String>
}

I think we should remove such signatures in this case.
Comment 11 Philipe Mulet CLA 2005-04-27 11:10:28 EDT
Unclear how we would handle binary compatibility issues (i.e. at some point
X<String> was fine, but now it isn't anymore. Binaries could surface that).
Please investigate how other compilers are recovering from this.
Comment 12 Jean-François Morin CLA 2005-04-27 20:49:00 EDT
Everything works fine with the javac compiler provided with JDK 1.5.0_02.
Comment 13 Kent Johnson CLA 2005-04-29 16:32:16 EDT
Removed bounds checks in binary resolve.

javac does not detect binary incompatibilities which we will fix up with 
incremental build.
Comment 14 Olivier Thomann CLA 2005-05-11 09:55:06 EDT
Verified in I20050510-0010