8146484: Examine sun.misc.MessageUtils
Reviewed-by: alanb, mchung, sherman
This commit is contained in:
parent
41477d597a
commit
0c7d3be7a8
@ -216,6 +216,7 @@ SUNWprivate_1.1 {
|
|||||||
Java_java_lang_SecurityManager_getClassContext;
|
Java_java_lang_SecurityManager_getClassContext;
|
||||||
Java_java_lang_Shutdown_halt0;
|
Java_java_lang_Shutdown_halt0;
|
||||||
Java_java_lang_String_intern;
|
Java_java_lang_String_intern;
|
||||||
|
Java_java_lang_StringCoding_err;
|
||||||
Java_java_lang_StringUTF16_isBigEndian;
|
Java_java_lang_StringUTF16_isBigEndian;
|
||||||
Java_java_lang_System_identityHashCode;
|
Java_java_lang_System_identityHashCode;
|
||||||
Java_java_lang_System_initProperties;
|
Java_java_lang_System_initProperties;
|
||||||
@ -243,8 +244,6 @@ SUNWprivate_1.1 {
|
|||||||
Java_java_util_TimeZone_getSystemTimeZoneID;
|
Java_java_util_TimeZone_getSystemTimeZoneID;
|
||||||
Java_java_util_TimeZone_getSystemGMTOffsetID;
|
Java_java_util_TimeZone_getSystemGMTOffsetID;
|
||||||
Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8;
|
Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8;
|
||||||
Java_sun_misc_MessageUtils_toStderr;
|
|
||||||
Java_sun_misc_MessageUtils_toStdout;
|
|
||||||
Java_sun_misc_NativeSignalHandler_handle0;
|
Java_sun_misc_NativeSignalHandler_handle0;
|
||||||
Java_sun_misc_Signal_findSignal;
|
Java_sun_misc_Signal_findSignal;
|
||||||
Java_sun_misc_Signal_handle0;
|
Java_sun_misc_Signal_handle0;
|
||||||
|
@ -35,8 +35,6 @@ import java.util.Hashtable;
|
|||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import sun.misc.MessageUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A parser for DTDs. This parser roughly corresponds to the
|
* A parser for DTDs. This parser roughly corresponds to the
|
||||||
* rules specified in "The SGML Handbook" by Charles F. Goldfarb.
|
* rules specified in "The SGML Handbook" by Charles F. Goldfarb.
|
||||||
|
@ -39,7 +39,6 @@ import java.nio.charset.IllegalCharsetNameException;
|
|||||||
import java.nio.charset.UnsupportedCharsetException;
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||||
import sun.misc.MessageUtils;
|
|
||||||
import sun.nio.cs.HistoricallyNamedCharset;
|
import sun.nio.cs.HistoricallyNamedCharset;
|
||||||
import sun.nio.cs.ArrayDecoder;
|
import sun.nio.cs.ArrayDecoder;
|
||||||
import sun.nio.cs.ArrayEncoder;
|
import sun.nio.cs.ArrayEncoder;
|
||||||
@ -106,11 +105,11 @@ class StringCoding {
|
|||||||
|
|
||||||
private static void warnUnsupportedCharset(String csn) {
|
private static void warnUnsupportedCharset(String csn) {
|
||||||
if (warnUnsupportedCharset) {
|
if (warnUnsupportedCharset) {
|
||||||
// Use sun.misc.MessageUtils rather than the Logging API or
|
// Use err(String) rather than the Logging API or System.err
|
||||||
// System.err since this method may be called during VM
|
// since this method may be called during VM initialization
|
||||||
// initialization before either is available.
|
// before either is available.
|
||||||
MessageUtils.err("WARNING: Default charset " + csn +
|
err("WARNING: Default charset " + csn +
|
||||||
" not supported, using ISO-8859-1 instead");
|
" not supported, using ISO-8859-1 instead\n");
|
||||||
warnUnsupportedCharset = false;
|
warnUnsupportedCharset = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,10 +340,9 @@ class StringCoding {
|
|||||||
try {
|
try {
|
||||||
return decode("ISO-8859-1", ba, off, len);
|
return decode("ISO-8859-1", ba, off, len);
|
||||||
} catch (UnsupportedEncodingException x) {
|
} catch (UnsupportedEncodingException x) {
|
||||||
// If this code is hit during VM initialization, MessageUtils is
|
// 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.
|
// the only way we will be able to get any kind of error message.
|
||||||
MessageUtils.err("ISO-8859-1 charset not available: "
|
err("ISO-8859-1 charset not available: " + x.toString() + "\n");
|
||||||
+ x.toString());
|
|
||||||
// If we can not find ISO-8859-1 (a required encoding) then things
|
// If we can not find ISO-8859-1 (a required encoding) then things
|
||||||
// are seriously wrong with the installation.
|
// are seriously wrong with the installation.
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@ -653,14 +651,20 @@ class StringCoding {
|
|||||||
try {
|
try {
|
||||||
return encode("ISO-8859-1", coder, val);
|
return encode("ISO-8859-1", coder, val);
|
||||||
} catch (UnsupportedEncodingException x) {
|
} catch (UnsupportedEncodingException x) {
|
||||||
// If this code is hit during VM initialization, MessageUtils is
|
// 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.
|
// the only way we will be able to get any kind of error message.
|
||||||
MessageUtils.err("ISO-8859-1 charset not available: "
|
err("ISO-8859-1 charset not available: " + x.toString() + "\n");
|
||||||
+ x.toString());
|
|
||||||
// If we can not find ISO-8859-1 (a required encoding) then things
|
// If we can not find ISO-8859-1 (a required encoding) then things
|
||||||
// are seriously wrong with the installation.
|
// are seriously wrong with the installation.
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
return null;
|
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);
|
||||||
}
|
}
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1995, 2000, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.misc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MessageUtils: miscellaneous utilities for handling error and status
|
|
||||||
* properties and messages.
|
|
||||||
*
|
|
||||||
* @author Herb Jellinek
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class MessageUtils {
|
|
||||||
// can instantiate it for to allow less verbose use - via instance
|
|
||||||
// instead of classname
|
|
||||||
|
|
||||||
public MessageUtils() { }
|
|
||||||
|
|
||||||
public static String subst(String patt, String arg) {
|
|
||||||
String args[] = { arg };
|
|
||||||
return subst(patt, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String subst(String patt, String arg1, String arg2) {
|
|
||||||
String args[] = { arg1, arg2 };
|
|
||||||
return subst(patt, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String subst(String patt, String arg1, String arg2,
|
|
||||||
String arg3) {
|
|
||||||
String args[] = { arg1, arg2, arg3 };
|
|
||||||
return subst(patt, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String subst(String patt, String args[]) {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
int len = patt.length();
|
|
||||||
for (int i = 0; i >= 0 && i < len; i++) {
|
|
||||||
char ch = patt.charAt(i);
|
|
||||||
if (ch == '%') {
|
|
||||||
if (i != len) {
|
|
||||||
int index = Character.digit(patt.charAt(i + 1), 10);
|
|
||||||
if (index == -1) {
|
|
||||||
result.append(patt.charAt(i + 1));
|
|
||||||
i++;
|
|
||||||
} else if (index < args.length) {
|
|
||||||
result.append(args[index]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.append(ch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String substProp(String propName, String arg) {
|
|
||||||
return subst(System.getProperty(propName), arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String substProp(String propName, String arg1, String arg2) {
|
|
||||||
return subst(System.getProperty(propName), arg1, arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String substProp(String propName, String arg1, String arg2,
|
|
||||||
String arg3) {
|
|
||||||
return subst(System.getProperty(propName), arg1, arg2, arg3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a message directly to stderr, bypassing all the
|
|
||||||
* character conversion methods.
|
|
||||||
* @param msg message to print
|
|
||||||
*/
|
|
||||||
public static native void toStderr(String msg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a message directly to stdout, bypassing all the
|
|
||||||
* character conversion methods.
|
|
||||||
* @param msg message to print
|
|
||||||
*/
|
|
||||||
public static native void toStdout(String msg);
|
|
||||||
|
|
||||||
|
|
||||||
// Short forms of the above
|
|
||||||
|
|
||||||
public static void err(String s) {
|
|
||||||
toStderr(s + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void out(String s) {
|
|
||||||
toStdout(s + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print a stack trace to stderr
|
|
||||||
//
|
|
||||||
public static void where() {
|
|
||||||
Throwable t = new Throwable();
|
|
||||||
StackTraceElement[] es = t.getStackTrace();
|
|
||||||
for (int i = 1; i < es.length; i++)
|
|
||||||
toStderr("\t" + es[i].toString() + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -26,11 +26,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <jni_util.h>
|
#include <jni_util.h>
|
||||||
#include <jlong.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <jvm.h>
|
#include <jvm.h>
|
||||||
|
|
||||||
#include "sun_misc_MessageUtils.h"
|
#include "java_lang_StringCoding.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
printToFile(JNIEnv *env, jstring s, FILE *file)
|
printToFile(JNIEnv *env, jstring s, FILE *file)
|
||||||
@ -41,8 +40,8 @@ printToFile(JNIEnv *env, jstring s, FILE *file)
|
|||||||
const jchar *sAsArray;
|
const jchar *sAsArray;
|
||||||
|
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
s = (*env)->NewStringUTF(env, "null");
|
JNU_ThrowNullPointerException(env, NULL);
|
||||||
if (s == NULL) return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sAsArray = (*env)->GetStringChars(env, s, NULL);
|
sAsArray = (*env)->GetStringChars(env, s, NULL);
|
||||||
@ -70,13 +69,7 @@ printToFile(JNIEnv *env, jstring s, FILE *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_sun_misc_MessageUtils_toStderr(JNIEnv *env, jclass cls, jstring s)
|
Java_java_lang_StringCoding_err(JNIEnv *env, jclass cls, jstring s)
|
||||||
{
|
{
|
||||||
printToFile(env, s, stderr);
|
printToFile(env, s, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_sun_misc_MessageUtils_toStdout(JNIEnv *env, jclass cls, jstring s)
|
|
||||||
{
|
|
||||||
printToFile(env, s, stdout);
|
|
||||||
}
|
|
@ -35,8 +35,6 @@ import java.util.Vector;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import sun.misc.MessageUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple DTD-driven HTML parser. The parser reads an
|
* A simple DTD-driven HTML parser. The parser reads an
|
||||||
* HTML file from an InputStream and calls various methods
|
* HTML file from an InputStream and calls various methods
|
||||||
|
@ -44,7 +44,6 @@ import sun.awt.AppContext;
|
|||||||
import sun.awt.EmbeddedFrame;
|
import sun.awt.EmbeddedFrame;
|
||||||
import sun.awt.SunToolkit;
|
import sun.awt.SunToolkit;
|
||||||
import sun.misc.ManagedLocalsThread;
|
import sun.misc.ManagedLocalsThread;
|
||||||
import sun.misc.MessageUtils;
|
|
||||||
import sun.misc.PerformanceLogger;
|
import sun.misc.PerformanceLogger;
|
||||||
import sun.security.util.SecurityConstants;
|
import sun.security.util.SecurityConstants;
|
||||||
|
|
||||||
@ -118,8 +117,6 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
|
|||||||
*/
|
*/
|
||||||
Dimension currentAppletSize = new Dimension(10, 10);
|
Dimension currentAppletSize = new Dimension(10, 10);
|
||||||
|
|
||||||
MessageUtils mu = new MessageUtils();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The thread to use during applet loading
|
* The thread to use during applet loading
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user