JDK-4401373 : NullPointerException from the compiler
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: other
  • CPU: x86
  • Submitted: 2001-01-03
  • Updated: 2004-04-01
  • Resolved: 2001-04-05
Related Reports
Duplicate :  
Relates :  
Description
1.3.0 compiler sometimes fails with the following exception:
(we suspect this happens when you have two classes with the same name - one being regular (outer) class and the other inner class (in different packages),
both fully qualified)

compile:
    [javac] Compiling 40 source files to C:\build\ant\src
    [javac] C:\build\ant\src\org\apache\tools\ant\module\AntExecutor.java:91: cannot access org.openide.util.Task
    [javac] file org\openide\util\Task.class not found
    [javac]         private ExecutorTask t1, t2;
    [javac]                 ^
    [javac] C:\build\ant\src\org\apache\tools\ant\module\AntExecutor.java:73: operator == cannot be applied to org.openide.execution.ExecutorTask,<null>
    [javac]                 if (last == null) {
    [javac]                          ^
    [javac] An exception has occurred in the compiler (1.3.0). Please file a bug at the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi).  Include your program and the following diagnostic in your report.  Thank you.
    [javac] java.lang.NullPointerException
    [javac]     at com.sun.tools.javac.v8.comp.Attr.check(Attr.java:81)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.checkId(Attr.java:1274)
    [javac]     at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:1141)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$Select.visit(Tree.java:963)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:234)
    [javac]     at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:926)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$Assign.visit(Tree.java:848)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:234)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribExpr(Attr.java:262)
    [javac]     at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:604)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$Exec.visit(Tree.java:699)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:234)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:276)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribStats(Attr.java:294)
    [javac]     at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:428)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:492)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:234)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:276)
    [javac]     at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:386)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$MethodDef.visit(Tree.java:441)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:234)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:276)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribClass(Attr.java:1415)
    [javac]     at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:347)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$ClassDef.visit(Tree.java:402)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:234)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:276)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribClass(Attr.java:1415)
    [javac]     at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:378)
    [javac]     at com.sun.tools.javac.v8.Main.compile(Main.java:247)
    [javac]     at com.sun.tools.javac.Main.compile(Main.java:26)
    [javac]     at java.lang.reflect.Method.invoke(Native Method)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.doModernCompile(Javac.java:525)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:334)
    [javac]     at org.apache.tools.ant.Target.execute(Target.java:142)
    [javac]     at org.apache.tools.ant.Project.runTarget(Project.java:818)
    [javac]     at org.apache.tools.ant.Project.executeTarget(Project.java:532)
    [javac]     at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:213)
    [javac]     at org.apache.tools.ant.Target.execute(Target.java:142)
    [javac]     at org.apache.tools.ant.Project.runTarget(Project.java:818)
    [javac]     at org.apache.tools.ant.Project.executeTarget(Project.java:532)
    [javac]     at org.netbeans.nbbuild.NbMerge.execute(NbMerge.java:135)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:122)
    [javac]     at org.apache.tools.ant.Target.execute(Target.java:142)
    [javac]     at org.apache.tools.ant.Project.runTarget(Project.java:818)
    [javac]     at org.apache.tools.ant.Project.executeTarget(Project.java:532)
    [javac]     at org.apache.tools.ant.Project.executeTargets(Project.java:506)
    [javac]     at org.apache.tools.ant.Main.runBuild(Main.java:420)
    [javac]     at org.apache.tools.ant.Main.main(Main.java:149)

I have observed it on Win2000 but I suppose this not being platform specific
(was seen on other platforms as well).
I am able to supply the whole source and env when this particular case happened
(if required (50MB)).

-------------------------------------------------------------
Two files attached: ant1.2.zip and Build.zip. Steps to reproduce
on MS-Win machine (didn't try unix, might work as well):
1. unpack both files to c:2. add ant1.2\bin\ant.bat to your path (and edit it if necessary)
3. cd c:\build\nbbuild
4. ant

###@###.### 2001-02-14

Demonstration using plain javac:

1. unpack the attached build.zip (i am using e:\ on Win2000, with ant1.2 in c:\ant1.2)

2. cd build\ant\src\org\apache\tools\ant\module
3. javac -classpath e:\build\openide\netbeans\lib\openide.jar;e:\build\ant\release\modules\ext\ant.jar;e:\build\ant\release\modules\ext\xerces.jar;e:\build\core\release\lib\ext\jaxp.jar;e:\build\core\release\lib\ext\parser.jar;c:\ant1.2\lib\ant.jar;c:\ant1.2\lib\jaxp.jar;c:\ant1.2\lib\parser.jar -sourcepath ..\..\..\..\.. -verbose *.java

You get the exception and nothing is compiled.

###@###.### 2001-03-21

Please check the classpath - the openide.jar has to be on your classpath (as it is in my example on the first place). If you remove the -verbose the output will not be that long and the error will still be there.

###@###.### 2001-03-22

Comments
WORK AROUND This is comment and workaround for our project by ###@###.###: http://www.netbeans.org/unbranded-source/browse/openide/build.xml?rev=1.42&content-type=text/x-cvsweb-markup <target name="13javac-workaround" depends="init"> <!-- JDK 1.3 Javac at least on Linux has a serious bug as regards --> <!-- situations where one package contains a public class and a public --> <!-- inner class of the same name: though the inner class should be qualified --> <!-- by its outer class, something gets confused and the compiler thinks --> <!-- it cannot find the simple class whenever it is used. --> <!-- Forcing use of 1.2 compiler is possible with -Dbuild.compiler=classic, --> <!-- but this slows down builds, messes up Jikes users, and is not apparently --> <!-- needed for all 1.3 Javac versions. Easier to ensure that the outer classes --> <!-- appear in a separate JAR file at compile time, this assuages the compiler. --> <javac srcdir="src" destdir="src" deprecation="${build.compiler.deprecation}" debug="${build.compiler.debug}"> <!-- Compare inner classes of Actions: --> <include name="org/openide/awt/ToolbarButton.java"/> <include name="org/openide/awt/ToolbarToggleButton.java"/> <!-- Compare inner class of RequestProcessor: --> <include name="org/openide/util/Task.java"/> <!-- Included because Task imports it: --> <include name="org/openide/util/TaskListener.java"/> </javac> <jar jarfile="openide-13javac-workaround.jar" basedir="src" compress="false"> <include name="org/openide/awt/ToolbarButton.class"/> <include name="org/openide/awt/ToolbarButton$*.class"/> <include name="org/openide/awt/ToolbarToggleButton.class"/> <include name="org/openide/awt/ToolbarToggleButton$*.class"/> <include name="org/openide/util/Task.class"/> <include name="org/openide/util/Task$*.class"/> <include name="org/openide/util/TaskListener.class"/> <include name="org/openide/util/TaskListener$*.class"/> </jar> </target>
11-06-2004

PUBLIC COMMENTS .
10-06-2004

EVALUATION I hate to have to say this, but I need a self-contained test case including all source code and a script to run the compiler. Ideally it should be a small example, but I'll take a large example if that's all you can do. neal.gafter@Eng 2001-02-13 I have the test case; thanks. neal.gafter@Eng 2001-02-15 Looking at it more closely, I see you don't use javac. Rather, you invoke a class internal to the compiler. I'm not willing to run the rest of your java application, and I can't easily diagnose the problem without the compiler being run as a command. Can you please modify the test case to cause the compiler to be invoked as a command? It would be very helpful if this test case were narrowed down significantly. neal.gafter@Eng 2001-03-05 I tried it and got a bunch of errors from the compiler. They look right. It didn't crash. I tried it on Solaris and NT4 with the same results. I have attached the compiler output as cmd.out. I still don't have enough to reproduce the problem. neal.gafter@Eng 2001-03-21 Yes, I did have the class path wrong. I fixed it and could reproduce the bug in version 1.3 of javac. I tried a prerelease of 1.4 javac, and did not have the problem. When the beta comes out, give it a try. I have attached the output of the run. I am closing this as will not fix. However, if you can reproduce the problem with 1.4 open a new bug and I will try to fix it. neal.gafter@Eng 2001-03-22 I *believe* this has been fixed in JDK 1.4.2 (not in 1.4.1), based on scattered reports. I plan on removing the workaround JAR from the NetBeans build process as we now require JDK 1.4.2 at build time and I am not aware of any reports of it happening under JDK 1.4.2, while some people who have had it happen using 1.3.x or 1.4.1 report the bug not happening under 1.4.2. (I have seen it happen with the NetBeans IDE's background parsing (to highlight errors), but as this is using a specially imported copy of javac, I have to assume it is using a pre-1.4.2 copy rather than the one included in tools.jar.) Currently I build with 1.4.2_04 and have not seen it happen, despite the fact that many of our modules no longer include the workaround JAR at the head of the classpath. ###@###.### 2004-04-01
01-04-2004