6882235: invalid exponent causes silent javac crash

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2009-09-15 12:20:55 -07:00
parent e851626bac
commit 8a6e77c436
3 changed files with 20 additions and 1 deletions

View File

@ -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));

View File

@ -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
}

View File

@ -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