8165889: Remove jdk.test.lib.unsafe.UnsafeHelper

Remove use of setAccessible() to get Unsafe.

Reviewed-by: shade, lfoltan
This commit is contained in:
George Triantafillou 2016-09-14 08:17:50 -04:00
parent 08cc021f41
commit d624da8942
51 changed files with 56 additions and 151 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2016, 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
@ -38,15 +38,11 @@ import jdk.internal.misc.Unsafe;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class Test6968348 { public class Test6968348 {
static Unsafe unsafe; static Unsafe unsafe = Unsafe.getUnsafe();
static final long[] buffer = new long[4096]; static final long[] buffer = new long[4096];
static int array_long_base_offset; static int array_long_base_offset;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Class c = Test6968348.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
Field f = c.getDeclaredField("theUnsafe");
f.setAccessible(true);
unsafe = (Unsafe)f.get(c);
array_long_base_offset = unsafe.arrayBaseOffset(long[].class); array_long_base_offset = unsafe.arrayBaseOffset(long[].class);
for (int n = 0; n < 100000; n++) { for (int n = 0; n < 100000; n++) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2016, 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
@ -50,14 +50,10 @@ public class TestIntUnsafeCAS {
private static final int ALIGN_OFF = 8; private static final int ALIGN_OFF = 8;
private static final int UNALIGN_OFF = 5; private static final int UNALIGN_OFF = 5;
private static final Unsafe unsafe; private static final Unsafe unsafe = Unsafe.getUnsafe();
private static final int BASE; private static final int BASE;
static { static {
try { try {
Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
Field f = c.getDeclaredField("theUnsafe");
f.setAccessible(true);
unsafe = (Unsafe)f.get(c);
BASE = unsafe.arrayBaseOffset(int[].class); BASE = unsafe.arrayBaseOffset(int[].class);
} catch (Exception e) { } catch (Exception e) {
InternalError err = new InternalError(); InternalError err = new InternalError();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2016, 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
@ -50,14 +50,10 @@ public class TestIntUnsafeOrdered {
private static final int ALIGN_OFF = 8; private static final int ALIGN_OFF = 8;
private static final int UNALIGN_OFF = 5; private static final int UNALIGN_OFF = 5;
private static final Unsafe unsafe; private static final Unsafe unsafe = Unsafe.getUnsafe();
private static final int BASE; private static final int BASE;
static { static {
try { try {
Class<?> c = Unsafe.class;
Field f = c.getDeclaredField("theUnsafe");
f.setAccessible(true);
unsafe = (Unsafe) f.get(c);
BASE = unsafe.arrayBaseOffset(int[].class); BASE = unsafe.arrayBaseOffset(int[].class);
} catch (Exception e) { } catch (Exception e) {
InternalError err = new InternalError(); InternalError err = new InternalError();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2016, 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
@ -50,14 +50,10 @@ public class TestIntUnsafeVolatile {
private static final int ALIGN_OFF = 8; private static final int ALIGN_OFF = 8;
private static final int UNALIGN_OFF = 5; private static final int UNALIGN_OFF = 5;
private static final Unsafe unsafe; private static final Unsafe unsafe = Unsafe.getUnsafe();
private static final int BASE; private static final int BASE;
static { static {
try { try {
Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe");
Field f = c.getDeclaredField("theUnsafe");
f.setAccessible(true);
unsafe = (Unsafe)f.get(c);
BASE = unsafe.arrayBaseOffset(int[].class); BASE = unsafe.arrayBaseOffset(int[].class);
} catch (Exception e) { } catch (Exception e) {
InternalError err = new InternalError(); InternalError err = new InternalError();

View file

@ -27,7 +27,6 @@
* @bug 8142386 * @bug 8142386
* @summary Unsafe access to an array is wrongly marked as mismatched * @summary Unsafe access to an array is wrongly marked as mismatched
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib
* *
* @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:-TieredCompilation * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:-TieredCompilation
* compiler.intrinsics.unsafe.TestUnsafeMismatchedArrayFieldAccess * compiler.intrinsics.unsafe.TestUnsafeMismatchedArrayFieldAccess
@ -36,11 +35,10 @@
package compiler.intrinsics.unsafe; package compiler.intrinsics.unsafe;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.unsafe.UnsafeHelper;
public class TestUnsafeMismatchedArrayFieldAccess { public class TestUnsafeMismatchedArrayFieldAccess {
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
static { static {
try { try {

View file

@ -45,7 +45,6 @@ package compiler.jvmci.compilerToVM;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject;
@ -114,7 +113,7 @@ public class GetResolvedJavaMethodTest {
abstract HotSpotResolvedJavaMethod getResolvedJavaMethod(); abstract HotSpotResolvedJavaMethod getResolvedJavaMethod();
} }
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final Field METASPACE_METHOD_FIELD; private static final Field METASPACE_METHOD_FIELD;
private static final Class<?> TEST_CLASS = GetResolvedJavaMethodTest.class; private static final Class<?> TEST_CLASS = GetResolvedJavaMethodTest.class;

View file

@ -53,7 +53,6 @@ package compiler.jvmci.compilerToVM;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
@ -154,7 +153,7 @@ public class GetResolvedJavaTypeTest {
abstract HotSpotResolvedObjectType getResolvedJavaType(); abstract HotSpotResolvedObjectType getResolvedJavaType();
} }
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class; private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class;
/* a compressed parameter for tested method is set to false because /* a compressed parameter for tested method is set to false because

View file

@ -53,7 +53,6 @@ import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.internal.org.objectweb.asm.Opcodes; import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
import jdk.vm.ci.meta.ConstantPool; import jdk.vm.ci.meta.ConstantPool;
@ -69,7 +68,7 @@ import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CON
*/ */
public class ResolveFieldInPoolTest { public class ResolveFieldInPoolTest {
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Map<ConstantTypes, Validator> typeTests = new HashMap<>(); Map<ConstantTypes, Validator> typeTests = new HashMap<>();

View file

@ -52,7 +52,6 @@ import compiler.jvmci.common.testcases.SingleSubclassedClass;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.Utils; import jdk.test.lib.Utils;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
@ -61,7 +60,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
public class ResolveMethodTest { public class ResolveMethodTest {
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
public static void main(String args[]) { public static void main(String args[]) {
ResolveMethodTest test = new ResolveMethodTest(); ResolveMethodTest test = new ResolveMethodTest();

View file

@ -34,7 +34,6 @@
package compiler.loopopts.superword; package compiler.loopopts.superword;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.unsafe.UnsafeHelper;
public class TestVectorizationWithInvariant { public class TestVectorizationWithInvariant {
@ -43,7 +42,7 @@ public class TestVectorizationWithInvariant {
private static final long CHAR_ARRAY_OFFSET; private static final long CHAR_ARRAY_OFFSET;
static { static {
unsafe = UnsafeHelper.getUnsafe(); unsafe = Unsafe.getUnsafe();
BYTE_ARRAY_OFFSET = unsafe.arrayBaseOffset(byte[].class); BYTE_ARRAY_OFFSET = unsafe.arrayBaseOffset(byte[].class);
CHAR_ARRAY_OFFSET = unsafe.arrayBaseOffset(char[].class); CHAR_ARRAY_OFFSET = unsafe.arrayBaseOffset(char[].class);
} }

View file

@ -49,7 +49,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.CommandLineOptionTest;
import jdk.test.lib.cli.predicate.AndPredicate; import jdk.test.lib.cli.predicate.AndPredicate;
@ -125,7 +124,7 @@ public class TestRTMAbortRatio extends CommandLineOptionTest {
public static class Test implements CompilableTest { public static class Test implements CompilableTest {
private static final int TOTAL_ITERATIONS = 10000; private static final int TOTAL_ITERATIONS = 10000;
private static final int WARMUP_ITERATIONS = 1000; private static final int WARMUP_ITERATIONS = 1000;
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private final Object monitor = new Object(); private final Object monitor = new Object();
// Following field have to be static in order to avoid escape analysis. // Following field have to be static in order to avoid escape analysis.
@SuppressWarnings("UnsuedDeclaration") @SuppressWarnings("UnsuedDeclaration")

View file

@ -51,7 +51,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.CommandLineOptionTest;
import jdk.test.lib.cli.predicate.AndPredicate; import jdk.test.lib.cli.predicate.AndPredicate;
@ -158,7 +157,7 @@ public class TestRTMAfterNonRTMDeopt extends CommandLineOptionTest {
private static int field = 0; private static int field = 0;
private static final int ITERATIONS = 10000; private static final int ITERATIONS = 10000;
private static final int RANGE_CHECK_AT = ITERATIONS / 2; private static final int RANGE_CHECK_AT = ITERATIONS / 2;
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private final Object monitor = new Object(); private final Object monitor = new Object();
@Override @Override

View file

@ -48,7 +48,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.CommandLineOptionTest;
import jdk.test.lib.cli.predicate.AndPredicate; import jdk.test.lib.cli.predicate.AndPredicate;
@ -133,7 +132,7 @@ public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest {
} }
public static class Test implements CompilableTest { public static class Test implements CompilableTest {
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private final Object monitor = new Object(); private final Object monitor = new Object();
@Override @Override

View file

@ -49,7 +49,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.CommandLineOptionTest;
import jdk.test.lib.cli.predicate.AndPredicate; import jdk.test.lib.cli.predicate.AndPredicate;
@ -142,7 +141,7 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest {
@SuppressWarnings("UnsuedDeclaration") @SuppressWarnings("UnsuedDeclaration")
private static int field = 0; private static int field = 0;
private static final int TOTAL_ITERATIONS = 10000; private static final int TOTAL_ITERATIONS = 10000;
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private final Object monitor = new Object(); private final Object monitor = new Object();

View file

@ -49,7 +49,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts; import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.CommandLineOptionTest;
import jdk.test.lib.cli.predicate.AndPredicate; import jdk.test.lib.cli.predicate.AndPredicate;
@ -113,7 +112,7 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
public static class Test implements CompilableTest { public static class Test implements CompilableTest {
private static final long TOTAL_ITERATIONS = 10000L; private static final long TOTAL_ITERATIONS = 10000L;
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private final Object monitor = new Object(); private final Object monitor = new Object();
// Following field have to be static in order to avoid escape analysis. // Following field have to be static in order to avoid escape analysis.
@SuppressWarnings("UnsuedDeclaration") @SuppressWarnings("UnsuedDeclaration")

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2016, 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
@ -25,7 +25,6 @@
package compiler.testlibrary.rtm; package compiler.testlibrary.rtm;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.unsafe.UnsafeHelper;
/** /**
* Current RTM locking implementation force transaction abort * Current RTM locking implementation force transaction abort
@ -35,7 +34,7 @@ class XAbortProvoker extends AbortProvoker {
// Following field have to be static in order to avoid escape analysis. // Following field have to be static in order to avoid escape analysis.
@SuppressWarnings("UnsuedDeclaration") @SuppressWarnings("UnsuedDeclaration")
private static int field = 0; private static int field = 0;
private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
public XAbortProvoker() { public XAbortProvoker() {
this(new Object()); this(new Object());

View file

@ -35,7 +35,6 @@ package compiler.unsafe;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.Utils; import jdk.test.lib.Utils;
import jdk.test.lib.unsafe.UnsafeHelper;
import java.util.Random; import java.util.Random;
@ -82,7 +81,7 @@ public class UnsafeRaw {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
final int array_size = 128; final int array_size = 128;
final int element_size = 4; final int element_size = 4;
final int magic = 0x12345678; final int magic = 0x12345678;

View file

@ -37,7 +37,6 @@ import java.util.Collections;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Utils; import jdk.test.lib.Utils;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
public class TestMaxMinHeapFreeRatioFlags { public class TestMaxMinHeapFreeRatioFlags {
@ -134,7 +133,7 @@ public class TestMaxMinHeapFreeRatioFlags {
*/ */
public static class RatioVerifier { public static class RatioVerifier {
private static final Unsafe unsafe = UnsafeHelper.getUnsafe(); private static final Unsafe unsafe = Unsafe.getUnsafe();
// Size of byte array that will be allocated // Size of byte array that will be allocated
public static final int CHUNK_SIZE = 1024; public static final int CHUNK_SIZE = 1024;

View file

@ -46,7 +46,6 @@ import jdk.internal.misc.Unsafe;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Utils; import jdk.test.lib.Utils;
import jdk.test.lib.unsafe.UnsafeHelper;
import sun.hotspot.WhiteBox; import sun.hotspot.WhiteBox;
/* In order to test that TargetSurvivorRatio affects survivor space occupancy /* In order to test that TargetSurvivorRatio affects survivor space occupancy
@ -249,7 +248,7 @@ public class TestTargetSurvivorRatioFlag {
public static class TargetSurvivorRatioVerifier { public static class TargetSurvivorRatioVerifier {
static final WhiteBox wb = WhiteBox.getWhiteBox(); static final WhiteBox wb = WhiteBox.getWhiteBox();
static final Unsafe unsafe = UnsafeHelper.getUnsafe(); static final Unsafe unsafe = Unsafe.getUnsafe();
// Desired size of memory allocated at once // Desired size of memory allocated at once
public static final int CHUNK_SIZE = 1024; public static final int CHUNK_SIZE = 1024;

View file

@ -34,13 +34,12 @@
import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform; import jdk.test.lib.Platform;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
public class CreateCoredumpOnCrash { public class CreateCoredumpOnCrash {
private static class Crasher { private static class Crasher {
public static void main(String[] args) { public static void main(String[] args) {
UnsafeHelper.getUnsafe().putInt(0L, 0); Unsafe.getUnsafe().putInt(0L, 0);
} }
} }

View file

@ -35,14 +35,13 @@
import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
public class ProblematicFrameTest { public class ProblematicFrameTest {
private static class Crasher { private static class Crasher {
public static void main(String[] args) { public static void main(String[] args) {
UnsafeHelper.getUnsafe().getInt(0); Unsafe.getUnsafe().getInt(0);
} }
} }

View file

@ -30,12 +30,11 @@
* @run main AllocateInstance * @run main AllocateInstance
*/ */
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class AllocateInstance { public class AllocateInstance {
static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); static final Unsafe UNSAFE = Unsafe.getUnsafe();
class TestClass { class TestClass {
public boolean calledConstructor = false; public boolean calledConstructor = false;

View file

@ -31,13 +31,12 @@
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m AllocateMemory * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m AllocateMemory
*/ */
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class AllocateMemory { public class AllocateMemory {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
// Allocate a byte, write to the location and read back the value // Allocate a byte, write to the location and read back the value
long address = unsafe.allocateMemory(1); long address = unsafe.allocateMemory(1);

View file

@ -30,14 +30,13 @@
* @run main CopyMemory * @run main CopyMemory
*/ */
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class CopyMemory { public class CopyMemory {
final static int LENGTH = 8; final static int LENGTH = 8;
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
long src = unsafe.allocateMemory(LENGTH); long src = unsafe.allocateMemory(LENGTH);
long dst = unsafe.allocateMemory(LENGTH); long dst = unsafe.allocateMemory(LENGTH);
assertNotEquals(src, 0L); assertNotEquals(src, 0L);

View file

@ -34,13 +34,12 @@
import java.security.ProtectionDomain; import java.security.ProtectionDomain;
import java.io.InputStream; import java.io.InputStream;
import jdk.test.lib.InMemoryJavaCompiler; import jdk.test.lib.InMemoryJavaCompiler;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class DefineClass { public class DefineClass {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
TestClassLoader classloader = new TestClassLoader(); TestClassLoader classloader = new TestClassLoader();
ProtectionDomain pd = new ProtectionDomain(null, null); ProtectionDomain pd = new ProtectionDomain(null, null);

View file

@ -31,14 +31,13 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import java.lang.reflect.*; import java.lang.reflect.*;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class FieldOffset { public class FieldOffset {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Field[] fields = Test.class.getDeclaredFields(); Field[] fields = Test.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {

View file

@ -30,14 +30,13 @@
* @run main GetField * @run main GetField
*/ */
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import java.lang.reflect.*; import java.lang.reflect.*;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetField { public class GetField {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
// Unsafe.INVALID_FIELD_OFFSET is a static final int field, // Unsafe.INVALID_FIELD_OFFSET is a static final int field,
// make sure getField returns the correct field // make sure getField returns the correct field
Field field = Unsafe.class.getField("INVALID_FIELD_OFFSET"); Field field = Unsafe.class.getField("INVALID_FIELD_OFFSET");

View file

@ -31,13 +31,12 @@
*/ */
import jdk.test.lib.Platform; import jdk.test.lib.Platform;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutAddress { public class GetPutAddress {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
int addressSize = unsafe.addressSize(); int addressSize = unsafe.addressSize();
// Ensure the size returned from Unsafe.addressSize is correct // Ensure the size returned from Unsafe.addressSize is correct
assertEquals(unsafe.addressSize(), Platform.is32bit() ? 4 : 8); assertEquals(unsafe.addressSize(), Platform.is32bit() ? 4 : 8);

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutBoolean { public class GetPutBoolean {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("b1"); Field field = Test.class.getField("b1");

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutByte { public class GetPutByte {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("b"); Field field = Test.class.getField("b");

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutChar { public class GetPutChar {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("c"); Field field = Test.class.getField("c");

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutDouble { public class GetPutDouble {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("d"); Field field = Test.class.getField("d");

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutFloat { public class GetPutFloat {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("f"); Field field = Test.class.getField("f");

View file

@ -30,13 +30,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutInt { public class GetPutInt {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("i"); Field field = Test.class.getField("i");

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutLong { public class GetPutLong {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("l"); Field field = Test.class.getField("l");

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutObject { public class GetPutObject {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Object o = new Object(); Object o = new Object();
Field field = Test.class.getField("o"); Field field = Test.class.getField("o");

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class GetPutShort { public class GetPutShort {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Test t = new Test(); Test t = new Test();
Field field = Test.class.getField("s"); Field field = Test.class.getField("s");

View file

@ -30,13 +30,12 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
public class GetUncompressedObject { public class GetUncompressedObject {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
// Allocate some memory and fill it with non-zero values. // Allocate some memory and fill it with non-zero values.
final int size = 32; final int size = 32;

View file

@ -35,7 +35,6 @@ import java.security.ProtectionDomain;
import java.io.InputStream; import java.io.InputStream;
import java.lang.*; import java.lang.*;
import jdk.test.lib.InMemoryJavaCompiler; import jdk.test.lib.InMemoryJavaCompiler;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
@ -50,7 +49,7 @@ public class NestedUnsafe {
" } } "); " } } ");
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
Class klass = unsafe.defineAnonymousClass(NestedUnsafe.class, klassbuf, new Object[0]); Class klass = unsafe.defineAnonymousClass(NestedUnsafe.class, klassbuf, new Object[0]);
unsafe.ensureClassInitialized(klass); unsafe.ensureClassInitialized(klass);

View file

@ -31,13 +31,12 @@
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class PageSize { public class PageSize {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
int pageSize = unsafe.pageSize(); int pageSize = unsafe.pageSize();
for (int n = 1; n != 0; n <<= 1) { for (int n = 1; n != 0; n <<= 1) {

View file

@ -39,16 +39,7 @@ import jdk.internal.misc.Unsafe;
public class PrimitiveHostClass { public class PrimitiveHostClass {
static final Unsafe U; static final Unsafe U = Unsafe.getUnsafe();
static {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
U = (Unsafe) theUnsafe.get(null);
} catch (Exception e) {
throw new AssertionError(e);
}
}
public static void testVMAnonymousClass(Class<?> hostClass) { public static void testVMAnonymousClass(Class<?> hostClass) {

View file

@ -33,7 +33,6 @@
import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform; import jdk.test.lib.Platform;
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
@ -60,7 +59,7 @@ public class RangeCheck {
public static class DummyClassWithMainRangeCheck { public static class DummyClassWithMainRangeCheck {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
unsafe.getObject(new DummyClassWithMainRangeCheck(), Short.MAX_VALUE); unsafe.getObject(new DummyClassWithMainRangeCheck(), Short.MAX_VALUE);
} }
} }

View file

@ -31,13 +31,12 @@
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m Reallocate * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m Reallocate
*/ */
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class Reallocate { public class Reallocate {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
long address = unsafe.allocateMemory(1); long address = unsafe.allocateMemory(1);
assertNotEquals(address, 0L); assertNotEquals(address, 0L);

View file

@ -30,13 +30,12 @@
* @run main SetMemory * @run main SetMemory
*/ */
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class SetMemory { public class SetMemory {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
long address = unsafe.allocateMemory(1); long address = unsafe.allocateMemory(1);
assertNotEquals(address, 0L); assertNotEquals(address, 0L);
unsafe.setMemory(address, 1, (byte)17); unsafe.setMemory(address, 1, (byte)17);

View file

@ -30,13 +30,12 @@
* @run main ThrowException * @run main ThrowException
*/ */
import jdk.test.lib.unsafe.UnsafeHelper;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class ThrowException { public class ThrowException {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
try { try {
unsafe.throwException(new TestException()); unsafe.throwException(new TestException());
} catch (Throwable t) { } catch (Throwable t) {

View file

@ -48,20 +48,11 @@ import jdk.internal.vm.annotation.Contended;
*/ */
public class Basic { public class Basic {
private static final Unsafe U; private static final Unsafe U = Unsafe.getUnsafe();
private static int ADDRESS_SIZE; private static int ADDRESS_SIZE;
private static int HEADER_SIZE; private static int HEADER_SIZE;
static { static {
// steal Unsafe
try {
Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
unsafe.setAccessible(true);
U = (Unsafe) unsafe.get(null);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
// When running with CompressedOops on 64-bit platform, the address size // When running with CompressedOops on 64-bit platform, the address size
// reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
// Try to guess the reference field size with this naive trick. // Try to guess the reference field size with this naive trick.

View file

@ -49,20 +49,11 @@ import jdk.internal.vm.annotation.Contended;
*/ */
public class DefaultValue { public class DefaultValue {
private static final Unsafe U; private static final Unsafe U = Unsafe.getUnsafe();
private static int ADDRESS_SIZE; private static int ADDRESS_SIZE;
private static int HEADER_SIZE; private static int HEADER_SIZE;
static { static {
// steal Unsafe
try {
Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
unsafe.setAccessible(true);
U = (Unsafe) unsafe.get(null);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
// When running with CompressedOops on 64-bit platform, the address size // When running with CompressedOops on 64-bit platform, the address size
// reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
// Try to guess the reference field size with this naive trick. // Try to guess the reference field size with this naive trick.

View file

@ -49,20 +49,11 @@ import jdk.internal.vm.annotation.Contended;
*/ */
public class Inheritance1 { public class Inheritance1 {
private static final Unsafe U; private static final Unsafe U = Unsafe.getUnsafe();
private static int ADDRESS_SIZE; private static int ADDRESS_SIZE;
private static int HEADER_SIZE; private static int HEADER_SIZE;
static { static {
// steal Unsafe
try {
Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
unsafe.setAccessible(true);
U = (Unsafe) unsafe.get(null);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
// When running with CompressedOops on 64-bit platform, the address size // When running with CompressedOops on 64-bit platform, the address size
// reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
// Try to guess the reference field size with this naive trick. // Try to guess the reference field size with this naive trick.

View file

@ -39,7 +39,6 @@ import java.io.InputStream;
import java.lang.*; import java.lang.*;
import jdk.test.lib.*; import jdk.test.lib.*;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.unsafe.UnsafeHelper;
// Test that an anonymous class in package 'p' cannot define its own anonymous class // Test that an anonymous class in package 'p' cannot define its own anonymous class
@ -54,7 +53,7 @@ public class NestedUnsafe {
" } } "); " } } ");
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
// The anonymous class calls defineAnonymousClass creating a nested anonymous class. // The anonymous class calls defineAnonymousClass creating a nested anonymous class.
byte klassbuf2[] = InMemoryJavaCompiler.compile("p.TestClass2", byte klassbuf2[] = InMemoryJavaCompiler.compile("p.TestClass2",

View file

@ -39,7 +39,6 @@ import java.io.InputStream;
import java.lang.*; import java.lang.*;
import jdk.test.lib.*; import jdk.test.lib.*;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.test.lib.unsafe.UnsafeHelper;
// Test that an anonymous class that gets put in its host's package cannot define // Test that an anonymous class that gets put in its host's package cannot define
@ -54,7 +53,7 @@ public class NestedUnsafe2 {
" } } "); " } } ");
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Unsafe unsafe = UnsafeHelper.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
// The anonymous class calls defineAnonymousClass creating a nested anonymous class. // The anonymous class calls defineAnonymousClass creating a nested anonymous class.
byte klassbuf2[] = InMemoryJavaCompiler.compile("TestClass2", byte klassbuf2[] = InMemoryJavaCompiler.compile("TestClass2",

View file

@ -39,7 +39,7 @@ import java.util.regex.Pattern;
* Concrete subclasses should implement method {@link #process()}. * Concrete subclasses should implement method {@link #process()}.
*/ */
public abstract class PathHandler { public abstract class PathHandler {
private static final Unsafe UNSAFE = jdk.test.lib.unsafe.UnsafeHelper.getUnsafe(); private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private static final AtomicLong CLASS_COUNT = new AtomicLong(0L); private static final AtomicLong CLASS_COUNT = new AtomicLong(0L);
private static volatile boolean CLASSES_LIMIT_REACHED = false; private static volatile boolean CLASSES_LIMIT_REACHED = false;
private static final Pattern JAR_IN_DIR_PATTERN private static final Pattern JAR_IN_DIR_PATTERN