--- old/src/java.base/share/classes/java/lang/invoke/MethodHandles.java 2018-01-22 01:04:30.074042933 -0500 +++ new/src/java.base/share/classes/java/lang/invoke/MethodHandles.java 2018-01-22 01:04:27.905918398 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, 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 @@ -835,7 +835,7 @@ } // Allow nestmate lookups to be created without special privilege: if ((newModes & PRIVATE) != 0 - && !VerifyAccess.isSamePackageMember(this.lookupClass, requestedLookupClass)) { + && !Reflection.areNestMates(this.lookupClass, requestedLookupClass)) { newModes &= ~(PRIVATE|PROTECTED); } if ((newModes & PUBLIC) != 0 @@ -2216,17 +2216,13 @@ return "member is private to package"; } - private static final boolean ALLOW_NESTMATE_ACCESS = false; // experiment with protected nestmate access - private void checkSpecialCaller(Class specialCaller, Class refc) throws IllegalAccessException { int allowedModes = this.allowedModes; if (allowedModes == TRUSTED) return; if (!hasPrivateAccess() || (specialCaller != lookupClass() // ensure non-abstract methods in superinterfaces can be special-invoked - && !(refc != null && refc.isInterface() && refc.isAssignableFrom(specialCaller)) - && !(ALLOW_NESTMATE_ACCESS && - VerifyAccess.isSamePackageMember(specialCaller, lookupClass())))) + && !(refc != null && refc.isInterface() && refc.isAssignableFrom(specialCaller)))) throw new MemberName(specialCaller). makeAccessException("no private access for invokespecial", this); } @@ -2237,9 +2233,7 @@ if (!method.isProtected() || method.isStatic() || allowedModes == TRUSTED || method.getDeclaringClass() == lookupClass() - || VerifyAccess.isSamePackage(method.getDeclaringClass(), lookupClass()) - || (ALLOW_NESTMATE_ACCESS && - VerifyAccess.isSamePackageMember(method.getDeclaringClass(), lookupClass()))) + || VerifyAccess.isSamePackage(method.getDeclaringClass(), lookupClass())) return false; return true; } --- old/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java 2018-01-22 01:04:36.450409180 -0500 +++ new/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java 2018-01-22 01:04:34.274284187 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, 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 @@ -61,23 +61,29 @@ * the defining class should be passed for both arguments ({@code defc == refc}). *

JVM Specification, 5.4.4 "Access Control"

* A field or method R is accessible to a class or interface D if - * and only if any of the following conditions is true: