Bug 44715 - NullPointerException compiling Java file
Summary: NullPointerException compiling Java file
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 major with 2 votes (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-12 07:49 EDT by Kenneth Foo CLA
Modified: 2003-11-20 05:39 EST (History)
1 user (show)

See Also:


Attachments
workspace exhibiting the error (324.34 KB, application/octet-stream)
2003-10-14 16:47 EDT, Kenneth Foo CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Foo CLA 2003-10-12 07:49:15 EDT
I'm getting this error on JDK 1.4.2
with Eclipse 3.0M4

NIC Commons/src/com/nic/mail
line 0
------------------------------------------------------

Internal compiler error
java.lang.NullPointerException

	at org.eclipse.jdt.internal.compiler.codegen.CharArrayCache.hashCodeChar
(CharArrayCache.java:80)

	at org.eclipse.jdt.internal.compiler.codegen.CharArrayCache.get
(CharArrayCache.java:71)

	at org.eclipse.jdt.internal.compiler.codegen.ConstantPool.literalIndex
(ConstantPool.java:672)

	at org.eclipse.jdt.internal.compiler.codegen.ConstantPool.literalIndex
(ConstantPool.java:1062)

	at org.eclipse.jdt.internal.compiler.ClassFile.<init>
(ClassFile.java:137)

	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode
(TypeDeclaration.java:453)

	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode
(TypeDeclaration.java:512)

	at 
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode
(AbstractMethodDeclaration.java:210)

	at 
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode
(AbstractMethodDeclaration.java:156)

	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode
(TypeDeclaration.java:477)

	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode
(TypeDeclaration.java:531)

	at 
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode
(CompilationUnitDeclaration.java:176)

	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:521)

	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:328)

	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile
(AbstractImageBuilder.java:201)

	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile
(AbstractImageBuilder.java:151)

	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build
(BatchImageBuilder.java:51)

	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll
(JavaBuilder.java:211)

	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build
(JavaBuilder.java:139)

	at org.eclipse.core.internal.events.BuildManager$2.run
(BuildManager.java:475)

	at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:1018)

	at org.eclipse.core.runtime.Platform.run(Platform.java:461)

	at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:130)

	at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:201)

	at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:156)

	at org.eclipse.core.internal.events.BuildManager$1.run
(BuildManager.java:182)

	at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:1018)

	at org.eclipse.core.runtime.Platform.run(Platform.java:461)

	at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:185)

	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop
(BuildManager.java:219)

	at org.eclipse.core.internal.events.BuildManager.build
(BuildManager.java:247)

	at org.eclipse.core.internal.events.AutoBuildJob.doBuild
(AutoBuildJob.java:76)

	at org.eclipse.core.internal.events.AutoBuildJob.run
(AutoBuildJob.java:109)

	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:62)
Comment 1 Philipe Mulet CLA 2003-10-12 10:02:37 EDT
Can you pls provide steps to reproduce ?
Comment 2 John Keyes CLA 2003-10-13 11:01:55 EDT
I experienced the same issue with 3.0M3 and 3.0M4.  It occurs on a 'Rebuild
All'.  There were probably around 3,500-4,500 Java files in my workspace at the
time.
Comment 3 John Keyes CLA 2003-10-13 11:03:09 EDT
Apologies for the second comment but I forgot to mention, I experienced this bug
on Red Hat 8 and Windows 2000.
Comment 4 Philipe Mulet CLA 2003-10-13 14:15:52 EDT
We would need steps to reproduce and investigate a fix. Could you reduce the 
problem ? Likely the offending unit got an error with the exception message.
Comment 5 Olivier Thomann CLA 2003-10-14 11:15:18 EDT
Add CC'
Comment 6 Philipe Mulet CLA 2003-10-14 11:19:25 EDT
Would indicate a null char[] as an argument for #hashCodeChar
Comment 7 Olivier Thomann CLA 2003-10-14 11:23:24 EDT
Looking at the stack trace, it would mean that one binding is null. Therefore 
it won't make sense to try to create a class file for it. This could be an 
invalid code that we don't detect properly.
Comment 8 Philipe Mulet CLA 2003-10-14 13:29:58 EDT
I rather think it would be a null #constantPoolName() which only seem to be 
possible for a local type if generating its code prior to having computed the 
binary names (which in theory should never occur).

Need steps to reproduce.
Comment 9 Philipe Mulet CLA 2003-10-14 13:30:25 EDT
Please reopen once steps are provided
Comment 10 Kenneth Foo CLA 2003-10-14 16:47:07 EDT
Created attachment 6423 [details]
workspace exhibiting the error

Decompress the workspace into c:\work\test
Import the project into eclipse.

It shows the build error.
Attempt to save the java file will cause NPE.
Comment 11 Philipe Mulet CLA 2003-10-15 05:09:14 EDT
Reopening
Comment 12 Philipe Mulet CLA 2003-10-15 06:53:38 EDT
Reproduced with test case. Thanks a lot.
Comment 13 Philipe Mulet CLA 2003-10-15 06:56:39 EDT
Constant pool name for local type is indeed null.
class ByteArrayDataSource implements javax.activation.DataSource
Comment 14 Philipe Mulet CLA 2003-10-15 06:58:39 EDT
The problem seems to arise due to the fact a fake reachable local type is still 
being generated (and did not get computed a constant pool name, since not 
reachable).
Comment 15 Philipe Mulet CLA 2003-10-15 07:00:14 EDT
Simpler test case:

public class X {
	public static void main(String[] args) {
		if (true)
			return;
		class ShouldNotBeGenerated {
		}
	}
}
Comment 16 Philipe Mulet CLA 2003-10-15 07:20:04 EDT
Added regression test InnerEmulationTest#test110.
Fixed.
Comment 17 David Audel CLA 2003-11-20 05:39:43 EST
Verified.