Bug 204662 - org.eclipse.jdt.internal.compiler.parser.Parser.endParse throws NullPointerException
Summary: org.eclipse.jdt.internal.compiler.parser.Parser.endParse throws NullPointerEx...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.4 M3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 152883 188053 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-26 06:04 EDT by Roberto Javier Godoy CLA
Modified: 2007-11-05 09:18 EST (History)
4 users (show)

See Also:


Attachments
error log (7.09 KB, text/plain)
2007-09-26 06:04 EDT, Roberto Javier Godoy CLA
no flags Details
javac_1-6-0_02 log (616 bytes, text/plain)
2007-09-26 06:12 EDT, Roberto Javier Godoy CLA
no flags Details
Bug example source code (406 bytes, text/x-java-source)
2007-09-26 06:16 EDT, Roberto Javier Godoy CLA
no flags Details
Proposed fix (10.10 KB, patch)
2007-09-27 07:23 EDT, David Audel CLA
no flags Details | Diff
Better fix (10.51 KB, patch)
2007-09-28 04:32 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roberto Javier Godoy CLA 2007-09-26 06:04:56 EDT
Created attachment 79190 [details]
error log

Build ID: I20070625-1500

Steps To Reproduce:
1. Create a Java project and include the attached source file BadClass.java
2. Compile it


More information:

The attached example was simplified and it only contains the error cause.

The intent of the method is to do the following assignment
 People oPeople;
 {oPeople= (People) obj;}

Since the automated tool which made the source invoked Class.toString() instead of Class.getName() the resulting code was

class People oPeople;
{oPeople= (class People) obj;} 

When compiling, an internal compiler error occurs.
It DOES NOT occur unless the assignment is done inside its own scope. (i.e, the following example do not compiles, 
but the compiler errors are fine)

class People oPeople;
oPeople= (class People) obj;

All this examples are included into the attachment. You may also need a People class which may be implemented as:

public class People {}
Comment 1 Roberto Javier Godoy CLA 2007-09-26 06:12:24 EDT
Created attachment 79192 [details]
javac_1-6-0_02 log

Both javac 1.6.0_02 and javac 1.4.2  compile the example as expected (they correctly report the errors). 

The log for javac 1.4.2 is the same, except for the last error "reached end of file while parsing") which only occurs with 1.6.0_02
Comment 2 Roberto Javier Godoy CLA 2007-09-26 06:16:42 EDT
Created attachment 79193 [details]
Bug example source code
Comment 3 David Audel CLA 2007-09-27 07:22:23 EDT
I reproduce the problem with build I20070925-1406.

Simpler test case

public class X {
  public void foo() { 
    class Y ;
    {
      class Z ;
    }
  }
}
Comment 4 David Audel CLA 2007-09-27 07:23:54 EDT
Created attachment 79275 [details]
Proposed fix
Comment 5 David Audel CLA 2007-09-28 04:32:58 EDT
Created attachment 79355 [details]
Better fix
Comment 6 David Audel CLA 2007-09-28 04:40:12 EDT
Released for 3.4M3.

Tests added
  StatementRecoveryTests#test0045() -> test0047()
Comment 7 David Audel CLA 2007-09-28 06:33:36 EDT
*** Bug 152883 has been marked as a duplicate of this bug. ***
Comment 8 Jerome Lanneluc CLA 2007-10-29 06:23:33 EDT
Verified for 3.4M3 using I20071029-0800
Comment 9 David Audel CLA 2007-11-05 09:18:36 EST
*** Bug 188053 has been marked as a duplicate of this bug. ***