hg: valhalla/valhalla: [nestmates] Lambda proxy uses live MethodHandle for a protected member inherited from its superclass in a different package.

mandy.chung at oracle.com mandy.chung at oracle.com
Fri Feb 21 20:05:34 UTC 2020


Changeset: f796bd335b45
Author:    mchung
Date:      2020-02-21 12:03 -0800
URL:       https://hg.openjdk.java.net/valhalla/valhalla/rev/f796bd335b45

[nestmates] Lambda proxy uses live MethodHandle for a protected member inherited from its superclass in a different package.
Summary: class C attempts to access a protected member D::m inherited from
its supertype in a different package. The lambda proxy class HC is not a subtype
of D and D::m is not inaccessible to HC.  C may not necessarily have the bridge
for example D::m was public member when C was compiled and later D::m is changed
from public to protected in a separation compilation.  D::m is accessible to C
with a receiver object of C.  Changing D::m to protected is a supported binary
compatibility.  JDK-8199386 should be explored as a long-term solution that
a framework can use Lookup::in to teleport from HC to C to obtain a method
handle for D::m.

! src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
! src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
! src/java.base/share/classes/java/lang/invoke/MethodHandles.java
+ test/jdk/java/lang/invoke/lambda/superProtectedMethod/InheritedProtectedMethod.java
! test/jdk/java/lang/invoke/lambda/superProtectedMethod/SuperMethodTest.java
+ test/jdk/java/lang/invoke/lambda/superProtectedMethod/modified/MethodSupplierOuter.java
+ test/jdk/java/lang/invoke/lambda/superProtectedMethod/src/MethodInvoker.java
+ test/jdk/java/lang/invoke/lambda/superProtectedMethod/src/MyFunctionalInterface.java
+ test/jdk/java/lang/invoke/lambda/superProtectedMethod/src/anotherpkg/MethodSupplierOuter.java



More information about the valhalla-dev mailing list