From d8abcff906b1779454932a1b6a3e21599f620791 Mon Sep 17 00:00:00 2001 From: jjg Date: Tue, 15 Sep 2009 12:20:55 -0700 Subject: [PATCH] 6882235: invalid exponent causes silent javac crash Reviewed-by: darcy --- .../com/sun/tools/javac/parser/JavacParser.java | 2 +- test/tools/javac/T6882235.java | 14 ++++++++++++++ test/tools/javac/T6882235.out | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/tools/javac/T6882235.java create mode 100644 test/tools/javac/T6882235.out diff --git a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index ce20bff0..ffe85955 100644 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -593,7 +593,7 @@ public class JavacParser implements Parser { //where boolean isZero(String s) { char[] cs = s.toCharArray(); - int base = ((Character.toLowerCase(s.charAt(1)) == 'x') ? 16 : 10); + int base = ((cs.length > 1 && Character.toLowerCase(cs[1]) == 'x') ? 16 : 10); int i = ((base==16) ? 2 : 0); while (i < cs.length && (cs[i] == '0' || cs[i] == '.')) i++; return !(i < cs.length && (Character.digit(cs[i], base) > 0)); diff --git a/test/tools/javac/T6882235.java b/test/tools/javac/T6882235.java new file mode 100644 index 00000000..453a8a38 --- /dev/null +++ b/test/tools/javac/T6882235.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6882235 + * @summary invalid exponent causes silent javac crash + * + * @compile/fail T6882235.java + * @compile/fail/ref=T6882235.out -XDrawDiagnostics T6882235.java + */ + +class T6882235 { + int i = ; // invalid expression + float f = 0e*; // invalid exponent, should not crash compiler + int j = ; // invalid expression +} diff --git a/test/tools/javac/T6882235.out b/test/tools/javac/T6882235.out new file mode 100644 index 00000000..92997686 --- /dev/null +++ b/test/tools/javac/T6882235.out @@ -0,0 +1,5 @@ +T6882235.java:11:13: compiler.err.illegal.start.of.expr +T6882235.java:12:15: compiler.err.malformed.fp.lit +T6882235.java:12:18: compiler.err.illegal.start.of.expr +T6882235.java:13:13: compiler.err.illegal.start.of.expr +4 errors -- GitLab