changeset 7812:aaab3e55ae2f

Replaced WB methods for JVM_ with reflection invoke
author ctornqvi
date Tue, 10 Feb 2015 15:17:12 -0800
parents 5b987349098f
children ef26f9d82c61
files src/share/vm/prims/whitebox.cpp test/runtime/modules/AccessCheckExp.java test/runtime/modules/AccessCheckRead.java test/runtime/modules/AccessCheckSuper.java test/runtime/modules/AccessCheckToUnnamed.java test/runtime/modules/AccessCheckUnnamed.java test/runtime/modules/AccessCheckWorks.java test/runtime/modules/ExportTwice.java test/runtime/modules/JVMAddModuleExports.java test/runtime/modules/JVMAddModulePackage.java test/runtime/modules/JVMAddReadsModule.java test/runtime/modules/JVMCanReadModule.java test/runtime/modules/JVMDefineModule.java test/runtime/modules/JVMIsExportedToModule.java test/runtime/modules/LoadUnloadModuleStress.java test/runtime/modules/ModuleHelper.java
diffstat 16 files changed, 242 insertions(+), 282 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/prims/whitebox.cpp	Mon Feb 09 19:11:31 2015 -0500
+++ b/src/share/vm/prims/whitebox.cpp	Tue Feb 10 15:17:12 2015 -0800
@@ -1090,30 +1090,6 @@
   MetadataFactory::free_array(cld, (Array<u1>*)(uintptr_t)addr);
 WB_END
 
-WB_ENTRY(jobject, WB_DefineModule(JNIEnv* env, jobject o, jstring name, jobject loader, jobjectArray packages))
-  return Modules::define_module(env, name, loader, packages);
-WB_END
-
-WB_ENTRY(void, WB_AddModuleExports(JNIEnv* env, jobject o, jobject from_module, jstring package, jobject to_module))
-  Modules::add_module_exports(env, from_module, package, to_module);
-WB_END
-
-WB_ENTRY(void, WB_AddReadsModule(JNIEnv* env, jobject o, jobject from_module, jobject to_module))
-  Modules::add_reads_module(env, from_module, to_module);
-WB_END
-
-WB_ENTRY(jboolean, WB_CanReadModule(JNIEnv* env, jobject o, jobject asking_module, jobject target_module))
-  return Modules::can_read_module(env, asking_module, target_module);
-WB_END
-
-WB_ENTRY(jboolean, WB_IsExportedToModule(JNIEnv* env, jobject o, jobject from_module, jstring package, jobject to_module))
-  return Modules::is_exported_to_module(env, from_module, package, to_module);
-WB_END
-
-WB_ENTRY(void, WB_AddModulePackage(JNIEnv* env, jobject o, jclass module, jstring package))
-  Modules::add_module_package(env, module, package);
-WB_END
-
 WB_ENTRY(jlong, WB_IncMetaspaceCapacityUntilGC(JNIEnv* env, jobject wb, jlong inc))
   if (inc < 0) {
     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
@@ -1362,18 +1338,6 @@
   {CC"getCodeBlob",        CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob        },
   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
-  {CC"DefineModule", CC"(Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;",
-                                                      (void*)&WB_DefineModule },
-  {CC"AddModuleExports",   CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V",
-                                                      (void*)&WB_AddModuleExports },
-  {CC"AddReadsModule", CC"(Ljava/lang/Object;Ljava/lang/Object;)V",
-                                                      (void*)&WB_AddReadsModule },
-  {CC"CanReadModule", CC"(Ljava/lang/Object;Ljava/lang/Object;)Z",
-                                                      (void*)&WB_CanReadModule },
-  {CC"IsExportedToModule", CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z",
-                                                      (void*)&WB_IsExportedToModule },
-  {CC"AddModulePackage", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
-                                                      (void*)&WB_AddModulePackage },
   {CC"readImageFile",     CC"(Ljava/lang/String;)Z",  (void*)&WB_ReadImageFile },
   {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
   {CC"isMonitorInflated",  CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated  },
--- a/test/runtime/modules/AccessCheckExp.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/AccessCheckExp.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,26 +23,20 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @library /testlibrary
  * @compile p2/c2.java
  * @compile p1/c1.java
- * @build AccessCheckExp
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckExp
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc AccessCheckExp
  */
 
-import com.oracle.java.testlibrary.*;
 import java.lang.reflect.Module;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class AccessCheckExp {
 
     // Test that if module1 can read module2, but package p2 in module2 is not
     // exported then class p1.c1 in module1 can not read p2.c2 in module2.
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         Object m1, m2;
 
         // Get the java.lang.reflect.Module object for module java.base.
@@ -55,21 +49,21 @@
         ClassLoader this_cldr = AccessCheckExp.class.getClassLoader();
 
         // Define a module for p1.
-        m1 = wb.DefineModule("module1", this_cldr, new String[] { "p1" });
+        m1 = ModuleHelper.DefineModule("module1", this_cldr, new String[] { "p1" });
         assertNotNull(m1, "Module should not be null");
-        wb.AddReadsModule(m1, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1, jlObject_jlrM);
 
         // Define a module for p2.
-        m2 = wb.DefineModule("module2", this_cldr, new String[] { "p2" });
+        m2 = ModuleHelper.DefineModule("module2", this_cldr, new String[] { "p2" });
         assertNotNull(m2, "Module should not be null");
-        wb.AddReadsModule(m2, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2, jlObject_jlrM);
 
         // Make package p1 in m1 visible to everyone.
-        wb.AddModuleExports(m1, "p1", null);
+        ModuleHelper.AddModuleExports(m1, "p1", null);
 
         // p1.c1's ctor tries to call a method in p2.c2, but p2.c2 is not
         // exported.  So should get IllegalAccessError.
-        wb.AddReadsModule(m1, m2);
+        ModuleHelper.AddReadsModule(m1, m2);
 
         Class p1_c1_class = Class.forName("p1.c1");
         try {
--- a/test/runtime/modules/AccessCheckRead.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/AccessCheckRead.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,26 +23,22 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @library /testlibrary
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build AccessCheckRead
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckRead
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc AccessCheckRead AccessCheckRead
  */
 
 import com.oracle.java.testlibrary.*;
 import java.lang.reflect.Module;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class AccessCheckRead {
 
     // Test that a class in a package in module1 cannot access a class in
     // a package n module2 if module1 cannot read module2.
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         Object m1, m2;
 
         // Get the java.lang.reflect.Module object for module java.base.
@@ -55,17 +51,17 @@
         ClassLoader this_cldr = AccessCheckRead.class.getClassLoader();
 
         // Define a module for p1.
-        m1 = wb.DefineModule("module1", this_cldr, new String[] { "p1" });
+        m1 = ModuleHelper.DefineModule("module1", this_cldr, new String[] { "p1" });
         assertNotNull(m1, "Module should not be null");
-        wb.AddReadsModule(m1, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1, jlObject_jlrM);
 
         // Define a module for p2.
-        m2 = wb.DefineModule("module2", this_cldr, new String[] { "p2" });
+        m2 = ModuleHelper.DefineModule("module2", this_cldr, new String[] { "p2" });
         assertNotNull(m2, "Module should not be null");
-        wb.AddReadsModule(m2, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2, jlObject_jlrM);
 
         // Make package p1 in m1 visible to everyone.
-        wb.AddModuleExports(m1, "p1", null);
+        ModuleHelper.AddModuleExports(m1, "p1", null);
 
         Class p1_c1_class = Class.forName("p1.c1");
 
--- a/test/runtime/modules/AccessCheckSuper.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/AccessCheckSuper.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,25 +23,19 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @library /testlibrary
  * @compile p2/c2.java
- * @build AccessCheckSuper
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckSuper
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc AccessCheckSuper
  */
 
-import com.oracle.java.testlibrary.*;
 import java.lang.reflect.Module;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class AccessCheckSuper {
 
     // Test that when a class cannot access its super class the message
     // contains  both "superclass" text and module text.
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         Object m2;
 
         // Get the class loader for AccessCheckSuper and assume it's also used to
@@ -49,7 +43,7 @@
         ClassLoader this_cldr = AccessCheckSuper.class.getClassLoader();
 
         // Define a module for p2.
-        m2 = wb.DefineModule("module2", this_cldr, new String[] { "p2" });
+        m2 = ModuleHelper.DefineModule("module2", this_cldr, new String[] { "p2" });
         assertNotNull(m2, "Module should not be null");
 
         // p2.c2 cannot read its superclass java.lang.Object
--- a/test/runtime/modules/AccessCheckToUnnamed.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/AccessCheckToUnnamed.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,18 +23,13 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @library /testlibrary
  * @compile p2/c2.java
  * @compile p1/c1.java
- * @build AccessCheckToUnnamed
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckToUnnamed
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc AccessCheckToUnnamed
  */
 
-import com.oracle.java.testlibrary.*;
 import java.lang.reflect.Module;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class AccessCheckToUnnamed {
@@ -42,8 +37,7 @@
     // Check that a class in a package in module1 can successfully access a
     // class that is in the unnamed module.
     // has been exported.
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         Object m1;
 
         // Get the java.lang.reflect.Module object for module java.base.
@@ -56,12 +50,12 @@
         ClassLoader this_cldr = AccessCheckToUnnamed.class.getClassLoader();
 
         // Define a module for p1.
-        m1 = wb.DefineModule("module1", this_cldr, new String[] { "p1" });
+        m1 = ModuleHelper.DefineModule("module1", this_cldr, new String[] { "p1" });
         assertNotNull(m1, "Module should not be null");
-        wb.AddReadsModule(m1, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1, jlObject_jlrM);
 
         // Make package p1 in m1 visible to everyone.
-        wb.AddModuleExports(m1, "p1", null);
+        ModuleHelper.AddModuleExports(m1, "p1", null);
 
         // p1.c1's ctor tries to call a method in p2.c2.  This should work because
         // p2 is in the unnamed module.
--- a/test/runtime/modules/AccessCheckUnnamed.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/AccessCheckUnnamed.java	Tue Feb 10 15:17:12 2015 -0800
@@ -21,28 +21,22 @@
  * questions.
  */
 
-import com.oracle.java.testlibrary.*;
 import java.lang.reflect.Module;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @library /testlibrary
  * @compile p2/c2.java
  * @compile p1/c1.java
- * @build AccessCheckUnnamed
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckUnnamed
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc AccessCheckUnnamed
  */
 
 public class AccessCheckUnnamed {
 
     // Test that a class in the unnamed module can not access a package in a
     // named module that has not been unqualifiedly exported.
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         Object m1, m2;
 
         // Get the java.lang.reflect.Module object for module java.base.
@@ -55,9 +49,9 @@
         ClassLoader this_cldr = AccessCheckUnnamed.class.getClassLoader();
 
         // Define a module for p2.
-        m2 = wb.DefineModule("module2", this_cldr, new String[] { "p2" });
+        m2 = ModuleHelper.DefineModule("module2", this_cldr, new String[] { "p2" });
         assertNotNull(m2, "Module should not be null");
-        wb.AddReadsModule(m2, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2, jlObject_jlrM);
 
         // p1.c1's ctor tries to call a method in p2.c2.  This should fail because
         // p1 is in the unnamed module and p2.c2 is not unqualifiedly exported.
--- a/test/runtime/modules/AccessCheckWorks.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/AccessCheckWorks.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,18 +23,13 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @library /testlibrary
  * @compile p2/c2.java
  * @compile p1/c1.java
- * @build AccessCheckWorks
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckWorks
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc AccessCheckWorks
  */
 
-import com.oracle.java.testlibrary.*;
 import java.lang.reflect.Module;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class AccessCheckWorks {
@@ -42,8 +37,7 @@
     // Check that a class in a package in module1 can successfully access a
     // class in module2 when module1 can read module2 and the class's package
     // has been exported.
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         Object m1, m2;
 
         // Get the java.lang.reflect.Module object for module java.base.
@@ -56,22 +50,22 @@
         ClassLoader this_cldr = AccessCheckWorks.class.getClassLoader();
 
         // Define a module for p1.
-        m1 = wb.DefineModule("module1", this_cldr, new String[] { "p1" });
+        m1 = ModuleHelper.DefineModule("module1", this_cldr, new String[] { "p1" });
         assertNotNull(m1, "Module should not be null");
-        wb.AddReadsModule(m1, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1, jlObject_jlrM);
 
         // Define a module for p2.
-        m2 = wb.DefineModule("module2", this_cldr, new String[] { "p2" });
+        m2 = ModuleHelper.DefineModule("module2", this_cldr, new String[] { "p2" });
         assertNotNull(m2, "Module should not be null");
-        wb.AddReadsModule(m2, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2, jlObject_jlrM);
 
         // Make package p1 in m1 visible to everyone.
-        wb.AddModuleExports(m1, "p1", null);
+        ModuleHelper.AddModuleExports(m1, "p1", null);
 
         // p1.c1's ctor tries to call a method in p2.c2.  This should work because
         // p1's module can read p2's module and p2 is exported to p1's module.
-        wb.AddReadsModule(m1, m2);
-        wb.AddModuleExports(m2, "p2", m1);
+        ModuleHelper.AddReadsModule(m1, m2);
+        ModuleHelper.AddModuleExports(m2, "p2", m1);
         Class p1_c1_class = Class.forName("p1.c1");
         p1_c1_class.newInstance();
     }
--- a/test/runtime/modules/ExportTwice.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/ExportTwice.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,18 +23,13 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @library /testlibrary
  * @compile p2/c2.java
  * @compile p1/c1.java
- * @build ExportTwice
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ExportTwice
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc ExportTwice
  */
 
-import com.oracle.java.testlibrary.*;
 import java.lang.reflect.Module;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class ExportTwice {
@@ -43,8 +38,7 @@
     // to a specific package.
     // Also, check that a package can be exported to a specific package and then
     // exported unqualifiedly.
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         Object m1, m2, m3;
 
         // Get the java.lang.reflect.Module object for module java.base.
@@ -57,26 +51,26 @@
         ClassLoader this_cldr = ExportTwice.class.getClassLoader();
 
         // Define a module for p1.
-        m1 = wb.DefineModule("module1", this_cldr, new String[] { "p1" });
+        m1 = ModuleHelper.DefineModule("module1", this_cldr, new String[] { "p1" });
         assertNotNull(m1, "Module should not be null");
-        wb.AddReadsModule(m1, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1, jlObject_jlrM);
 
         // Define a module for p2.
-        m2 = wb.DefineModule("module2", this_cldr, new String[] { "p2" });
+        m2 = ModuleHelper.DefineModule("module2", this_cldr, new String[] { "p2" });
         assertNotNull(m2, "Module should not be null");
-        wb.AddReadsModule(m2, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2, jlObject_jlrM);
 
         // Define a module for p3.
-        m3 = wb.DefineModule("module3", this_cldr, new String[] { "p3" });
+        m3 = ModuleHelper.DefineModule("module3", this_cldr, new String[] { "p3" });
         assertNotNull(m3, "Module should not be null");
-        wb.AddReadsModule(m3, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m3, jlObject_jlrM);
 
         // Make package p1 in m1 visible to everyone.
-        wb.AddModuleExports(m1, "p1", null);
+        ModuleHelper.AddModuleExports(m1, "p1", null);
 
         // Try to export p1 only to m2 after it was exported unqualifiedly.
         try {
-            wb.AddModuleExports(m1, "p1", m2);
+            ModuleHelper.AddModuleExports(m1, "p1", m2);
             throw new RuntimeException("Failed to get IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             if (!e.getMessage().contains("package p1 in module module1 is already unqualifiedly exported")) {
@@ -85,12 +79,12 @@
         }
 
         // Export p2 to m3 then export it again unqualifiedly.
-        wb.AddModuleExports(m2, "p2", m3);
-        wb.AddModuleExports(m2, "p2", null);
+        ModuleHelper.AddModuleExports(m2, "p2", m3);
+        ModuleHelper.AddModuleExports(m2, "p2", null);
 
         // p1.c1's ctor tries to call a method in p2.c2.  This should work because
         // p1's module can read p2's module and p2 is now exported unqualifiedly.
-        wb.AddReadsModule(m1, m2);
+        ModuleHelper.AddReadsModule(m1, m2);
         Class p1_c1_class = Class.forName("p1.c1");
         p1_c1_class.newInstance();
     }
--- a/test/runtime/modules/JVMAddModuleExports.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/JVMAddModuleExports.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,44 +23,39 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
- * @build JVMAddModuleExports
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExports
+ * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc JVMAddModuleExports
  */
 
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
+import java.lang.reflect.Module;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class JVMAddModuleExports {
 
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         MyClassLoader from_cl = new MyClassLoader();
         MyClassLoader to_cl = new MyClassLoader();
-        Object from_module, to_module;
+        Module from_module, to_module;
 
-        from_module = wb.DefineModule("from_module", from_cl, new String[] { "mypackage", "this/package" });
+        from_module = ModuleHelper.DefineModule("from_module", from_cl, new String[] { "mypackage", "this/package" });
         assertNotNull(from_module, "Module should not be null");
-        to_module = wb.DefineModule("to_module", to_cl, new String[] { "yourpackage", "that/package" });
+        to_module = ModuleHelper.DefineModule("to_module", to_cl, new String[] { "yourpackage", "that/package" });
         assertNotNull(to_module, "Module should not be null");
 
         // Null from_module argument, expect an NPE
         try {
-            wb.AddModuleExports(null, "mypackage", to_module);
+            ModuleHelper.AddModuleExports((Module)null, "mypackage", to_module);
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
         }
 
         // Normal export to null module
-        wb.AddModuleExports(to_module, "that/package", null);
+        ModuleHelper.AddModuleExports(to_module, "that/package", (Module)null);
 
         // Bad from_module argument, expect an IAE
         try {
-            wb.AddModuleExports(to_cl, "mypackage", to_module);
+            ModuleHelper.AddModuleExports(to_cl, "mypackage", to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -68,7 +63,7 @@
 
         // Null package argument, expect an NPE
         try {
-            wb.AddModuleExports(from_module, null, to_module);
+            ModuleHelper.AddModuleExports(from_module, null, to_module);
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
@@ -76,18 +71,18 @@
 
         // Bad to_module argument, expect an IAE
         try {
-            wb.AddModuleExports(from_module, "mypackage", from_cl);
+            ModuleHelper.AddModuleExports(from_module, "mypackage", from_cl);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Exporting a package to the same module
-        wb.AddModuleExports(from_module, "mypackage", from_module);
+        ModuleHelper.AddModuleExports(from_module, "mypackage", from_module);
 
         // Export a package that does not exist to to_module
         try {
-            wb.AddModuleExports(from_module, "notmypackage", to_module);
+            ModuleHelper.AddModuleExports(from_module, "notmypackage", to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -95,7 +90,7 @@
 
         // Export a package, that is not in from_module, to to_module
         try {
-            wb.AddModuleExports(from_module, "yourpackage", to_module);
+            ModuleHelper.AddModuleExports(from_module, "yourpackage", to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -103,7 +98,7 @@
 
         // Export a package, that does not exist, to from_module
         try {
-            wb.AddModuleExports(from_module, "notmypackage", from_module);
+            ModuleHelper.AddModuleExports(from_module, "notmypackage", from_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -111,28 +106,28 @@
 
         // Export a package, that is not in from_module, to from_module
         try {
-            wb.AddModuleExports(from_module, "that/package", from_module);
+            ModuleHelper.AddModuleExports(from_module, "that/package", from_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Export the same package twice to the same module
-        wb.AddModuleExports(from_module, "this/package", to_module);
-        wb.AddModuleExports(from_module, "this/package", to_module);
+        ModuleHelper.AddModuleExports(from_module, "this/package", to_module);
+        ModuleHelper.AddModuleExports(from_module, "this/package", to_module);
 
         // Export a package, using '.' instead of '/'
         try {
-            wb.AddModuleExports(from_module, "this.package", to_module);
+            ModuleHelper.AddModuleExports(from_module, "this.package", to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Export a package to the unnamed module and then to a specific module.
-        wb.AddModuleExports(to_module, "that/package", null);
+        ModuleHelper.AddModuleExports(to_module, "that/package", (Module)null);
         try {
-            wb.AddModuleExports(to_module, "that/package", from_module);
+            ModuleHelper.AddModuleExports(to_module, "that/package", from_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
--- a/test/runtime/modules/JVMAddModulePackage.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/JVMAddModulePackage.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,43 +23,37 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
- * @build JVMAddModulePackage
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModulePackage
+ * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc JVMAddModulePackage
  */
 
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class JVMAddModulePackage {
 
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         MyClassLoader cl1 = new MyClassLoader();
         MyClassLoader cl3 = new MyClassLoader();
         Object module1, module2, module3;
         boolean result;
 
-        module1 = wb.DefineModule("module1", cl1, new String[] { "mypackage" });
+        module1 = ModuleHelper.DefineModule("module1", cl1, new String[] { "mypackage" });
         assertNotNull(module1, "Module should not be null");
-        module2 = wb.DefineModule("module2", cl1, new String[] { "yourpackage" });
+        module2 = ModuleHelper.DefineModule("module2", cl1, new String[] { "yourpackage" });
         assertNotNull(module2, "Module should not be null");
-        module3 = wb.DefineModule("module3", cl3, new String[] { "package/num3" });
+        module3 = ModuleHelper.DefineModule("module3", cl3, new String[] { "package/num3" });
         assertNotNull(module3, "Module should not be null");
 
         // Simple call
-        wb.AddModulePackage(module1, "new_package");
+        ModuleHelper.AddModulePackage(module1, "new_package");
 
         // Add a package and export it
-        wb.AddModulePackage(module1, "package/num3");
-        wb.AddModuleExports(module1, "package/num3", null);
+        ModuleHelper.AddModulePackage(module1, "package/num3");
+        ModuleHelper.AddModuleExports(module1, "package/num3", null);
 
         // Null module argument, expect an NPE
         try {
-            wb.AddModulePackage(null, "new_package");
+            ModuleHelper.AddModulePackage(null, "new_package");
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
@@ -67,7 +61,7 @@
 
         // Bad module argument, expect an IAE
         try {
-            wb.AddModulePackage(cl1, "new_package");
+            ModuleHelper.AddModulePackage(cl1, "new_package");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -75,7 +69,7 @@
 
         // Null package argument, expect an NPE
         try {
-            wb.AddModulePackage(module1, null);
+            ModuleHelper.AddModulePackage(module1, null);
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
@@ -83,7 +77,7 @@
 
         // Existing package, expect an IAE
         try {
-            wb.AddModulePackage(module1, "yourpackage");
+            ModuleHelper.AddModulePackage(module1, "yourpackage");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -91,7 +85,7 @@
 
         // Invalid package name, expect an IAE
         try {
-            wb.AddModulePackage(module1, "your.package");
+            ModuleHelper.AddModulePackage(module1, "your.package");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -99,7 +93,7 @@
 
         // Invalid package name, expect an IAE
         try {
-            wb.AddModulePackage(module1, ";your/package");
+            ModuleHelper.AddModulePackage(module1, ";your/package");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -107,7 +101,7 @@
 
         // Invalid package name, expect an IAE
         try {
-            wb.AddModulePackage(module1, "7[743");
+            ModuleHelper.AddModulePackage(module1, "7[743");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -115,7 +109,7 @@
 
         // Empty package name, expect an IAE
         try {
-            wb.AddModulePackage(module1, "");
+            ModuleHelper.AddModulePackage(module1, "");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
--- a/test/runtime/modules/JVMAddReadsModule.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/JVMAddReadsModule.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,33 +23,27 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
- * @build JVMAddReadsModule
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddReadsModule
+ * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc JVMAddReadsModule
  */
 
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class JVMAddReadsModule {
 
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         MyClassLoader from_cl = new MyClassLoader();
         MyClassLoader to_cl = new MyClassLoader();
         Object from_module, to_module;
 
-        from_module = wb.DefineModule("from_module", from_cl, new String[] { "mypackage" });
+        from_module = ModuleHelper.DefineModule("from_module", from_cl, new String[] { "mypackage" });
         assertNotNull(from_module, "Module should not be null");
-        to_module = wb.DefineModule("to_module", to_cl, new String[] { "yourpackage" });
+        to_module = ModuleHelper.DefineModule("to_module", to_cl, new String[] { "yourpackage" });
         assertNotNull(to_module, "Module should not be null");
 
         // Null from_module argument, expect an NPE
         try {
-            wb.AddReadsModule(null, to_module);
+            ModuleHelper.AddReadsModule(null, to_module);
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
@@ -57,7 +51,7 @@
 
         // Null to_module argument, expect an NPE
         try {
-            wb.AddReadsModule(from_module, null);
+            ModuleHelper.AddReadsModule(from_module, null);
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
@@ -65,18 +59,18 @@
 
         // Null from_module and to_module arguments, expect an NPE
         try {
-            wb.AddReadsModule(null, null);
+            ModuleHelper.AddReadsModule(null, null);
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
         }
 
         // Both modules are the same, should not throw an exception
-        wb.AddReadsModule(from_module, from_module);
+        ModuleHelper.AddReadsModule(from_module, from_module);
 
         // Duplicate calls, should not throw an exception
-        wb.AddReadsModule(from_module, to_module);
-        wb.AddReadsModule(from_module, to_module);
+        ModuleHelper.AddReadsModule(from_module, to_module);
+        ModuleHelper.AddReadsModule(from_module, to_module);
     }
 
     static class MyClassLoader extends ClassLoader { }
--- a/test/runtime/modules/JVMCanReadModule.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/JVMCanReadModule.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,37 +23,31 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
- * @build JVMCanReadModule
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMCanReadModule
+ * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc JVMCanReadModule
  */
 
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class JVMCanReadModule {
 
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         MyClassLoader asking_cl = new MyClassLoader();
         MyClassLoader target_cl = new MyClassLoader();
         Object asking_module, target_module;
         boolean result;
 
-        asking_module = wb.DefineModule("asking_module", asking_cl, new String[] { "mypackage" });
+        asking_module = ModuleHelper.DefineModule("asking_module", asking_cl, new String[] { "mypackage" });
         assertNotNull(asking_module, "Module should not be null");
-        target_module = wb.DefineModule("target_module", target_cl, new String[] { "yourpackage" });
+        target_module = ModuleHelper.DefineModule("target_module", target_cl, new String[] { "yourpackage" });
         assertNotNull(target_module, "Module should not be null");
 
         // Set up relationship
-        wb.AddReadsModule(asking_module, target_module);
+        ModuleHelper.AddReadsModule(asking_module, target_module);
 
         // Null asking_module argument, expect an NPE
         try {
-            result = wb.CanReadModule(null, target_module);
+            result = ModuleHelper.CanReadModule(null, target_module);
             throw new RuntimeException("Failed to get the expected NPE");
         } catch(NullPointerException e) {
             // Expected
@@ -61,7 +55,7 @@
 
         // Bad asking_module argument, expect an IAE
         try {
-            result = wb.CanReadModule(asking_cl, target_module);
+            result = ModuleHelper.CanReadModule(asking_cl, target_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -69,26 +63,26 @@
 
         // Bad target_module argument, expect an IAE
         try {
-            result = wb.CanReadModule(asking_module, asking_cl);
+            result = ModuleHelper.CanReadModule(asking_module, asking_cl);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Verify modules can always read the unnamed module
-        result = wb.CanReadModule(target_module, null);
+        result = ModuleHelper.CanReadModule(target_module, null);
         assertTrue(result, "target_module can read unnamed module");
 
         // Verify asking_module can read itself
-        result = wb.CanReadModule(asking_module, asking_module);
+        result = ModuleHelper.CanReadModule(asking_module, asking_module);
         assertTrue(result, "asking_module can read itself");
 
         // Verify asking_module can read target_module
-        result = wb.CanReadModule(asking_module, target_module);
+        result = ModuleHelper.CanReadModule(asking_module, target_module);
         assertTrue(result, "asking_module can read target_module");
 
         // Verify target_module cannot read asking_module
-        result = wb.CanReadModule(target_module, asking_module);
+        result = ModuleHelper.CanReadModule(target_module, asking_module);
         assertTrue(!result, "target_module cannot read asking_module");
     }
 
--- a/test/runtime/modules/JVMDefineModule.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/JVMDefineModule.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,43 +23,37 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
- * @build JVMDefineModule
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMDefineModule
+ * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc JVMDefineModule
  */
 
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class JVMDefineModule {
 
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         MyClassLoader cl = new MyClassLoader();
         Object m;
 
         // NULL classloader argument, expect success
-        m = wb.DefineModule("mymodule", null, new String[] { "mypackage" });
+        m = ModuleHelper.DefineModule("mymodule", null, new String[] { "mypackage" });
         assertNotNull(m, "Module should not be null");
 
         // Invalid classloader argument, expect an IAE
         try {
-            wb.DefineModule("mymodule1", new Object(), new String[] { "mypackage1" });
+            ModuleHelper.DefineModule("mymodule1", new Object(), new String[] { "mypackage1" });
             throw new RuntimeException("Failed to get expected IAE for bad loader");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // NULL package argument, should not throw an exception
-        m = wb.DefineModule("mymodule2", cl, null);
+        m = ModuleHelper.DefineModule("mymodule2", cl, null);
         assertNotNull(m, "Module should not be null");
 
         // NULL module name, expect an NPE
         try {
-            wb.DefineModule(null, cl, new String[] { "mypackage2" });
+            ModuleHelper.DefineModule(null, cl, new String[] { "mypackage2" });
             throw new RuntimeException("Failed to get expected NPE for NULL module");
         } catch(NullPointerException e) {
             // Expected
@@ -67,7 +61,7 @@
 
         // module name is java.base, expect an IAE
         try {
-            wb.DefineModule("java.base", cl, new String[] { "mypackage3" });
+            ModuleHelper.DefineModule("java.base", cl, new String[] { "mypackage3" });
             throw new RuntimeException("Failed to get expected IAE for java.base");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -75,7 +69,7 @@
 
         // Duplicates in package list, expect an IAE
         try {
-            wb.DefineModule("java.base", cl, new String[] { "mypackage4", "mypackage5", "mypackage4" });
+            ModuleHelper.DefineModule("java.base", cl, new String[] { "mypackage4", "mypackage5", "mypackage4" });
             throw new RuntimeException("Failed to get IAE for duplicate packages");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -83,17 +77,17 @@
 
         // Empty entry in package list, expect an IAE
         try {
-            wb.DefineModule("java.base", cl, new String[] { "mypackageX", "", "mypackageY" });
+            ModuleHelper.DefineModule("java.base", cl, new String[] { "mypackageX", "", "mypackageY" });
             throw new RuntimeException("Failed to get IAE for empty package");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Duplicate module name, expect an IAE
-        m = wb.DefineModule("module.name", cl, new String[] { "mypackage6" });
+        m = ModuleHelper.DefineModule("module.name", cl, new String[] { "mypackage6" });
         assertNotNull(m, "Module should not be null");
         try {
-            wb.DefineModule("module.name", cl, new String[] { "mypackage7" });
+            ModuleHelper.DefineModule("module.name", cl, new String[] { "mypackage7" });
             throw new RuntimeException("Failed to get IAE for duplicate module");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -101,7 +95,7 @@
 
         // Package is already defined for class loader, expect an IAE
         try {
-            wb.DefineModule("dupl.pkg.module", cl, new String[] { "mypackage6" });
+            ModuleHelper.DefineModule("dupl.pkg.module", cl, new String[] { "mypackage6" });
             throw new RuntimeException("Failed to get IAE for existing package");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -109,7 +103,7 @@
 
         // Empty module name, expect an IAE
         try {
-            wb.DefineModule("", cl, new String[] { "mypackage8" });
+            ModuleHelper.DefineModule("", cl, new String[] { "mypackage8" });
             throw new RuntimeException("Failed to get expected IAE for empty module name");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -117,7 +111,7 @@
 
         // Bad module name, expect an IAE
         try {
-            wb.DefineModule("bad;name", cl, new String[] { "mypackage9" });
+            ModuleHelper.DefineModule("bad;name", cl, new String[] { "mypackage9" });
             throw new RuntimeException("Failed to get expected IAE for bad;name");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -125,7 +119,7 @@
 
         // Bad module name, expect an IAE
         try {
-            wb.DefineModule(".leadingdot", cl, new String[] { "mypackage9a" });
+            ModuleHelper.DefineModule(".leadingdot", cl, new String[] { "mypackage9a" });
             throw new RuntimeException("Failed to get expected IAE for .leadingdot");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -133,7 +127,7 @@
 
         // Bad module name, expect an IAE
         try {
-            wb.DefineModule("trailingdot.", cl, new String[] { "mypackage9b" });
+            ModuleHelper.DefineModule("trailingdot.", cl, new String[] { "mypackage9b" });
             throw new RuntimeException("Failed to get expected IAE for trailingdot.");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -141,23 +135,23 @@
 
         // Bad module name, expect an IAE
         try {
-            wb.DefineModule("consecutive..dots", cl, new String[] { "mypackage9c" });
+            ModuleHelper.DefineModule("consecutive..dots", cl, new String[] { "mypackage9c" });
             throw new RuntimeException("Failed to get expected IAE for consecutive..dots");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // module name with multiple dots, should be okay
-        m = wb.DefineModule("more.than.one.dat", cl, new String[] { "mypackage9d" });
+        m = ModuleHelper.DefineModule("more.than.one.dat", cl, new String[] { "mypackage9d" });
         assertNotNull(m, "Module should not be null");
 
         // Zero length package list, should be okay
-        m = wb.DefineModule("zero.packages", cl, new String[] { });
+        m = ModuleHelper.DefineModule("zero.packages", cl, new String[] { });
         assertNotNull(m, "Module should not be null");
 
         // Invalid package name, expect an IAE
         try {
-            wb.DefineModule("module5", cl, new String[] { "your.package" });
+            ModuleHelper.DefineModule("module5", cl, new String[] { "your.package" });
             throw new RuntimeException("Failed to get expected IAE for your.package");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -165,7 +159,7 @@
 
         // Invalid package name, expect an IAE
         try {
-            wb.DefineModule("module6", cl, new String[] { ";your/package" });
+            ModuleHelper.DefineModule("module6", cl, new String[] { ";your/package" });
             throw new RuntimeException("Failed to get expected IAE for ;your.package");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -173,7 +167,7 @@
 
         // Invalid package name, expect an IAE
         try {
-            wb.DefineModule("module7", cl, new String[] { "7[743" });
+            ModuleHelper.DefineModule("module7", cl, new String[] { "7[743" });
             throw new RuntimeException("Failed to get expected IAE for package 7[743");
         } catch(IllegalArgumentException e) {
             // Expected
--- a/test/runtime/modules/JVMIsExportedToModule.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/JVMIsExportedToModule.java	Tue Feb 10 15:17:12 2015 -0800
@@ -23,46 +23,40 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
- * @build JVMIsExportedToModule
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMIsExportedToModule
+ * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc JVMIsExportedToModule
  */
 
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class JVMIsExportedToModule {
 
-    public static void main(String args[]) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static void main(String args[]) throws Throwable {
         MyClassLoader from_cl = new MyClassLoader();
         MyClassLoader to_cl = new MyClassLoader();
         Object from_module, to_module;
         boolean result;
 
-        from_module = wb.DefineModule("from_module", from_cl, new String[] { "mypackage", "this/package" });
+        from_module = ModuleHelper.DefineModule("from_module", from_cl, new String[] { "mypackage", "this/package" });
         assertNotNull(from_module, "Module should not be null");
-        to_module = wb.DefineModule("to_module", to_cl, new String[] { "yourpackage", "that/package" });
+        to_module = ModuleHelper.DefineModule("to_module", to_cl, new String[] { "yourpackage", "that/package" });
         assertNotNull(to_module, "Module should not be null");
 
         // Null from_module argument, expect an NPE
         try {
-            result = wb.IsExportedToModule(null, "mypackage", to_module);
+            result = ModuleHelper.IsExportedToModule(null, "mypackage", to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(NullPointerException e) {
             // Expected
         }
 
         // Null to_module argument, expect normal return
-        result = wb.IsExportedToModule(from_module, "mypackage", null);
+        result = ModuleHelper.IsExportedToModule(from_module, "mypackage", null);
         assertTrue(!result, "Package has not been exported");
 
         // Null package argument, expect an NPE
         try {
-            result = wb.IsExportedToModule(from_module, null, to_module);
+            result = ModuleHelper.IsExportedToModule(from_module, null, to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(NullPointerException e) {
             // Expected
@@ -70,7 +64,7 @@
 
         // Bad from_module argument, expect an IAE
         try {
-            result = wb.IsExportedToModule(to_cl, "mypackage", to_module);
+            result = ModuleHelper.IsExportedToModule(to_cl, "mypackage", to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -78,36 +72,36 @@
 
         // Bad to_module argument, expect an IAE
         try {
-            result = wb.IsExportedToModule(from_module, "mypackage", from_cl);
+            result = ModuleHelper.IsExportedToModule(from_module, "mypackage", from_cl);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Check that package is exported to its own module
-        result = wb.IsExportedToModule(from_module, "mypackage", from_module);
+        result = ModuleHelper.IsExportedToModule(from_module, "mypackage", from_module);
         assertTrue(result, "Package is always exported to itself");
 
         // Package is not in to_module, expect an IAE
         try {
-            result = wb.IsExportedToModule(from_module, "yourpackage", from_cl);
+            result = ModuleHelper.IsExportedToModule(from_module, "yourpackage", from_cl);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Package is accessible when exported to unnamed module
-        wb.AddModuleExports(from_module, "mypackage", null);
-        result = wb.IsExportedToModule(from_module, "mypackage", to_module);
+        ModuleHelper.AddModuleExports(from_module, "mypackage", null);
+        result = ModuleHelper.IsExportedToModule(from_module, "mypackage", to_module);
         assertTrue(result, "Package exported to unnamed module is visible to named module");
-        result = wb.IsExportedToModule(from_module, "mypackage", null);
+        result = ModuleHelper.IsExportedToModule(from_module, "mypackage", null);
         assertTrue(result, "Package exported to unnamed module is visible to unnamed module");
 
         // Package is accessible only to named module when exported to named module
-        wb.AddModuleExports(from_module, "this/package", to_module);
-        result = wb.IsExportedToModule(from_module, "this/package", to_module);
+        ModuleHelper.AddModuleExports(from_module, "this/package", to_module);
+        result = ModuleHelper.IsExportedToModule(from_module, "this/package", to_module);
         assertTrue(result, "Package exported to named module is visible to named module");
-        result = wb.IsExportedToModule(from_module, "this/package", null);
+        result = ModuleHelper.IsExportedToModule(from_module, "this/package", null);
         assertTrue(!result, "Package exported to named module is not visible to unnamed module");
     }
 
--- a/test/runtime/modules/LoadUnloadModuleStress.java	Mon Feb 09 19:11:31 2015 -0500
+++ b/test/runtime/modules/LoadUnloadModuleStress.java	Tue Feb 10 15:17:12 2015 -0800
@@ -24,16 +24,11 @@
 /*
  * @test
  * @summary Ensure module information is cleaned when owning class loader unloads
- * @library /testlibrary /../../test/lib /compiler/whitebox ..
- * @build LoadUnloadModuleStress
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx64m LoadUnloadModuleStress 15000
+ * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc -Xmx64m LoadUnloadModuleStress 15000
  */
 
 import java.lang.ref.WeakReference;
-import com.oracle.java.testlibrary.*;
-import sun.hotspot.WhiteBox;
 import static com.oracle.java.testlibrary.Asserts.*;
 
 public class LoadUnloadModuleStress {
@@ -43,16 +38,15 @@
     public static byte[] garbage;
     public static volatile WeakReference<MyClassLoader> clweak;
 
-    public static Object createModule() {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+    public static Object createModule() throws Throwable {
         MyClassLoader cl = new MyClassLoader();
-        Object module = wb.DefineModule("mymodule", cl, new String [] {"PackageA"});
+        Object module = ModuleHelper.DefineModule("mymodule", cl, new String [] {"PackageA"});
         assertNotNull(module);
         clweak = new WeakReference<>(cl);
         return module;
     }
 
-    public static void main(String args[]) throws Exception {
+    public static void main(String args[]) throws Throwable {
         timeout = Long.valueOf(args[0]);
         timeStamp = System.currentTimeMillis();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/modules/ModuleHelper.java	Tue Feb 10 15:17:12 2015 -0800
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Module;
+
+public class ModuleHelper {
+
+    public static Module DefineModule(String name, Object loader, String[] pkgs) throws Throwable {
+        return DefineModule(name, "1.0", "location", loader, pkgs);
+    }
+
+    public static Module DefineModule(String name, String version, String location,
+                                      Object loader, String[] pkgs) throws Throwable {
+        return (Module)invoke(findMethod("defineModule"), name, version, location, loader, pkgs);
+    }
+
+    public static void AddModuleExports(Object from, String pkg, Object to) throws Throwable {
+        invoke(findMethod("addModuleExports"), from, pkg, to);
+    }
+
+    public static void AddReadsModule(Object from, Object to) throws Throwable {
+        invoke(findMethod("addReadsModule"), from, to);
+    }
+
+    public static void AddModulePackage(Object m, String pkg) throws Throwable {
+        invoke(findMethod("addModulePackage"), m, pkg);
+    }
+
+    public static boolean CanReadModule(Object from, Object to) throws Throwable {
+        return (boolean)invoke(findMethod("canReadModule"), from, to);
+    }
+
+    public static boolean IsExportedToModule(Object from, String pkg,
+                                             Object to) throws Throwable {
+        return (boolean)invoke(findMethod("isExportedToModule"), from, pkg, to);
+    }
+
+    private static Object invoke(Method m, Object... args) throws Throwable {
+        try {
+            return m.invoke(null, args);
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    private static Method findMethod(String name) {
+        for (Method m : sun.misc.VM.class.getDeclaredMethods()) {
+            if (m.getName().equals(name)) {
+                m.setAccessible(true);
+                return m;
+            }
+        }
+        throw new RuntimeException("Failed to find method " + name + "in sun.misc.VM");
+    }
+}