-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b35
-
x86
-
solaris_2.6
Name: akR10088 Date: 11/18/2003
When compiling the following code fragment:
double dbl_var;
dbl_var = 0xCAFE.BABE; /* no exponent. */
compiler (build 1.5.0-beta-b28) crashes with diagnostics:
javac -source 1.5 lex07305.java
lex07305.java:20: malformed floating point literal
dbl_var = 0xCAFE.BABE;
^
An exception has occurred in the compiler (1.5.0-beta). Please file a bug at the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NumberFormatException: For input string: "0xCAFE.BABE"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.FloatingDecimal.parseHexString(FloatingDecimal.java:1865)
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1041)
at java.lang.Double.valueOf(Double.java:446)
at com.sun.tools.javac.parser.Parser.literal(Parser.java:404)
at com.sun.tools.javac.parser.Parser.term3(Parser.java:833)
at com.sun.tools.javac.parser.Parser.term2(Parser.java:550)
at com.sun.tools.javac.parser.Parser.term1(Parser.java:521)
at com.sun.tools.javac.parser.Parser.term(Parser.java:477)
at com.sun.tools.javac.parser.Parser.termRest(Parser.java:491)
at com.sun.tools.javac.parser.Parser.term(Parser.java:480)
at com.sun.tools.javac.parser.Parser.term(Parser.java:459)
at com.sun.tools.javac.parser.Parser.blockStatements(Parser.java:1497)
at com.sun.tools.javac.parser.Parser.block(Parser.java:1421)
at com.sun.tools.javac.parser.Parser.block(Parser.java:1433)
at com.sun.tools.javac.parser.Parser.methodDeclaratorRest(Parser.java:2321)
at com.sun.tools.javac.parser.Parser.classOrInterfaceBodyDeclaration(Parser.java:2276)
at com.sun.tools.javac.parser.Parser.classOrInterfaceBody(Parser.java:2213)
at com.sun.tools.javac.parser.Parser.classDeclaration(Parser.java:2081)
at com.sun.tools.javac.parser.Parser.classOrInterfaceOrEnumDeclaration(Parser.java:2053)
at com.sun.tools.javac.parser.Parser.typeDeclaration(Parser.java:2043)
at com.sun.tools.javac.parser.Parser.compilationUnit(Parser.java:1989)
at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:270)
at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:294)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:380)
at com.sun.tools.javac.main.Main.compile(Main.java:598)
at com.sun.tools.javac.main.Main.compile(Main.java:546)
at com.sun.tools.javac.Main.compile(Main.java:41)
at com.sun.tools.javac.Main.main(Main.java:32)
Using decimal exponent (E) instead of hexadecimal (P) also causes similiar crash:
dbl_var = 0x1.1E-5;
======================================================================
Name: akR10088 Date: 11/19/2003
Actually, 0x1.1E-5 is also a hexadecimal floating-point literal without exponent (followed binary minus).
Another malformed literal which causes crash is:
dbl_var = 0x1.1p; /* exponent without signed integer */
======================================================================