On Thu, 8 Jul 2021 02:32:45 GMT, Yi Yang <yy...@openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: 07e90524
Author:    Yi Yang <yy...@openjdk.org>
URL:       
https://git.openjdk.java.net/jdk/commit/07e90524576f159fc16523430f1db62327c89a3b
Stats:     324 lines in 3 files changed: 181 ins; 141 del; 2 mod

8270056: Generated lambda class can not access protected static method of 
target class

Co-authored-by: NekoCaffeine <nekocaffe...@qq.com>
Reviewed-by: mchung

-------------

PR: https://git.openjdk.java.net/jdk/pull/4714

Reply via email to