8174194: Several java/lang tests failing due to undeclared module dependencies
authorskovalev
Fri, 10 Feb 2017 11:00:41 +0300
changeset 43733 25b25148d346
parent 43732 358d327a8220
child 43734 64b58fc82d90
8174194: Several java/lang tests failing due to undeclared module dependencies Reviewed-by: dfuchs, mchung
jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java
jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java
jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
jdk/test/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java
jdk/test/java/lang/reflect/PublicMethods/PublicMethodsTest.java
--- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java	Fri Feb 10 11:00:41 2017 +0300
@@ -33,6 +33,7 @@
 
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
+import java.lang.reflect.Layer;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
@@ -80,25 +81,33 @@
         }
 
         void test() {
-            System.out.println("Testing module " + moduleName);
+            final boolean isModulePresent =
+                        Layer.boot().findModule(moduleName).isPresent();
+            System.out.format("Testing module: %1$s. Module is%2$s present.\n",
+                        moduleName, isModulePresent ? "" : " NOT");
 
-            // access to exported pkg should pass
-            testNonRestricted(exports);
+            if (isModulePresent) {
 
-            // access to opened pkg should pass
-            opens.ifPresent(Test::testNonRestricted);
+                // access to exported pkg should pass
+                testNonRestricted(exports);
+
+                // access to opened pkg should pass
+                opens.ifPresent(Test::testNonRestricted);
 
-            // access to concealed pkg should fail
-            testRestricted(conceals);
+                // access to concealed pkg should fail
+                testRestricted(conceals);
 
-            // access to qualified export pkg should fail
-            qualExports.ifPresent(Test::testRestricted);
+                // access to qualified export pkg should fail
+                qualExports.ifPresent(Test::testRestricted);
 
-            // access to qualified open pkg should fail
-            qualOpens.ifPresent(Test::testRestricted);
+                // access to qualified open pkg should fail
+                qualOpens.ifPresent(Test::testRestricted);
 
-            // access to qualified opened pkg that is also exported should pass
-            qualOpensAndExports.ifPresent(Test::testNonRestricted);
+                // access to qualified opened pkg that is also exported should pass
+                qualOpensAndExports.ifPresent(Test::testNonRestricted);
+            } else {
+                System.out.println("Skipping tests for module.");
+            }
         }
 
         private static void testRestricted(String pkg) {
--- a/jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java	Fri Feb 10 11:00:41 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -26,6 +26,7 @@
  * @bug 6479237
  * @summary Basic test StackTraceElement with class loader names
  * @library lib /lib/testlibrary
+ * @modules jdk.compiler
  * @build m1/* WithClassLoaderName
  * @run main/othervm m1/com.app.Main
  * @run main/othervm WithClassLoaderName
--- a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java	Fri Feb 10 11:00:41 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * @library /lib/testlibrary/jsr292 /lib/testlibrary
  * @modules java.base/java.lang.invoke:open
  *          java.base/java.lang.ref:open
- *          jdk.management
+ *          java.management
  * @build TestMethods
  * @build LambdaFormTestCase
  * @build LFCachingTestCase
--- a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java	Fri Feb 10 11:00:41 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
  * @library /lib/testlibrary/jsr292 /lib/testlibrary
  * @modules java.base/java.lang.ref:open
  *          java.base/java.lang.invoke:open
+ *          java.management
  * @build TestMethods
  * @build LambdaFormTestCase
  * @build LFCachingTestCase
--- a/jdk/test/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/jdk/test/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java	Fri Feb 10 11:00:41 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -26,6 +26,7 @@
  * @bug 8151099
  * @summary Verify platform MXBeans initialized properly with java.management
  *          module only. No other management provider
+ * @modules java.management
  * @run main/othervm --limit-modules=java.management DefaultManagementProviderTest
  */
 import java.lang.management.ManagementFactory;
--- a/jdk/test/java/lang/reflect/PublicMethods/PublicMethodsTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/jdk/test/java/lang/reflect/PublicMethods/PublicMethodsTest.java	Fri Feb 10 11:00:41 2017 +0300
@@ -57,6 +57,9 @@
 /*
  * @test
  * @bug 8062389
+ * @modules java.compiler
+ *          jdk.compiler
+ *          jdk.zipfs
  * @summary Nearly exhaustive test of Class.getMethod() and Class.getMethods()
  * @run main PublicMethodsTest
  */