Bug 230070 - [1.5][compiler] Internal compiler error: NullPointerException at org.eclipse.jdt.internal.compiler.ast.CastExpression.checkUnsafeCast()
Summary: [1.5][compiler] Internal compiler error: NullPointerException at org.eclipse....
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.4 RC1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-03 08:03 EDT by Marcel Rieser CLA
Modified: 2008-05-13 10:04 EDT (History)
2 users (show)

See Also:


Attachments
workspace with one project that does not compile in Eclipse 3.4M7 (54.95 KB, application/x-gzip)
2008-05-05 10:50 EDT, Marcel Rieser CLA
no flags Details
Regression test (1.24 KB, patch)
2008-05-05 11:48 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed patch (6.02 KB, patch)
2008-05-06 04:53 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel Rieser CLA 2008-05-03 08:03:40 EDT
Build ID: I20080502-0100

Steps To Reproduce:
1. create a new java project
2. add the class "java.util.TreeMap" from the GNU classpath project (http://www.gnu.org/software/classpath/)
3. next to many other errors (due to other missing classes, wrong package declaration, etc), Eclipse also shows an Internal Compiler Error at Line 1.


More information:
Using Eclipse 3.4M7 on Mac OS X 10.5.2, running on Core 2 Duo (Intel-Architecture), using Apple's JVM 1.5.0.
The same error does not show when using Eclipse 3.4M6a.
Solving all the other errors shown by the compiler does not solve the NullPointerException at org.eclipse.jdt.internal.compiler.ast.CastExpression.checkUnsafeCast(CastExpression.java:300)
Comment 1 Olivier Thomann CLA 2008-05-04 21:13:00 EDT
Could not reproduce.
Could you please give more details on the version that doesn't compile?
Compiler settings?

Would it be possible for you to isolate a test case ? That would help us reproducing it and then fixing it.
Thanks.
Comment 2 Marcel Rieser CLA 2008-05-05 04:35:19 EDT
Thanks, your message made me play around a bit more:
If I use a clean install of Eclipse 3.4M7 (no additional plugins installed) and open my *existing* workspace (created with Eclipse 3.2 or Eclipse 3.3 some while ago, contains 18 projects, not all Java), I get the mentioned error. I also get the error when I create a new java project in my existing workspace with the mentioned class in the buildpath.
However, if I create a *new* workspace with a new project with the mentioned class, I do *not* get the error. So it seems to be somehow workspace-dependent, but not project-dependent.
This may explain why you are not able to reproduce it. But still, the same *existing* playground in Eclipse 3.4M6a compiled without problems...
I'll try to somehow reduce my existing workspace to fewer projects etc in the hope to isolate the problem -- but that might take a while.
Is there something like "clean workspace", similar to "clean project"? Cleaning the projects didn't help, but as it seems to be workspace-dependent, "cleaning the workspace" might help if something like that is possible.
Comment 3 Philipe Mulet CLA 2008-05-05 07:04:53 EDT
Please provide detailed steps to reproduce. I tried to checkout HEAD from CVS gnu classpath, and could not reproduce either. There were many other compiler errors, likely due to inconsistencies in the libs.

Comment 4 Marcel Rieser CLA 2008-05-05 10:50:00 EDT
Created attachment 98640 [details]
workspace with one project that does not compile in Eclipse 3.4M7

project in given workspace does not compile in Eclipse 3.4M7, but does in Eclipse 3.4M6a, on Mac OS X 10.5.2 (x86) and Apple-JVM 1.5.0
Comment 5 Marcel Rieser CLA 2008-05-05 11:01:04 EDT
I just added an attachment to this bug (id=98640; 2008-05-05 10:50 -0400, 54.95KB). The attachment contains a very small workspace with one project "test", that contains 6 classes from GNU Classpath 0.97.1 (slightly modified import-statements so it compiles in this small example). I deleted most directories in workspace/.metadata/.plugins/ to reduce the filesize, and only included those directories that are needed to reproduce the bug on my machine.
To reproduce the bug:
1) uncompress the attachment --> will create a directory "workspace"
2) Start a clean Eclipse 3.4M7 (I20080502-0100) and choose the workspace from (1)
3) Clean the project "test" --> There is an error on line 0 in TreeMap.java

Opening the same workspace in Eclipse 3.4M6a (I20080409-1425) and cleaning the project does not reproduce the error. Opening the workspace again in 3.4M7 and cleaning the project generates the error again.
Quitting Eclipse, deleting workspace/.metadata/.plugins/org.eclipse.core.runtime, launching 3.4M7 and cleaning the project solves the problem.

So I think there must be some setting in workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/ that triggers the error, but I haven't found out yet which one it is...
Comment 6 Olivier Thomann CLA 2008-05-05 11:05:17 EDT
Ok, I'll try to reproduce and make a small compiler regression test out of it.
Thanks for your time.
Comment 7 Olivier Thomann CLA 2008-05-05 11:15:50 EDT
Reproduced using your workspace.
I could not however reproduce it using a new workspace and importing your test project in it.
Comment 8 Olivier Thomann CLA 2008-05-05 11:18:35 EDT
It has to do with the compiler settings. If I restore default settings for your workspace, I can no longer reproduce the failure.
I'll try to extract a small test case.
Comment 9 Olivier Thomann CLA 2008-05-05 11:47:18 EDT
You need to check for unnecessary cast.
Comment 10 Olivier Thomann CLA 2008-05-05 11:48:24 EDT
Created attachment 98650 [details]
Regression test
Comment 11 Marcel Rieser CLA 2008-05-05 12:29:56 EDT
I can confirm that setting the compiler option "Unnecessary cast or 'instanceof' operation" (in Preferences > Java > Compiler > Errors/Warnings) to "Ignore" gets rid of the error message, but setting it to "Warning" generates it again. Thanks for figuring this out. This solves for me the problem temporarily. 
Comment 12 Philipe Mulet CLA 2008-05-06 04:53:33 EDT
Created attachment 98764 [details]
Proposed patch
Comment 13 Philipe Mulet CLA 2008-05-06 04:54:20 EDT
Added GenericTypeTest#test1314.
Released for 3.4RC1.
Fixed
Comment 14 Kent Johnson CLA 2008-05-06 16:41:41 EDT
+1 for 3.4RC1
Comment 15 David Audel CLA 2008-05-13 10:04:32 EDT
Verified for 3.4RC1 using I20080510-2000