changeset 1384:75c936d14c6a

8000483: cryptic error message when source file contains hash Summary: cryptic error message when source file contains hash Reviewed-by: jjg, mcimadamore Contributed-by: vicente.romero@oracle.com
author vromero
date Thu, 01 Nov 2012 12:47:11 +0000
parents bf54daa9dcd8
children bf76f4190ef8 2443d24d096a
files src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java src/share/classes/com/sun/tools/javac/resources/compiler.properties test/tools/javac/quid/T6999438.out
diffstat 3 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Nov 01 10:48:36 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Nov 01 12:47:11 2012 +0000
@@ -662,7 +662,10 @@
                             tk = TokenKind.EOF;
                             pos = reader.buflen;
                         } else {
-                            lexError(pos, "illegal.char", String.valueOf((int)reader.ch));
+                            String arg = (32 < reader.ch && reader.ch < 127) ?
+                                            String.format("%s", reader.ch) :
+                                            String.format("\\u%04x", (int)reader.ch);
+                            lexError(pos, "illegal.char", arg);
                             reader.scanChar();
                         }
                     }
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Nov 01 10:48:36 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Nov 01 12:47:11 2012 +0000
@@ -475,7 +475,7 @@
 
 # 0: string
 compiler.err.illegal.char=\
-    illegal character: \\{0}
+    illegal character: ''{0}''
 
 compiler.err.illegal.char.for.encoding=\
     unmappable character for encoding {0}
--- a/test/tools/javac/quid/T6999438.out	Thu Nov 01 10:48:36 2012 +0100
+++ b/test/tools/javac/quid/T6999438.out	Thu Nov 01 12:47:11 2012 +0000
@@ -1,4 +1,4 @@
-T6999438.java:8:9: compiler.err.illegal.char: 35
+T6999438.java:8:9: compiler.err.illegal.char: #
 T6999438.java:8:10: compiler.err.illegal.start.of.type
 T6999438.java:8:25: compiler.err.expected: token.identifier
 T6999438.java:8:26: compiler.err.expected: ';'