RFR: 8270056: Generated lambda class can not access protected static method of target class [v2]
Yi Yang
yyang at openjdk.java.net
Fri Jul 9 02:28:46 UTC 2021
> Generated lambda class can not access protected static method of the target class. The following exception is thrown when executing the attached reproducible program:
>
>
> Exception in thread "main" java.lang.IllegalAccessError: class AccessProtectedStaticMethodFromSuper$B$$Lambda$15/0x0000000800b8ea48 tried to access protected method 'void AccessProtectedStaticMethodFromSuper$A.func()' (AccessProtectedStaticMethodFromSuper$B$$Lambda$15/0x0000000800b8ea48 is in unnamed module of loader AccessProtectedStaticMethodFromSuper$1Loader @71dac704; AccessProtectedStaticMethodFromSuper$A is in unnamed module of loader AccessProtectedStaticMethodFromSuper$1Loader @39ed3c8d)
> at AccessProtectedStaticMethodFromSuper.main(AccessProtectedStaticMethodFromSuper.java:51)
>
>
> This issue is similar to JDK-8254975(#767) with slight differences: generated lambda proxy calls static protected method rather than protected member method.
>
> The proposed fix 1) tries to use MethodHandle instead of invoking forwardee directly(since the lambda class has no access to the resolved method) and 2) does not force accepting an implClass as the first argument when invoking a static method.
>
> Testing:
> - test/jdk/java/ with release mode
> - presubmit tests
Yi Yang has updated the pull request incrementally with one additional commit since the last revision:
rename SuperMethodTest -> ProtectedMethodInOtherPackage; add test case within it;
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/4714/files
- new: https://git.openjdk.java.net/jdk/pull/4714/files/840e39f3..8aa4e1d7
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4714&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4714&range=00-01
Stats: 416 lines in 3 files changed: 178 ins; 238 del; 0 mod
Patch: https://git.openjdk.java.net/jdk/pull/4714.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/4714/head:pull/4714
PR: https://git.openjdk.java.net/jdk/pull/4714
More information about the core-libs-dev
mailing list