Summary: | [1.5][compiler] NPE in CompilationUnitProblemFinder.process with explicit wildcard invocation | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Alexis Lauthier <alx7539-eclipse> | ||||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | minor | ||||||||
Priority: | P3 | CC: | eclipse, maxime_daniel, philippe_mulet | ||||||
Version: | 3.3 | ||||||||
Target Milestone: | 3.3 M5 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Alexis Lauthier
2007-01-30 11:51:53 EST
This is an invalid case that is not propertly reported. When simply trying to compile the code, we get: Internal compiler error java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ast.MessageSend.analyseCode(MessageSend.java:45) at org.eclipse.jdt.internal.compiler.ast.MessageSend.analyseCode(MessageSend.java:54) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.analyseCode(MethodDeclaration.java:90) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.internalAnalyseCode(TypeDeclaration.java:668) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:253) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:107) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:621) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:391) at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:3024) at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1324) at org.eclipse.jdt.core.tools.compiler.Compile.main(Compile.java:86) javac 1.6 u1_b03 reports: X.java:19: illegal start of type list.add(X.<?, Object>create("", "")); ^ X.java:19: illegal start of expression list.add(X.<?, Object>create("", "")); ^ 2 errors We have no binding for the method invocation: X.<?, Object>create("", "") without reporting any error. The problem seems to come from the fact that the wildcard without a bound returns null in the resolveType call without logging any error. Added disabled regression test org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest._test1101() Created attachment 57817 [details]
Proposed fix
Looks good to me. I missed a case with the first fix where the parameterized type cannot be resolved. In this case, we ended up reporting too many errors. I propose to move the check inside the message send class. See my second proposal. Created attachment 57918 [details]
New patch
Released for 3.3M5. Regression test enabled. Verified for 3.3 M5 using build I20070205-0009 *** Bug 174724 has been marked as a duplicate of this bug. *** Has this really been fixed in 3.3 M5? I could reproduce bug 174724 (marked as duplicate) using M5. Your test case from bug 174724 compiles fine using M5. d:\tests_sources>java -jar org.eclipse.jdt.core_3.3.0.v_735.jar X.java -1.5 ---------- 1. WARNING in X.java (at line 3) Class foo = Class.<? extends Object>forName(Integer.class.getName()); ^^^^^ Class is a raw type. References to generic type Class<T> should be parameterized ---------- 2. ERROR in X.java (at line 3) Class foo = Class.<? extends Object>forName(Integer.class.getName()); ^^^^^^^^^^^^^^^^ Wildcard is not allowed at this location ---------- 2 problems (1 error, 1 warning) Never mind, I was actually using M4. I was reading the build number from the log file, and I had inadvertently been running M5 and M4 on the same workspace (the log file had some sessions describing the M5 build, and others the M4 build). Should use the About dialog box next time. |