Navigation Menu

Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
8067223: [TESTBUG] Rename Whitebox API package
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, kvn
  • Loading branch information
iignatev committed Aug 2, 2021
1 parent f8fb571 commit ada58d1
Show file tree
Hide file tree
Showing 36 changed files with 1,394 additions and 72 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/prims/nativeLookup.cpp
Expand Up @@ -244,6 +244,7 @@ static JNINativeMethod lookup_special_native_methods[] = {
{ CC"Java_jdk_internal_invoke_NativeEntryPoint_registerNatives", NULL, FN_PTR(JVM_RegisterNativeEntryPointMethods) },
{ CC"Java_jdk_internal_perf_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) },
{ CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) },
{ CC"Java_jdk_test_whitebox_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) },
{ CC"Java_jdk_internal_vm_vector_VectorSupport_registerNatives", NULL, FN_PTR(JVM_RegisterVectorSupportMethods)},
#if INCLUDE_JVMCI
{ CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) },
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/wbtestmethods/parserTests.cpp
Expand Up @@ -50,7 +50,7 @@
* This method Returns a char* representation of that enum value.
*/
static const char* lookup_diagnosticArgumentEnum(const char* field_name, oop object) {
const char* enum_sig = "Lsun/hotspot/parser/DiagnosticCommand$DiagnosticArgumentType;";
const char* enum_sig = "Ljdk/test/whitebox/parser/DiagnosticCommand$DiagnosticArgumentType;";
TempNewSymbol enumSigSymbol = SymbolTable::new_symbol(enum_sig);
int offset = WhiteBox::offset_for_field(field_name, object, enumSigSymbol);
oop enumOop = object->obj_field(offset);
Expand Down
13 changes: 8 additions & 5 deletions src/hotspot/share/prims/whitebox.cpp
Expand Up @@ -2151,6 +2151,9 @@ bool WhiteBox::lookup_bool(const char* field_name, oop object) {

void WhiteBox::register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread, JNINativeMethod* method_array, int method_count) {
ResourceMark rm;
Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(wbclass));
const char* klass_name = klass->external_name();

ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI

// one by one registration natives for exception catching
Expand All @@ -2166,13 +2169,13 @@ void WhiteBox::register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread,
if (env->IsInstanceOf(throwable_obj, no_such_method_error_klass)) {
// NoSuchMethodError is thrown when a method can't be found or a method is not native.
// Ignoring the exception since it is not preventing use of other WhiteBox methods.
tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s",
method_array[i].name, method_array[i].signature);
tty->print_cr("Warning: 'NoSuchMethodError' on register of %s::%s%s",
klass_name, method_array[i].name, method_array[i].signature);
}
} else {
// Registration failed unexpectedly.
tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered",
method_array[i].name, method_array[i].signature);
tty->print_cr("Warning: unexpected error on register of %s::%s%s. All methods will be unregistered",
klass_name, method_array[i].name, method_array[i].signature);
env->UnregisterNatives(wbclass);
break;
}
Expand Down Expand Up @@ -2387,7 +2390,7 @@ static JNINativeMethod methods[] = {
{CC"countAliveClasses0", CC"(Ljava/lang/String;)I", (void*)&WB_CountAliveClasses },
{CC"getSymbolRefcount", CC"(Ljava/lang/String;)I", (void*)&WB_GetSymbolRefcount },
{CC"parseCommandLine0",
CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
CC"(Ljava/lang/String;C[Ljdk/test/whitebox/parser/DiagnosticCommand;)[Ljava/lang/Object;",
(void*) &WB_ParseCommandLine
},
{CC"addToBootstrapClassLoaderSearch0", CC"(Ljava/lang/String;)V",
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/TEST.ROOT
Expand Up @@ -40,7 +40,7 @@ groups=TEST.groups TEST.quick-groups
# to determine additional characteristics of the system for use with the @requires tag.
# Note: compiled bootlibs classes will be added to BCP.
requires.extraPropDefns = ../../jtreg-ext/requires/VMProps.java
requires.extraPropDefns.bootlibs = ../../lib/sun
requires.extraPropDefns.bootlibs = ../../lib/jdk/test/whitebox
requires.extraPropDefns.libs = \
../../lib/jdk/test/lib/Platform.java \
../../lib/jdk/test/lib/Container.java
Expand Down
Expand Up @@ -37,9 +37,9 @@
* jdk.internal.vm.ci/jdk.vm.ci.runtime
*
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
* sun.hotspot.WhiteBox sun.hotspot.parser.DiagnosticCommand
* sun.hotspot.WhiteBox jdk.test.whitebox.parser.DiagnosticCommand
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.parser.DiagnosticCommand
* jdk.test.whitebox.parser.DiagnosticCommand
* @run main/othervm -Xbootclasspath/a:.
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
Expand Down
28 changes: 19 additions & 9 deletions test/hotspot/jtreg/runtime/cds/appcds/JarBuilder.java
Expand Up @@ -131,27 +131,37 @@ static void update(String jarFile, String dir) throws Exception {
}

// Add commonly used inner classes that are often omitted by mistake. Currently
// we support only sun/hotspot/WhiteBox$WhiteBoxPermission. See JDK-8199290
// we support only jdk/test/whitebox/WhiteBox$WhiteBoxPermission and
// sun/hotspot/WhiteBox$WhiteBoxPermission. See JDK-8199290
private static String[] addInnerClasses(String[] classes, int startIdx) {
boolean seenWB = false;
boolean seenWBInner = false;
boolean seenNewWb = false;
boolean seenNewWbInner = false;
boolean seenOldWb = false;
boolean seenOldWbInner = false;
// This method is different than ClassFileInstaller.addInnerClasses which
// uses "." as the package delimiter :-(
final String wb = "sun/hotspot/WhiteBox";
final String wbInner = "sun/hotspot/WhiteBox$WhiteBoxPermission";
final String newWb = "jdk/test/whitebox/WhiteBox";
final String newWbInner = newWb + "$WhiteBoxPermission";
final String oldWb = "sun/hotspot/WhiteBox";
final String oldWbInner = oldWb + "$WhiteBoxPermission";

ArrayList<String> list = new ArrayList<>();

for (int i = startIdx; i < classes.length; i++) {
String cls = classes[i];
list.add(cls);
switch (cls) {
case wb: seenWB = true; break;
case wbInner: seenWBInner = true; break;
case newWb: seenNewWb = true; break;
case newWbInner: seenNewWbInner = true; break;
case oldWb: seenOldWb = true; break;
case oldWbInner: seenOldWbInner = true; break;
}
}
if (seenWB && !seenWBInner) {
list.add(wbInner);
if (seenNewWb && !seenNewWbInner) {
list.add(newWbInner);
}
if (seenOldWb && !seenOldWbInner) {
list.add(oldWbInner);
}

String[] array = new String[list.size()];
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/serviceability/ParserTest.java
Expand Up @@ -33,8 +33,8 @@

import java.math.BigInteger;

import sun.hotspot.parser.DiagnosticCommand;
import sun.hotspot.parser.DiagnosticCommand.DiagnosticArgumentType;
import jdk.test.whitebox.parser.DiagnosticCommand;
import jdk.test.whitebox.parser.DiagnosticCommand.DiagnosticArgumentType;
import sun.hotspot.WhiteBox;

public class ParserTest {
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/testlibrary/ctw/Makefile
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2021, 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
Expand Down Expand Up @@ -47,7 +47,7 @@ LIB_FILES = $(shell find $(TESTLIBRARY_DIR)/jdk/test/lib/ \
$(TESTLIBRARY_DIR)/jdk/test/lib/util \
$(TESTLIBRARY_DIR)/jtreg \
-maxdepth 1 -name '*.java')
WB_SRC_FILES = $(shell find $(TESTLIBRARY_DIR)/sun/hotspot -name '*.java')
WB_SRC_FILES = $(shell find $(TESTLIBRARY_DIR)/sun/hotspot $(TESTLIBRARY_DIR)/jdk/test/whitebox -name '*.java')
EXPORTS=--add-exports java.base/jdk.internal.jimage=ALL-UNNAMED \
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.reflect=ALL-UNNAMED \
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/TEST.ROOT
Expand Up @@ -39,7 +39,7 @@ groups=TEST.groups
# to determine additional characteristics of the system for use with the @requires tag.
# Note: compiled bootlibs classes will be added to BCP.
requires.extraPropDefns = ../jtreg-ext/requires/VMProps.java
requires.extraPropDefns.bootlibs = ../lib/sun
requires.extraPropDefns.bootlibs = ../lib/jdk/test/whitebox
requires.extraPropDefns.libs = \
../lib/jdk/test/lib/Platform.java \
../lib/jdk/test/lib/Container.java
Expand Down
8 changes: 4 additions & 4 deletions test/jtreg-ext/requires/VMProps.java
Expand Up @@ -44,10 +44,10 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import sun.hotspot.code.Compiler;
import sun.hotspot.cpuinfo.CPUInfo;
import sun.hotspot.gc.GC;
import sun.hotspot.WhiteBox;
import jdk.test.whitebox.code.Compiler;
import jdk.test.whitebox.cpuinfo.CPUInfo;
import jdk.test.whitebox.gc.GC;
import jdk.test.whitebox.WhiteBox;
import jdk.test.lib.Platform;
import jdk.test.lib.Container;

Expand Down
Expand Up @@ -27,14 +27,14 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @modules java.management/sun.management
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI BlobSanityTest
* @summary sanity testing of allocateCodeBlob, freeCodeBlob and getCodeBlob
*/


import sun.hotspot.WhiteBox;
import jdk.test.whitebox.WhiteBox;

import java.util.function.Consumer;
import jdk.test.lib.Utils;
Expand Down
Expand Up @@ -25,8 +25,8 @@
* @test
* @library /test/lib /
*
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI
* CPUInfoTest
Expand All @@ -35,8 +35,8 @@
import java.util.Set;
import java.util.List;
import jdk.test.lib.Platform;
import sun.hotspot.WhiteBox;
import sun.hotspot.cpuinfo.CPUInfo;
import jdk.test.whitebox.WhiteBox;
import jdk.test.whitebox.cpuinfo.CPUInfo;

import static jdk.test.lib.Asserts.*;

Expand Down
Expand Up @@ -29,11 +29,11 @@
* @modules java.base/jdk.internal.misc
* @library /test/lib
* @compile WhiteBox.java
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-CheckIntrinsics sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-CheckIntrinsics jdk.test.whitebox.WhiteBox
*/

package sun.hotspot;
package jdk.test.whitebox;

public class WhiteBox {
@SuppressWarnings("serial")
Expand Down
51 changes: 51 additions & 0 deletions test/lib-test/jdk/test/whitebox/OldWhiteBox.java
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2021, 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.
*
* 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.
*/

/*
* @test id=without-inner-class
* @summary verify that sun.hotspot.WhiteBox class still can be used
* @library /test/lib
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI OldWhiteBox
*/

/*
* @test id=with-inner-class
* @summary verify that sun.hotspot.WhiteBox class still can be used
* @library /test/lib
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI OldWhiteBox
*/

import sun.hotspot.WhiteBox;

public class OldWhiteBox {
public static void main(String[] args) {
WhiteBox wb = WhiteBox.getWhiteBox();
if (wb.getHeapOopSize() < 0) {
throw new Error("wb.getHeapOopSize() < 0");
}
}
}
Expand Up @@ -26,12 +26,12 @@
* @summary verify that whitebox functions can be linked and executed
* @modules java.base/jdk.internal.misc
* @library /test/lib
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI WBApi
*/

import sun.hotspot.WhiteBox;
import jdk.test.whitebox.WhiteBox;
public class WBApi {
public static void main(String... args) {
System.out.printf("args at: %x\n",WhiteBox.getWhiteBox().getObjectAddress(args));
Expand Down
Expand Up @@ -29,14 +29,14 @@
* java.compiler
* java.management/sun.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI BooleanTest
* @summary testing of WB::set/getBooleanVMFlag()
* @author igor.ignatyev@oracle.com
*/

import sun.hotspot.WhiteBox;
import jdk.test.whitebox.WhiteBox;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import sun.management.*;
Expand Down
Expand Up @@ -27,8 +27,8 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @modules java.management/sun.management
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DoubleTest
* @summary testing of WB::set/getDoubleVMFlag()
* @author igor.ignatyev@oracle.com
Expand Down
Expand Up @@ -27,8 +27,8 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @modules java.management/sun.management
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xint -XX:-ProfileInterpreter IntxTest
* @summary testing of WB::set/getIntxVMFlag()
* @author igor.ignatyev@oracle.com
Expand Down
Expand Up @@ -27,8 +27,8 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management/sun.management
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions SizeTTest
* @summary testing of WB::set/getSizeTVMFlag()
*/
Expand Down
Expand Up @@ -27,8 +27,8 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @modules java.management/sun.management
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI StringTest
* @summary testing of WB::set/getStringVMFlag()
* @author igor.ignatyev@oracle.com
Expand Down
Expand Up @@ -27,8 +27,8 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @modules java.management/sun.management
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI Uint64Test
* @summary testing of WB::set/getUint64VMFlag()
* @author igor.ignatyev@oracle.com
Expand Down
Expand Up @@ -27,8 +27,8 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management/sun.management
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI UintxTest
* @summary testing of WB::set/getUintxVMFlag()
* @author igor.ignatyev@oracle.com
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, 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
Expand All @@ -23,7 +23,7 @@

import java.util.function.BiConsumer;
import java.util.function.Function;
import sun.hotspot.WhiteBox;
import jdk.test.whitebox.WhiteBox;
import sun.management.*;
import com.sun.management.*;
import jdk.test.lib.Asserts;
Expand Down

1 comment on commit ada58d1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.