src/java.base/share/classes/java/lang/StringCoding.java
Print this page
*** 37,47 ****
import java.nio.charset.CodingErrorAction;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Arrays;
import jdk.internal.HotSpotIntrinsicCandidate;
- import sun.misc.MessageUtils;
import sun.nio.cs.HistoricallyNamedCharset;
import sun.nio.cs.ArrayDecoder;
import sun.nio.cs.ArrayEncoder;
import static java.lang.String.LATIN1;
--- 37,46 ----
*** 104,118 ****
return null;
}
private static void warnUnsupportedCharset(String csn) {
if (warnUnsupportedCharset) {
! // Use sun.misc.MessageUtils rather than the Logging API or
! // System.err since this method may be called during VM
! // initialization before either is available.
! MessageUtils.err("WARNING: Default charset " + csn +
! " not supported, using ISO-8859-1 instead");
warnUnsupportedCharset = false;
}
}
static class Result {
--- 103,117 ----
return null;
}
private static void warnUnsupportedCharset(String csn) {
if (warnUnsupportedCharset) {
! // Use err(String) rather than the Logging API or System.err
! // since this method may be called during VM initialization
! // before either is available.
! err("WARNING: Default charset " + csn +
! " not supported, using ISO-8859-1 instead\n");
warnUnsupportedCharset = false;
}
}
static class Result {
*** 339,352 ****
warnUnsupportedCharset(csn);
}
try {
return decode("ISO-8859-1", ba, off, len);
} catch (UnsupportedEncodingException x) {
! // If this code is hit during VM initialization, MessageUtils is
// the only way we will be able to get any kind of error message.
! MessageUtils.err("ISO-8859-1 charset not available: "
! + x.toString());
// If we can not find ISO-8859-1 (a required encoding) then things
// are seriously wrong with the installation.
System.exit(1);
return null;
}
--- 338,350 ----
warnUnsupportedCharset(csn);
}
try {
return decode("ISO-8859-1", ba, off, len);
} catch (UnsupportedEncodingException x) {
! // If this code is hit during VM initialization, err(String) is
// the only way we will be able to get any kind of error message.
! err("ISO-8859-1 charset not available: " + x.toString() + "\n");
// If we can not find ISO-8859-1 (a required encoding) then things
// are seriously wrong with the installation.
System.exit(1);
return null;
}
*** 651,666 ****
warnUnsupportedCharset(csn);
}
try {
return encode("ISO-8859-1", coder, val);
} catch (UnsupportedEncodingException x) {
! // If this code is hit during VM initialization, MessageUtils is
// the only way we will be able to get any kind of error message.
! MessageUtils.err("ISO-8859-1 charset not available: "
! + x.toString());
// If we can not find ISO-8859-1 (a required encoding) then things
// are seriously wrong with the installation.
System.exit(1);
return null;
}
}
}
--- 649,670 ----
warnUnsupportedCharset(csn);
}
try {
return encode("ISO-8859-1", coder, val);
} catch (UnsupportedEncodingException x) {
! // If this code is hit during VM initialization, err(String) is
// the only way we will be able to get any kind of error message.
! err("ISO-8859-1 charset not available: " + x.toString() + "\n");
// If we can not find ISO-8859-1 (a required encoding) then things
// are seriously wrong with the installation.
System.exit(1);
return null;
}
}
+
+ /**
+ * Print a message directly to stderr, bypassing all character conversion
+ * methods.
+ * @param msg message to print
+ */
+ private static native void err(String msg);
}