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
--- 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: ';'