mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02: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
4 changed files with 13 additions and 8 deletions
|
@ -380,13 +380,17 @@ public abstract class BaseFileManager implements JavaFileManager {
|
||||||
dest = CharBuffer.allocate(newCapacity).put(dest);
|
dest = CharBuffer.allocate(newCapacity).put(dest);
|
||||||
} else if (result.isMalformed() || result.isUnmappable()) {
|
} else if (result.isMalformed() || result.isUnmappable()) {
|
||||||
// bad character in input
|
// bad character in input
|
||||||
|
StringBuilder unmappable = new StringBuilder();
|
||||||
|
int len = result.length();
|
||||||
|
|
||||||
log.error(new SimpleDiagnosticPosition(dest.limit()),
|
for (int i = 0; i < len; i++) {
|
||||||
"illegal.char.for.encoding",
|
unmappable.append(String.format("%02X", inbuf.get()));
|
||||||
charset == null ? encodingName : charset.name());
|
}
|
||||||
|
|
||||||
// skip past the coding error
|
String charsetName = charset == null ? encodingName : charset.name();
|
||||||
inbuf.position(inbuf.position() + result.length());
|
|
||||||
|
log.error(dest.limit(),
|
||||||
|
Errors.IllegalCharForEncoding(unmappable.toString(), charsetName));
|
||||||
|
|
||||||
// undo the flip() to prepare the output buffer
|
// undo the flip() to prepare the output buffer
|
||||||
// for more translation
|
// for more translation
|
||||||
|
|
|
@ -522,8 +522,9 @@ compiler.err.icls.cant.have.static.decl=\
|
||||||
compiler.err.illegal.char=\
|
compiler.err.illegal.char=\
|
||||||
illegal character: ''{0}''
|
illegal character: ''{0}''
|
||||||
|
|
||||||
|
# 0: string, 1: string
|
||||||
compiler.err.illegal.char.for.encoding=\
|
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
|
# 0: set of modifier, 1: set of modifier
|
||||||
compiler.err.illegal.combination.of.modifiers=\
|
compiler.err.illegal.combination.of.modifiers=\
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 4767128 5048557 5048773
|
* @bug 4767128 5048557 5048773 8078559
|
||||||
* @summary diagnose encoding errors in Java source files
|
* @summary diagnose encoding errors in Java source files
|
||||||
* @author gafter
|
* @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
|
1 error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue