Skip to content

Commit 18cc5c9

Browse files
committed
Move Thread.completeInitialization() into J9VMInternals
Refactoring Thread to simplify RI java.lang.Thread adoption. Signed-off-by: Jason Feng <[email protected]>
1 parent 57d463d commit 18cc5c9

File tree

1 file changed

+4
-37
lines changed

1 file changed

+4
-37
lines changed

src/java.base/share/classes/java/lang/Thread.java

+4-37
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
package java.lang;
3333

3434
import java.lang.reflect.Method;
35-
import java.io.FileDescriptor;
36-
import java.nio.charset.Charset;
3735
import java.security.AccessController;
3836
import java.security.AccessControlContext;
3937
import java.security.PrivilegedAction;
@@ -1556,6 +1554,10 @@ public void setContextClassLoader(ClassLoader cl) {
15561554
contextClassLoader = cl;
15571555
}
15581556

1557+
void internalSetContextClassLoader(ClassLoader cl) {
1558+
contextClassLoader = cl;
1559+
}
1560+
15591561
/**
15601562
* Returns {@code true} if and only if the current thread holds the
15611563
* monitor lock on the specified object.
@@ -2068,41 +2070,6 @@ private void dispatchUncaughtException(Throwable e) {
20682070
// Used internally to compute Thread names that comply with the Java specification
20692071
private static int createCount = -1;
20702072

2071-
/*
2072-
* Called after everything else is initialized.
2073-
*/
2074-
void completeInitialization() {
2075-
// Get the java.system.class.loader
2076-
contextClassLoader = ClassLoader.getSystemClassLoader();
2077-
jdk.internal.misc.VM.initLevel(4);
2078-
System.startSNMPAgent();
2079-
2080-
/* Although file.encoding is used to set the default Charset, some Charset's are not available
2081-
* in the java.base module and so are not used at startup. There are additional Charset's in the
2082-
* jdk.charsets module, which is only loaded later. This means the default Charset may not be the
2083-
* same as file.encoding. Now that all modules and Charset's are available, check if the desired
2084-
* encodings can be used for System.err and System.out.
2085-
*/
2086-
Properties props = System.internalGetProperties();
2087-
// If the sun.stderr.encoding was already set in System, don't change the encoding
2088-
if (!System.hasSetErrEncoding()) {
2089-
Charset stderrCharset = System.getCharset(props.getProperty("sun.stderr.encoding"), true);
2090-
if (stderrCharset != null) {
2091-
System.err.flush();
2092-
System.setErr(System.createConsole(FileDescriptor.err, stderrCharset));
2093-
}
2094-
}
2095-
2096-
// If the sun.stdout.encoding was already set in System, don't change the encoding
2097-
if (!System.hasSetOutEncoding()) {
2098-
Charset stdoutCharset = System.getCharset(props.getProperty("sun.stdout.encoding"), true);
2099-
if (stdoutCharset != null) {
2100-
System.out.flush();
2101-
System.setOut(System.createConsole(FileDescriptor.out, stdoutCharset));
2102-
}
2103-
}
2104-
}
2105-
21062073
void uncaughtException(Throwable e) {
21072074
UncaughtExceptionHandler handler = getUncaughtExceptionHandler();
21082075
if (handler != null) {

0 commit comments

Comments
 (0)