You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/03/24 14:15:00 UTC

[jira] [Resolved] (GROOVY-5728) Accessing private constructor from a static factory

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

Eric Milles resolved GROOVY-5728.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

> Accessing private constructor from a static factory
> ---------------------------------------------------
>
>                 Key: GROOVY-5728
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5728
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.0.4, 2.4.0-beta-3
>            Reporter: Paul King
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.0-alpha-3
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The following code works fine from Java but fails in Groovy:
> {code}
> public abstract class FooMain {
>     private FooMain() {}
>     public abstract String bar();
>     public static FooMain factory() {
>       return new FooMain() {
>         public String bar() { return "xxx"; }
>       };
>     }
>     public static void main(String[] args) {
>         System.out.println(factory().bar());
>     }
> }
> // => java.lang.IllegalAccessError: tried to access method FooMain.<init>()V from class FooMain$1
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)