提交 d8abcff9 编写于 作者: J jjg

6882235: invalid exponent causes silent javac crash

Reviewed-by: darcy
上级 7834e84c
......@@ -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));
......
/*
* @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
}
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册