mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 09:53:18 +00:00
8078559: Update error message to indicate illegal character when encoding set to ascii
When an input character cannot be decoded, include it in the produced error Reviewed-by: jjg
This commit is contained in:
parent
ef51223aa3
commit
41258c689d
@ -380,13 +380,17 @@ public abstract class BaseFileManager implements JavaFileManager {
|
||||
dest = CharBuffer.allocate(newCapacity).put(dest);
|
||||
} else if (result.isMalformed() || result.isUnmappable()) {
|
||||
// bad character in input
|
||||
StringBuilder unmappable = new StringBuilder();
|
||||
int len = result.length();
|
||||
|
||||
log.error(new SimpleDiagnosticPosition(dest.limit()),
|
||||
"illegal.char.for.encoding",
|
||||
charset == null ? encodingName : charset.name());
|
||||
for (int i = 0; i < len; i++) {
|
||||
unmappable.append(String.format("%02X", inbuf.get()));
|
||||
}
|
||||
|
||||
// skip past the coding error
|
||||
inbuf.position(inbuf.position() + result.length());
|
||||
String charsetName = charset == null ? encodingName : charset.name();
|
||||
|
||||
log.error(dest.limit(),
|
||||
Errors.IllegalCharForEncoding(unmappable.toString(), charsetName));
|
||||
|
||||
// undo the flip() to prepare the output buffer
|
||||
// for more translation
|
||||
|
||||
@ -522,8 +522,9 @@ compiler.err.icls.cant.have.static.decl=\
|
||||
compiler.err.illegal.char=\
|
||||
illegal character: ''{0}''
|
||||
|
||||
# 0: string, 1: string
|
||||
compiler.err.illegal.char.for.encoding=\
|
||||
unmappable character for encoding {0}
|
||||
unmappable character (0x{0}) for encoding {1}
|
||||
|
||||
# 0: set of modifier, 1: set of modifier
|
||||
compiler.err.illegal.combination.of.modifiers=\
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 4767128 5048557 5048773
|
||||
* @bug 4767128 5048557 5048773 8078559
|
||||
* @summary diagnose encoding errors in Java source files
|
||||
* @author gafter
|
||||
*
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
Unmappable.java:12:18: compiler.err.illegal.char.for.encoding: ascii
|
||||
Unmappable.java:12:18: compiler.err.illegal.char.for.encoding: E4, ascii
|
||||
1 error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user