Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085459 | emb-9 | Joel Borggrén-Franck | P4 | Resolved | Fixed | team |
FULL PRODUCT VERSION :
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
CYGWIN_NT-6.1 Penguin 1.7.32(0.274/5/3) 2014-08-13 23:06 x86_64 Cygwin
A DESCRIPTION OF THE PROBLEM :
When doing annotation processing in a subclass of AbstractProcessor, printing only string "\n" throws exception for array out of bounds. It turns out that com.sun.tools.javac.util.BasicDiagnosticFormatter splits the string by "\n" and assumes that there is at least one element in resulting array.
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Extend an javax.annotation.processing.AbstractProcessor
2. Inside process method, try printing an empty line
(processingEnv.getMessager().printMessage(Kind.NOTE,"\n");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result is that an empty line should be printed during annotation processing.
ACTUAL -
javac throws exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.7.0_15). 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.ArrayIndexOutOfBoundsException: 0
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:116)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMeta(BasicDiagnosticFormatter.java:184)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatDiagnostic(BasicDiagnosticFormatter.java:100)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.format(AbstractDiagnosticFormatter.java:114)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:112)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:67)
at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:434)
at com.sun.tools.javac.util.Log.report(Log.java:400)
at com.sun.tools.javac.util.Log.reportDeferredDiagnostics(Log.java:373)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.showDiagnostics(JavacProcessingEnvironment.java:1045)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:342)
at com.sun.tools.javac.main.Main.compile(Main.java:333)
at com.sun.tools.javac.Main.compile(Main.java:76)
at com.sun.tools.javac.Main.main(Main.java:61)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class MyPreprocessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> types,RoundEnvironment rEnv) {
processingEnv.getMessager().printMessage(Kind.NOTE,"\n");
return true;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Enter just one empty space in the printout string: "\n" -> " \n". This way string splitting returns an array of length 1.
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
CYGWIN_NT-6.1 Penguin 1.7.32(0.274/5/3) 2014-08-13 23:06 x86_64 Cygwin
A DESCRIPTION OF THE PROBLEM :
When doing annotation processing in a subclass of AbstractProcessor, printing only string "\n" throws exception for array out of bounds. It turns out that com.sun.tools.javac.util.BasicDiagnosticFormatter splits the string by "\n" and assumes that there is at least one element in resulting array.
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Extend an javax.annotation.processing.AbstractProcessor
2. Inside process method, try printing an empty line
(processingEnv.getMessager().printMessage(Kind.NOTE,"\n");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result is that an empty line should be printed during annotation processing.
ACTUAL -
javac throws exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.7.0_15). 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.ArrayIndexOutOfBoundsException: 0
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:116)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMeta(BasicDiagnosticFormatter.java:184)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatDiagnostic(BasicDiagnosticFormatter.java:100)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.format(AbstractDiagnosticFormatter.java:114)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:112)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:67)
at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:434)
at com.sun.tools.javac.util.Log.report(Log.java:400)
at com.sun.tools.javac.util.Log.reportDeferredDiagnostics(Log.java:373)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.showDiagnostics(JavacProcessingEnvironment.java:1045)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:342)
at com.sun.tools.javac.main.Main.compile(Main.java:333)
at com.sun.tools.javac.Main.compile(Main.java:76)
at com.sun.tools.javac.Main.main(Main.java:61)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class MyPreprocessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> types,RoundEnvironment rEnv) {
processingEnv.getMessager().printMessage(Kind.NOTE,"\n");
return true;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Enter just one empty space in the printout string: "\n" -> " \n". This way string splitting returns an array of length 1.
- backported by
-
JDK-8085459 ArrayIndexOutOfBoundsException with annotation processing printout of empty line
-
- Resolved
-