JDK-7014715 : javac returns different error code for certain failure(s)
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-01-25
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b130Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Compiling reg test InterfaceInInner.java

class InterfaceInInner {
    InterfaceInInner() {
        class foo {
            interface A {
            }
        }
    }
}

fails as expected but as of nightly build of 1/25/11 returns 4 instead of 1.
This other reg tests which failed like this are
AnonStaticMember_2.java and QualifiedNew.java

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/afe226180744
03-02-2011

EVALUATION The different exit code indicates a javac crash, which is bad.
26-01-2011

EVALUATION Under some circumstances, javac will silently swallow a crash, especially after error messages have been generated. That may be what is happening here. See Main.java:448. } catch (Throwable ex) { // Nasty. If we've already reported an error, compensate // for buggy compiler error recovery by swallowing thrown // exceptions. if (comp == null || comp.errorCount() == 0 || options == null || options.isSet("dev")) bugMessage(ex); return EXIT_ABNORMAL;
26-01-2011

EVALUATION InterfaceInInner.java appears to have same results other than return code. QualifiedNew.java yields only 1 error instead of 2 in addition to the return code.This would hint at the crash. AnonStaticMember_2.java crashes whereas before it did not: g:\ws\7\tools\src\javac\devregtests]javac AnonStaticMember_2.java An exception has occurred in the compiler (1.7.0-ea). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) afte r checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.NullPointerException at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:3159) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3074) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3010) at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:663) at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:591) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:436) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:423) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:485) at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1702) at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1372) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:436) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:423) at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:454) at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:836) at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:725) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:436) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:423) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:485) at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:3148) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3074) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3010) at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1157) at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:847) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:806) at com.sun.tools.javac.main.Main.compile(Main.java:411) at com.sun.tools.javac.main.Main.compile(Main.java:329) at com.sun.tools.javac.main.Main.compile(Main.java:320) at com.sun.tools.javac.Main.compile(Main.java:76) at com.sun.tools.javac.Main.main(Main.java:61) Previously: g:\ws\7\tools\src\javac\devregtests]\jdk\promo\bin\javac AnonStaticMember_2.java AnonStaticMember_2.java:12: inner classes cannot have static declarations static void test() {} ^ 1 error
25-01-2011

EVALUATION For the record, here are the javac exit codes: static final int EXIT_OK = 0, // Compilation completed with no errors. EXIT_ERROR = 1, // Completed but reported errors. EXIT_CMDERR = 2, // Bad command-line arguments EXIT_SYSERR = 3, // System error or resource exhaustion. EXIT_ABNORMAL = 4; // Compiler terminated abnormally so the bug is not really that javac is returning different error codes -- it would appear to be crashing.
25-01-2011