FULL PRODUCT VERSION :
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP Pro
EXTRA RELEVANT SYSTEM CONFIGURATION :
Normal PC
A DESCRIPTION OF THE PROBLEM :
Compiler should NOT crash even when given bad source code.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the given source code, will crash compiler every time.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilers should not crash, the parser should have noticed the mistake and reported it.
ACTUAL -
The compiler crashed.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.5.0_02). 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.Attr.visitNewClass(Attr.java:1352)
at com.sun.tools.javac.tree.Tree$NewClass.accept(Tree.java:845)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:339)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1105)
at com.sun.tools.javac.tree.Tree$Apply.accept(Tree.java:819)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:302)
at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:896)
at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:734)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:331)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:599)
at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:532)
at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:482)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2473)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2406)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2355)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:444)
at com.sun.tools.javac.main.Main.compile(Main.java:592)
at com.sun.tools.javac.main.Main.compile(Main.java:544)
at com.sun.tools.javac.Main.compile(Main.java:67)
at com.sun.tools.javac.Main.main(Main.java:52)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
import java.util.Comparator;
public class Test
{
public static void main(String args[])
{
String[] stringArray = {"one", "two", "three", "four", "five", "six"};
// sorting lexicographically by last letter
Arrays.sort(stringArray, new <Object>Comparator()
{
public int compare(Object o1, Object o2)
{
return(((String) o1).charAt(((String) o1).length() - 1) -
((String) o2).charAt(((String) o2).length() - 1));
}
});
System.out.println(Arrays.toString(stringArray));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The work around is simple, enter in good code. The problem is the compiler should not crash even if given bad code.
###@###.### 2005-03-22 02:22:42 GMT
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP Pro
EXTRA RELEVANT SYSTEM CONFIGURATION :
Normal PC
A DESCRIPTION OF THE PROBLEM :
Compiler should NOT crash even when given bad source code.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the given source code, will crash compiler every time.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilers should not crash, the parser should have noticed the mistake and reported it.
ACTUAL -
The compiler crashed.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.5.0_02). 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.Attr.visitNewClass(Attr.java:1352)
at com.sun.tools.javac.tree.Tree$NewClass.accept(Tree.java:845)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:339)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1105)
at com.sun.tools.javac.tree.Tree$Apply.accept(Tree.java:819)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:302)
at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:896)
at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:734)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:331)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:599)
at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:532)
at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:482)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2473)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2406)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2355)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:444)
at com.sun.tools.javac.main.Main.compile(Main.java:592)
at com.sun.tools.javac.main.Main.compile(Main.java:544)
at com.sun.tools.javac.Main.compile(Main.java:67)
at com.sun.tools.javac.Main.main(Main.java:52)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
import java.util.Comparator;
public class Test
{
public static void main(String args[])
{
String[] stringArray = {"one", "two", "three", "four", "five", "six"};
// sorting lexicographically by last letter
Arrays.sort(stringArray, new <Object>Comparator()
{
public int compare(Object o1, Object o2)
{
return(((String) o1).charAt(((String) o1).length() - 1) -
((String) o2).charAt(((String) o2).length() - 1));
}
});
System.out.println(Arrays.toString(stringArray));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The work around is simple, enter in good code. The problem is the compiler should not crash even if given bad code.
###@###.### 2005-03-22 02:22:42 GMT
- duplicates
-
JDK-6231847 crash: java.lang.NullPointerException at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1352)
-
- Closed
-