Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
I have the following ill-typed program
import java.util.function.Supplier; public class Test { static class A { private static String m() { return null; } } public static void main(String[] args) { Supplier<String> x = A::m; } }
Actual behaviour
The compiler accepts the program, but I receive the following runtime error, because I access a private method.
Exception in thread "main" java.lang.IllegalAccessError: class Test tried to access private method 'java.lang.String Test$A.m()' (Test and Test$A are in unnamed module of loader 'app') at Test.main(groovy51.groovy:9)
Expected behavior
The program should have been rejected by the compiler.
Tested against master (commit: 191231a832efd2e2fc49391c01f8d176944d68e3)
Attachments
Attachments
Issue Links
- is related to
-
GROOVY-10687 JEP 181: replace bridge methods with nest-based access control
- Resolved
- relates to
-
GROOVY-11365 IllegalAccessError when using protected method as reference
- Resolved