changeset 13541:6b1e77f112fc

Export sun.misc and sun.reflect pending internal API encapsulation JEP
author alanb
date Wed, 29 Jul 2015 14:08:23 +0100
parents 8ed709fbba55
children 5cf67b8de07c
files src/java.base/macosx/classes/module-info.java.extra src/java.base/share/classes/java/lang/module/Layer.java src/java.base/share/classes/module-info.java test/java/lang/invoke/modules/src/m1/p1/Main.java test/jdk/jigsaw/module/LayerTest.java test/jdk/jigsaw/reflect/CheckAccess.java test/jdk/jigsaw/reflect/Exports.java
diffstat 7 files changed, 25 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/macosx/classes/module-info.java.extra	Wed Jul 29 08:41:11 2015 -0400
+++ b/src/java.base/macosx/classes/module-info.java.extra	Wed Jul 29 14:08:23 2015 +0100
@@ -24,7 +24,6 @@
  */
 
 exports jdk.internal.misc to java.desktop;
-exports sun.misc to jdk.deploy.osx;
 exports sun.security.pkcs to jdk.deploy.osx;
 exports sun.security.util to jdk.deploy.osx;
 exports sun.security.x509 to jdk.deploy.osx;
--- a/src/java.base/share/classes/java/lang/module/Layer.java	Wed Jul 29 08:41:11 2015 -0400
+++ b/src/java.base/share/classes/java/lang/module/Layer.java	Wed Jul 29 14:08:23 2015 +0100
@@ -319,7 +319,7 @@
      * with the given name.  If a module of the given name is not in this layer
      * then the {@linkplain #parent parent} layer is checked.
      */
-    public Optional<ModuleReference> findReference(String name) {
+    Optional<ModuleReference> findReference(String name) {
         if (cf == null)
             return Optional.empty();
         Optional<ModuleReference> omref = cf.findReference(name);
--- a/src/java.base/share/classes/module-info.java	Wed Jul 29 08:41:11 2015 -0400
+++ b/src/java.base/share/classes/module-info.java	Wed Jul 29 14:08:23 2015 +0100
@@ -82,6 +82,10 @@
     // JDK-8044773
     exports jdk.net;
 
+    // These will move to a jdk.internal module via JEP-XXX
+    exports sun.misc;
+    exports sun.reflect;
+
     // additional qualified exports may be inserted at build time
     // see make/gensrc/GenModuleInfo.gmk
 
@@ -105,34 +109,10 @@
     exports jdk.internal.module to
         jdk.jartool,
         jdk.jlink;
-
     exports jdk.internal.misc to
         java.management,
         java.xml,
         jdk.scripting.nashorn;
-
-    exports sun.misc to
-        java.corba,
-        java.desktop,
-        java.logging,
-        java.management,
-        java.naming,
-        java.prefs,
-        java.rmi,
-        java.security.jgss,
-        java.security.sasl,
-        java.sql,
-        java.xml,
-        java.xml.ws,
-        jdk.charsets,
-        jdk.crypto.pkcs11,
-        jdk.httpserver,
-        jdk.jartool,
-        jdk.jconsole,
-        jdk.jvmstat,
-        jdk.scripting.nashorn,
-        jdk.security.auth,
-        jdk.security.jgss;
     exports sun.net.dns to
         java.security.jgss,
         jdk.naming.dns;
@@ -155,12 +135,6 @@
     exports sun.nio.cs to
         java.desktop,
         jdk.charsets;
-    exports sun.reflect to
-        java.corba,
-        java.logging,
-        java.sql,
-        java.sql.rowset,
-        jdk.scripting.nashorn;
     exports sun.reflect.annotation to
         jdk.compiler;
     exports sun.reflect.generics.reflectiveObjects to
--- a/test/java/lang/invoke/modules/src/m1/p1/Main.java	Wed Jul 29 08:41:11 2015 -0400
+++ b/test/java/lang/invoke/modules/src/m1/p1/Main.java	Wed Jul 29 14:08:23 2015 +0100
@@ -53,7 +53,7 @@
     static final Class<?> p2_Type2;        // m1, not exported
     static final Class<?> q1_Type1;        // m2, exported, m1 reads m2
     static final Class<?> q2_Type2;        // m2, not exported, m1 reads m2
-    static final Class<?> uuEncoderClass;  // java.base, not exported
+    static final Class<?> x500NameClass;   // java.base, not exported
 
     static {
         try {
@@ -61,7 +61,7 @@
             p2_Type2 = Class.forName("p2.Type2");
             q1_Type1 = Class.forName("q1.Type1");
             q2_Type2 = Class.forName("q2.Type2");
-            uuEncoderClass = Class.forName("sun.misc.UUEncoder");
+            x500NameClass = Class.forName("sun.security.x509.X500Name");
         } catch (ClassNotFoundException e) {
             throw new AssertionError(e);
         }
@@ -84,7 +84,7 @@
         findConstructor(lookup, q1_Type1, void.class); // [A2]
         findConstructorExpectingIAE(lookup, q2_Type2, void.class); // [A3]
         findConstructor(lookup, Object.class, void.class); // [A2]
-        findConstructorExpectingIAE(lookup, uuEncoderClass, void.class); // [A3]
+        findConstructorExpectingIAE(lookup, x500NameClass, void.class, String.class); // [A3]
 
         /**
          * Teleport from MethodHandles.lookup() to lookup class in the same module
@@ -100,7 +100,7 @@
         findConstructor(lookup2, q1_Type1, void.class); // [A2]
         findConstructorExpectingIAE(lookup2, q2_Type2, void.class); // [A3]
         findConstructor(lookup2, Object.class, void.class); // [A2]
-        findConstructorExpectingIAE(lookup2, uuEncoderClass, void.class); // [A3]
+        findConstructorExpectingIAE(lookup2, x500NameClass, void.class, String.class); // [A3]
 
         /**
          * Teleport from MethodHandles.lookup() to lookup class in another named module
@@ -133,7 +133,7 @@
         findConstructor(lookup, q1_Type1, void.class); // [A1]
         findConstructorExpectingIAE(lookup, q2_Type2, void.class); // [A2]
         findConstructor(lookup, Object.class, void.class); // [A1]
-        findConstructorExpectingIAE(lookup, uuEncoderClass, void.class); // [A2]
+        findConstructorExpectingIAE(lookup, x500NameClass, void.class); // [A2]
 
         /**
          * Teleport from MethodHandles.publicLookup() to lookup class in java.base
@@ -145,7 +145,7 @@
         lookup2 = lookup.in(Object.class);
         assertTrue((lookup2.lookupModes() & MODULE) == 0); // [A0]
         findConstructor(lookup2, String.class, void.class); // [A1]
-        findConstructorExpectingIAE(lookup2, uuEncoderClass, void.class); // [A2]
+        findConstructorExpectingIAE(lookup2, x500NameClass, void.class, String.class); // [A2]
         findConstructorExpectingIAE(lookup2, p1_Type1, void.class); // [A3]
         findConstructorExpectingIAE(lookup2, q1_Type1, void.class); // [A3]
 
@@ -162,7 +162,7 @@
         findConstructor(lookup2, Object.class, void.class);  // [A1]
         findConstructorExpectingIAE(lookup, p2_Type2, void.class); // [A2]
         findConstructorExpectingIAE(lookup, q2_Type2, void.class); // [A2]
-        findConstructorExpectingIAE(lookup2, uuEncoderClass, void.class); // [A2]
+        findConstructorExpectingIAE(lookup2, x500NameClass, void.class, String.class); // [A2]
 
         /**
          * Teleport from MethodHandles.publicLookup() to lookup class in m2
@@ -177,7 +177,7 @@
         findConstructor(lookup2, Object.class, void.class); // [A1]
         findConstructorExpectingIAE(lookup2, p1_Type1, void.class); // [A2]
         findConstructorExpectingIAE(lookup, q2_Type2, void.class); // [A2]
-        findConstructorExpectingIAE(lookup2, uuEncoderClass, void.class);  // [A2]
+        findConstructorExpectingIAE(lookup2, x500NameClass, void.class, String.class);  // [A2]
 
         /**
          * Teleport from MethodHandles.publicLookup() to lookup class that is not
--- a/test/jdk/jigsaw/module/LayerTest.java	Wed Jul 29 08:41:11 2015 -0400
+++ b/test/jdk/jigsaw/module/LayerTest.java	Wed Jul 29 14:08:23 2015 +0100
@@ -434,14 +434,14 @@
 
     /**
      * Layer.create with a configuration that contains a module that has a
-     * module-private package that is the same a concealed packaged in
-     * java.base.
+     * concealed package that is the same name as a non-exported package
+     * in java.base.
      */
     public void testConcealSamePackageAsBootLayer() {
         ModuleDescriptor descriptor
             =  new ModuleDescriptor.Builder("m1")
                 .requires("java.base")
-                .conceals("sun.misc")
+                .conceals("sun.launcher")
                 .build();
 
         ModuleFinder finder = ModuleUtils.finderOf(descriptor);
--- a/test/jdk/jigsaw/reflect/CheckAccess.java	Wed Jul 29 08:41:11 2015 -0400
+++ b/test/jdk/jigsaw/reflect/CheckAccess.java	Wed Jul 29 14:08:23 2015 +0100
@@ -43,24 +43,24 @@
 
     @Test
     public void testConstructor() throws Exception {
-        Class<?> c = Class.forName("sun.misc.BASE64Encoder");
+        Class<?> c = Class.forName("sun.security.x509.X500Name");
         assertTrue(Modifier.isPublic(c.getModifiers()));
 
-        Constructor<?> ctor = c.getConstructor();
+        Constructor<?> ctor = c.getConstructor(String.class);
         assertTrue(Modifier.isPublic(ctor.getModifiers()));
 
-        // public class, public constructor, sun.misc not exported
+        // public class, public constructor, sun.security.x509 not exported
         try {
-            ctor.newInstance();
+            ctor.newInstance("cn=duke");
             expectedIllegalAccessException();
         } catch (IllegalAccessException e) { }
 
         // suppress access check
         ctor.setAccessible(true);
-        Object encoder = ctor.newInstance();
+        Object encoder = ctor.newInstance("cn=duke");
     }
 
-    @Test
+    @Test(enabled=false)
     public void testMethodInvoke() throws Exception {
         Class<?> c = Class.forName("sun.misc.VM");
         assertTrue(Modifier.isPublic(c.getModifiers()));
@@ -79,7 +79,7 @@
         m.invoke(null);
     }
 
-    @Test
+    @Test(enabled=false)
     public void testFieldGet() throws Exception {
         Class<?> c = Class.forName("sun.misc.Unsafe");
         assertTrue(Modifier.isPublic(c.getModifiers()));
--- a/test/jdk/jigsaw/reflect/Exports.java	Wed Jul 29 08:41:11 2015 -0400
+++ b/test/jdk/jigsaw/reflect/Exports.java	Wed Jul 29 14:08:23 2015 +0100
@@ -54,8 +54,8 @@
         assertTrue(baseModule.isNamed());
         assertTrue(baseModule.isExported("java.lang"));
         assertTrue(baseModule.isExported("java.lang", thisModule));
-        assertFalse(baseModule.isExported("sun.reflect"));
-        assertFalse(baseModule.isExported("sun.reflect", thisModule));
+        assertFalse(baseModule.isExported("sun.launcher"));
+        assertFalse(baseModule.isExported("sun.launcher", thisModule));
     }
 
     /**
@@ -97,11 +97,6 @@
             Object name = ctor.newInstance("CN=Duke");
             assertTrue(false);
         } catch (IllegalAccessException expected) { }
-
-        baseModule.addExports("sun.security.x509", thisModule);
-
-        // access should succeed
-        Object name = ctor.newInstance("CN=Duke");
     }