JDK-6326754 : Compiler will fail to handle -Xmaxerrs with -ve numbers
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2005-09-21
  • Updated: 2012-01-13
  • Resolved: 2012-01-13
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 b81Fixed
Related Reports
Duplicate :  
Description
Compiler will fail to handel -Xmaxerrs will -ve numbers. 
Though there are less chances that users to give -ve number for setting an error but compiler should give different output, say like -Xmaxwarns.  

When I tried like:
<output>
bash-3.00$ javac -Xmaxerrs -4 Test16.java
An exception has occurred in the compiler (1.6.0-ea). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after 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.TransTypes.retype(TransTypes.java:136)
        at com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:514)
        at com.sun.tools.javac.tree.Tree$Apply.accept(Tree.java:992)
        at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:346)
        at com.sun.tools.javac.comp.TransTypes.visitExec(TransTypes.java:477)
        at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:888)
        at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:43)
        at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:55)
        at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:146)
        at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:630)
        at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:346)
        at com.sun.tools.javac.comp.TransTypes.visitMethodDef(TransTypes.java:381)
        at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:545)
        at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:43)
        at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:55)
        at com.sun.tools.javac.tree.TreeTranslator.visitClassDef(TreeTranslator.java:120)
        at com.sun.tools.javac.comp.TransTypes.translateClass(TransTypes.java:690)
        at com.sun.tools.javac.comp.TransTypes.visitClassDef(TransTypes.java:368)
        at com.sun.tools.javac.tree.Tree$ClassDef.accept(Tree.java:487)
        at com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:346)
        at com.sun.tools.javac.comp.TransTypes.translateTopLevelClass(TransTypes.java:713)
        at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:722)
        at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:665)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:549)
        at com.sun.tools.javac.main.Main.compile(Main.java:680)
        at com.sun.tools.javac.main.Main.compile(Main.java:611)
        at com.sun.tools.javac.main.Main.compile(Main.java:607)
        at com.sun.tools.javac.Main.compile(Main.java:70)
        at com.sun.tools.javac.Main.main(Main.java:55)
bash-3.00$
</output>

I am not very sure whether code required or not but any way if required , please use the following code to reproduce.
<code>
class TestConstructor<T,K>{
    T t;
    K k;
    public TestConstructor(T t,K k){
        this.t =t;
    }
    public TestConstructor(K k){
        this.k = k;
        this.t = null;
    }
    public TestConstructor(T t){
        this.t=t;
        this.k=null;
    }
    public void setT(T t){
        this.t=t;
        this.k=null;
    }
    public void setT(K k){
        this.k = k;
        this.t = null;
    }
    public void setT(T t,K k){
        this.t = t;
        this.k = k;
    }
}
class TestC<T>{
    T t;
    public <T>void setT(T t){
        this.t = t;
    }
}
public class Test16{
    public static void main(String... arg){
        TestC tC =new TestC();
        tC.setT();
        TestConstructor tc = new TestConstructor("saaa");
        tc.setT("sasa");
        TestC<Integer> tC1 = new TestC();
        tC1.setT(545);
    }
}
</code>

Comments
EVALUATION Will treat 0 and negative numbers as invalid input and fall back on the default
10-09-2007

EVALUATION Problem reproduced with -Xmaxerrs -4 (as reported), and -Xmaxerrs 0. Issue is that if maxerrs <= 0, the Log.report will not increment the error count, thereby fooling latter phases into executing thinking that no errors have been found.
05-10-2005

SUGGESTED FIX Should verify/ensure that Log.MaxErrors and Log.MaxWarnings are both strictly positive, possibly giving an additional warning about an invalid value.
05-10-2005