--- old/src/java.base/share/classes/java/io/RandomAccessFile.java 2019-06-26 16:00:23.351796200 +0200 +++ new/src/java.base/share/classes/java/io/RandomAccessFile.java 2019-06-26 16:00:22.389373300 +0200 @@ -26,6 +26,7 @@ package java.io; import java.nio.channels.FileChannel; +import java.util.concurrent.atomic.AtomicBoolean; import jdk.internal.access.JavaIORandomAccessFileAccess; import jdk.internal.access.SharedSecrets; --- old/src/java.base/share/classes/java/security/Security.java 2019-06-26 16:00:30.201256300 +0200 +++ new/src/java.base/share/classes/java/security/Security.java 2019-06-26 16:00:29.243167200 +0200 @@ -32,7 +32,7 @@ import jdk.internal.event.EventHelper; import jdk.internal.event.SecurityPropertyModificationEvent; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.access.SharedSecrets; import jdk.internal.util.StaticProperty; import sun.security.util.Debug; import sun.security.util.PropertyExpander; --- old/src/java.base/share/classes/java/util/ImmutableCollections.java 2019-06-26 16:00:36.983180400 +0200 +++ new/src/java.base/share/classes/java/util/ImmutableCollections.java 2019-06-26 16:00:36.064275100 +0200 @@ -35,7 +35,7 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.function.UnaryOperator; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.access.SharedSecrets; import jdk.internal.vm.annotation.Stable; /** --- old/src/java.base/share/classes/jdk/internal/misc/Unsafe.java 2019-06-26 16:00:44.279256300 +0200 +++ new/src/java.base/share/classes/jdk/internal/misc/Unsafe.java 2019-06-26 16:00:43.332288200 +0200 @@ -3726,4 +3726,27 @@ private native int getLoadAverage0(double[] loadavg, int nelems); private native boolean unalignedAccess0(); private native boolean isBigEndian0(); + + /** + * Invokes the given direct byte buffer's cleaner, if any. + * + * @param directBuffer a direct byte buffer + * @throws NullPointerException if {@code directBuffer} is null + * @throws IllegalArgumentException if {@code directBuffer} is non-direct, + * or is a {@link java.nio.Buffer#slice slice}, or is a + * {@link java.nio.Buffer#duplicate duplicate} + */ + public void invokeCleaner(java.nio.ByteBuffer directBuffer) { + if (!directBuffer.isDirect()) + throw new IllegalArgumentException("buffer is non-direct"); + + DirectBuffer db = (DirectBuffer) directBuffer; + if (db.attachment() != null) + throw new IllegalArgumentException("duplicate or slice"); + + Cleaner cleaner = db.cleaner(); + if (cleaner != null) { + cleaner.clean(); + } + } } --- old/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java 2019-06-26 16:00:51.242415900 +0200 +++ new/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java 2019-06-26 16:00:50.316173100 +0200 @@ -51,9 +51,9 @@ import jdk.internal.loader.BootLoader; import jdk.internal.loader.BuiltinClassLoader; -import jdk.internal.misc.JavaLangAccess; -import jdk.internal.misc.JavaLangModuleAccess; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.JavaLangModuleAccess; +import jdk.internal.access.SharedSecrets; import jdk.internal.perf.PerfCounter; /** --- old/src/java.desktop/share/classes/sun/applet/AppletSecurity.java 2019-06-26 16:00:58.266309700 +0200 +++ new/src/java.desktop/share/classes/sun/applet/AppletSecurity.java 2019-06-26 16:00:57.317270100 +0200 @@ -40,9 +40,9 @@ import java.util.StringTokenizer; import java.security.*; import java.lang.reflect.*; -import jdk.internal.misc.JavaNetURLClassLoaderAccess; -import jdk.internal.misc.JavaSecurityAccess; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.access.JavaNetURLClassLoaderAccess; +import jdk.internal.access.JavaSecurityAccess; +import jdk.internal.access.SharedSecrets; import sun.awt.AWTSecurityManager; import sun.awt.AppContext; import sun.awt.AWTPermissions; --- old/test/hotspot/jtreg/applications/ctw/modules/java_net_http.java 2019-06-26 16:01:05.165879700 +0200 +++ new/test/hotspot/jtreg/applications/ctw/modules/java_net_http.java 2019-06-26 16:01:04.246281100 +0200 @@ -26,7 +26,8 @@ * @summary run CTW for all classes from java.net.http module * * @library /test/lib / /testlibrary/ctw/src - * @modules java.base/jdk.internal.jimage + * @modules java.base/jdk.internal.access + * java.base/jdk.internal.jimage * java.base/jdk.internal.misc * java.base/jdk.internal.reflect * @modules java.net.http --- old/test/jdk/java/lang/ModuleLayer/BasicLayerTest.java 2019-06-26 16:01:12.091188600 +0200 +++ new/test/jdk/java/lang/ModuleLayer/BasicLayerTest.java 2019-06-26 16:01:11.170590800 +0200 @@ -24,7 +24,7 @@ /** * @test * @library /lib/testlibrary - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @build BasicLayerTest ModuleUtils * @compile layertest/Test.java * @run testng BasicLayerTest @@ -37,11 +37,10 @@ import java.lang.module.ModuleFinder; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.access.SharedSecrets; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; --- old/test/jdk/java/lang/module/ConfigurationTest.java 2019-06-26 16:01:18.876194100 +0200 +++ new/test/jdk/java/lang/module/ConfigurationTest.java 2019-06-26 16:01:17.963353500 +0200 @@ -24,7 +24,7 @@ /** * @test * @library /lib/testlibrary - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * java.base/jdk.internal.module * @build ConfigurationTest ModuleUtils * @run testng ConfigurationTest @@ -44,10 +44,9 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import java.util.Optional; import java.util.Set; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.access.SharedSecrets; import jdk.internal.module.ModuleInfoWriter; import jdk.internal.module.ModuleTarget; import org.testng.annotations.DataProvider; --- old/test/jdk/jdk/internal/reflect/constantPool/ConstantPoolTest.java 2019-06-26 16:01:25.702651500 +0200 +++ new/test/jdk/jdk/internal/reflect/constantPool/ConstantPoolTest.java 2019-06-26 16:01:24.769985700 +0200 @@ -36,9 +36,9 @@ import java.util.HashMap; import java.util.Map; -import jdk.internal.misc.SharedSecrets; -import jdk.testlibrary.Asserts; +import jdk.internal.access.SharedSecrets; import jdk.internal.reflect.ConstantPool; +import jdk.testlibrary.Asserts; public class ConstantPoolTest { --- old/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java 2019-06-26 16:01:32.439990900 +0200 +++ new/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java 2019-06-26 16:01:31.536204900 +0200 @@ -34,8 +34,8 @@ import java.util.Map; import java.util.Set; -import jdk.internal.misc.JavaLangModuleAccess; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.access.JavaLangModuleAccess; +import jdk.internal.access.SharedSecrets; import org.testng.annotations.Test; import static org.testng.Assert.*; @@ -43,7 +43,7 @@ * @test * @bug 8142968 8173381 * @library /lib/testlibrary - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/jdk.internal.module * @modules java.base/jdk.internal.org.objectweb.asm * @build ModuleTargetHelper --- /dev/null 2019-06-26 16:01:39.000000000 +0200 +++ new/src/java.base/share/classes/jdk/internal/misc/JavaSecurityAccess.java 2019-06-26 16:01:38.358882200 +0200 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2010, 2019, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.internal.misc; + +import java.security.AccessControlContext; +import java.security.PrivilegedAction; + +/** This JavaSecurityAccess stub has to be kept in jdk.internal.misc in JDK 11 to keep + * sun.reflect.ReflectionFactory::newInstanceForSerialization working after backporting + * JDK-8211122 */ +public interface JavaSecurityAccess { + T doIntersectionPrivilege(PrivilegedAction action, + AccessControlContext stack, + AccessControlContext context); +} --- /dev/null 2019-06-26 16:01:45.000000000 +0200 +++ new/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java 2019-06-26 16:01:43.689138300 +0200 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002, 2019, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.internal.misc; + +import java.security.AccessControlContext; +import java.security.PrivilegedAction; + +/** This SharedSecrets stub has to be kept in jdk.internal.misc in JDK 11 to keep + * sun.reflect.ReflectionFactory::newInstanceForSerialization working after backporting + * JDK-8211122 */ +public class SharedSecrets { + private static JavaSecurityAccess javaSecurityAccess; + + public static JavaSecurityAccess getJavaSecurityAccess() { + if (javaSecurityAccess == null) { + javaSecurityAccess = new JavaSecurityAccess() { + + private jdk.internal.access.JavaSecurityAccess theRealSecurityAccess = + jdk.internal.access.SharedSecrets.getJavaSecurityAccess(); + + @Override + public T doIntersectionPrivilege(PrivilegedAction action, AccessControlContext stack, + AccessControlContext context) { + return theRealSecurityAccess.doIntersectionPrivilege(action, stack, context); + } + }; + } + return javaSecurityAccess; + } +}