8000483: cryptic error message when source file contains hash
authorvromero
Thu, 01 Nov 2012 12:47:11 +0000
changeset 14370 eefd0e6642a8
parent 14369 3d660d08d1f7
child 14371 5652321f1ae4
child 14439 fc971a9560d0
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
langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
langtools/test/tools/javac/quid/T6999438.out
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Nov 01 10:48:36 2012 +0100
+++ b/langtools/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/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Nov 01 10:48:36 2012 +0100
+++ b/langtools/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/langtools/test/tools/javac/quid/T6999438.out	Thu Nov 01 10:48:36 2012 +0100
+++ b/langtools/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: ';'