You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (Jira)" <ji...@apache.org> on 2023/07/10 07:33:00 UTC

[jira] [Closed] (GROOVY-11120) Unexpected error when using static method of class with lower case

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

Jochen Theodorou closed GROOVY-11120.
-------------------------------------
    Resolution: Won't Fix

This is a known limitation in Groovy, which we introduced on purpose. Thus this won't be fixed. You can try "import bar.foo as Foo" and then use Foo to access the class.

> Unexpected error when using static method of class with lower case
> ------------------------------------------------------------------
>
>                 Key: GROOVY-11120
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11120
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Jochen Theodorou
>            Priority: Minor
>
> I have the following class that resides in package named "bar", and its corresponding client.
> {code}
> package bar;
> public class foo {
>   public static void create(String x) {}
> }
> // client code
> class Main {
>   static final void test() {
>     bar.foo.create("fda");
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Main.groovy: 3: Apparent variable 'bar' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
> You attempted to reference a variable in the binding or an instance variable from a static context.
> You misspelled a classname or statically imported field. Please check the spelling.
> You attempted to use a method 'bar' but left out brackets in a place not allowed by the grammar.
>  @ line 3, column 5.
>        bar.foo.create("fda");
>        ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> h3. Notes
> Tested against master
> Test case adapted from the following code that uses the javassist library.
> {code}
> class Main {
>   static final void test() throws Exception {
>     javassist.tools.framedump.main(null);
>   }
> }
> {code}



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