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
src/java.base/share/classes

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

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

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.Arrays; import java.util.Arrays;
import java.security.AccessController;
import java.security.PrivilegedAction;
import jdk.internal.icu.util.VersionInfo; import jdk.internal.icu.util.VersionInfo;
@ -81,11 +79,7 @@ public final class ICUBinary {
public static ByteBuffer getRequiredData(String itemPath) { public static ByteBuffer getRequiredData(String itemPath) {
final Class<ICUBinary> root = ICUBinary.class; final Class<ICUBinary> root = ICUBinary.class;
try (@SuppressWarnings("removal") InputStream is = AccessController.doPrivileged(new PrivilegedAction<InputStream>() { try (InputStream is = root.getResourceAsStream(itemPath)) {
public InputStream run() {
return root.getResourceAsStream(itemPath);
}
})) {
// is.available() may return 0, or 1, or the total number of bytes in the stream, // is.available() may return 0, or 1, or the total number of bytes in the stream,
// or some other number. // or some other number.

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.MethodHandles.Lookup;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.nio.channels.FileChannel.MapMode; import java.nio.channels.FileChannel.MapMode;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
/** /**
* JDK-specific map modes implemented in java.base. * JDK-specific map modes implemented in java.base.
@ -41,10 +39,7 @@ public class ExtendedMapMode {
static final MethodHandle MAP_MODE_CONSTRUCTOR; static final MethodHandle MAP_MODE_CONSTRUCTOR;
static { static {
try { try {
PrivilegedExceptionAction<Lookup> pae = () -> Lookup lookup = MethodHandles.privateLookupIn(MapMode.class, MethodHandles.lookup());
MethodHandles.privateLookupIn(MapMode.class, MethodHandles.lookup());
@SuppressWarnings("removal")
Lookup lookup = AccessController.doPrivileged(pae);
var methodType = MethodType.methodType(void.class, String.class); var methodType = MethodType.methodType(void.class, String.class);
MAP_MODE_CONSTRUCTOR = lookup.findConstructor(MapMode.class, methodType); MAP_MODE_CONSTRUCTOR = lookup.findConstructor(MapMode.class, methodType);
} catch (Exception e) { } catch (Exception e) {