8344565: SM cleanup in jdk/internal and java/lang package private classes

Reviewed-by: alanb, mchung
This commit is contained in:
Roger Riggs 2024-11-26 17:12:17 +00:00
parent d8a23373c6
commit f1b5a6e66e
4 changed files with 18 additions and 43 deletions

View File

@ -28,12 +28,9 @@ package java.lang;
import jdk.internal.util.ArraysSupport;
import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.util.Arrays;
import java.util.zip.InflaterInputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
class CharacterName {
@ -49,12 +46,9 @@ class CharacterName {
private final int[] hsIndices; // chain heads, hash indices into "cps"
private CharacterName() {
try (@SuppressWarnings("removal") DataInputStream dis = new DataInputStream(new InflaterInputStream(
AccessController.doPrivileged(new PrivilegedAction<>() {
public InputStream run() {
return getClass().getResourceAsStream("uniName.dat");
}
})))) {
try (DataInputStream dis = new DataInputStream(
new InflaterInputStream(CharacterName.class
.getResourceAsStream("uniName.dat")))) {
int total = dis.readInt();
int bkNum = dis.readInt();

View File

@ -25,8 +25,6 @@
package java.lang.ref;
import java.security.PrivilegedAction;
import java.security.AccessController;
import jdk.internal.access.JavaLangAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.VM;
@ -116,24 +114,18 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
* The advantage of creating a fresh thread, however, is that it insulates
* invokers of that method from a stalled or deadlocked finalizer thread.
*/
@SuppressWarnings("removal")
private static void forkSecondaryFinalizer(final Runnable proc) {
AccessController.doPrivileged(
new PrivilegedAction<>() {
public Void run() {
ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg;
tgn != null;
tg = tgn, tgn = tg.getParent());
Thread sft = new Thread(tg, proc, "Secondary finalizer", 0, false);
sft.start();
try {
sft.join();
} catch (InterruptedException x) {
Thread.currentThread().interrupt();
}
return null;
}});
ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg;
tgn != null;
tg = tgn, tgn = tg.getParent());
Thread sft = new Thread(tg, proc, "Secondary finalizer", 0, false);
sft.start();
try {
sft.join();
} catch (InterruptedException x) {
Thread.currentThread().interrupt();
}
}
/* Called by Runtime.runFinalization() */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2024, 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
@ -39,8 +39,6 @@ import java.io.UncheckedIOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.security.AccessController;
import java.security.PrivilegedAction;
import jdk.internal.icu.util.VersionInfo;
@ -81,11 +79,7 @@ public final class ICUBinary {
public static ByteBuffer getRequiredData(String itemPath) {
final Class<ICUBinary> root = ICUBinary.class;
try (@SuppressWarnings("removal") InputStream is = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
public InputStream run() {
return root.getResourceAsStream(itemPath);
}
})) {
try (InputStream is = root.getResourceAsStream(itemPath)) {
// is.available() may return 0, or 1, or the total number of bytes in the stream,
// or some other number.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, 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
@ -30,8 +30,6 @@ import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.nio.channels.FileChannel.MapMode;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
/**
* JDK-specific map modes implemented in java.base.
@ -41,10 +39,7 @@ public class ExtendedMapMode {
static final MethodHandle MAP_MODE_CONSTRUCTOR;
static {
try {
PrivilegedExceptionAction<Lookup> pae = () ->
MethodHandles.privateLookupIn(MapMode.class, MethodHandles.lookup());
@SuppressWarnings("removal")
Lookup lookup = AccessController.doPrivileged(pae);
Lookup lookup = MethodHandles.privateLookupIn(MapMode.class, MethodHandles.lookup());
var methodType = MethodType.methodType(void.class, String.class);
MAP_MODE_CONSTRUCTOR = lookup.findConstructor(MapMode.class, methodType);
} catch (Exception e) {