[ 
https://issues.apache.org/jira/browse/GROOVY-11274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles resolved GROOVY-11274.
----------------------------------
    Fix Version/s: 5.0.0-alpha-11
       Resolution: Fixed

https://github.com/apache/groovy/commit/aa298337dadd8a10053897e397cd83377127ca27

> Not reporting error when implicit default constructor is private
> ----------------------------------------------------------------
>
>                 Key: GROOVY-11274
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11274
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 5.0.0-alpha-11
>
>
> I have the following ill-typed program:
> {code}
> public class Main {
>   public static void main(String[] args) {
>     var x = new Foo(1);
>   }
> }
> class Foo extends Bar {
>   Foo(int p0){ }
> }
> class Bar {
>   Bar(int x){ }
>   private Bar(){ }
> }
> {code}
> h3. Actual behavior
> The code compiles, but I receive the following error at runtime
> {code}
> Caught: java.lang.IllegalAccessError: class Foo tried to access private 
> method 'void Bar.<init>()' (Foo and Bar are in unnamed module of loader 
> groovy.lang.GroovyClassLoader$InnerLoader @266374ef)
> java.lang.IllegalAccessError: class Foo tried to access private method 'void 
> Bar.<init>()' (Foo and Bar are in unnamed module of loader 
> groovy.lang.GroovyClassLoader$InnerLoader @266374ef)
>         at Foo.<init>(test.groovy:8)
>         at Main.main(test.groovy:3)
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
>         at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
>         at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> {code}
> h3. Expected behavior
> The code should be rejected, as the implicit default constructor of Bar is 
> private.
> Tested against master (commit: 3cd76364f772250324f5729ef93ffd76fbdd2b79)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to