changeset 16703:db26f90a85f5

8174194: Several java/lang tests failing due to undeclared module dependencies Reviewed-by: dfuchs, mchung
author skovalev
date Fri, 10 Feb 2017 11:00:41 +0300
parents 4cda2699bf59
children 96748d4b1204
files test/java/lang/SecurityManager/CheckPackageAccess.java test/java/lang/StackTraceElement/WithClassLoaderName.java test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java test/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java test/java/lang/reflect/PublicMethods/PublicMethodsTest.java
diffstat 6 files changed, 33 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/SecurityManager/CheckPackageAccess.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/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 concealed pkg should fail
-            testRestricted(conceals);
+                // access to opened pkg should pass
+                opens.ifPresent(Test::testNonRestricted);
 
-            // access to qualified export pkg should fail
-            qualExports.ifPresent(Test::testRestricted);
+                // access to concealed pkg should fail
+                testRestricted(conceals);
 
-            // access to qualified open pkg should fail
-            qualOpens.ifPresent(Test::testRestricted);
+                // access to qualified export pkg should fail
+                qualExports.ifPresent(Test::testRestricted);
 
-            // access to qualified opened pkg that is also exported should pass
-            qualOpensAndExports.ifPresent(Test::testNonRestricted);
+                // 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);
+            } else {
+                System.out.println("Skipping tests for module.");
+            }
         }
 
         private static void testRestricted(String pkg) {
--- a/test/java/lang/StackTraceElement/WithClassLoaderName.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/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/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/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/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/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/test/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/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/test/java/lang/reflect/PublicMethods/PublicMethodsTest.java	Sun Feb 12 16:45:00 2017 -0800
+++ b/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
  */