Hi Paul, sorry for the late response. Actually, soon after I sent the e-mail (in May) I noticed that a similar issue was tracked (GROOVY-9136). At the time I was convinced (evidently incorrectly, sorry) that the ticket described the same issue. Eventually that bug was resolved and closed in a few days with this test:
src/test/groovy/bugs/Groovy9136.groovy """ @groovy.transform.CompileStatic class Foo { public String field = 'foo' } @groovy.transform.CompileStatic class Bar { def doIt(Foo foo) { 'baz'.with { foo.field // GROOVY-9136: Access to Foo#foo is forbidden at line: -1, column: -1 } } } def bar = new Bar() def out = bar.doIt(new Foo()) assert out == 'foo' """ I was really puzzled last week when I realized that while the two problems are related there is a significant difference between the two test scripts. After further investigation I would refine the problem in this terms: *The compiler complains when inside a closure one try to access a publicfield without a getter... of an object created within the closure scope* Now, with this new insight, it's simple to modify the above test to make it fail. """ @groovy.transform.CompileStatic class Foo { public String field = 'foo' } @groovy.transform.CompileStatic class Bar { def doIt(Foo foo1) { 'baz'.with { Foo foo = new Foo() foo.field // Access to Foo#foo is forbidden @ line 10, column 17. } } } def bar = new Bar() def out = bar.doIt(new Foo()) assert out == 'foo' """ M On Mon, Jul 22, 2019 at 2:04 AM Paul King <pa...@asert.com.au> wrote: > Hi Mirco, was there an issue associated with that? > > > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Virus-free. > www.avast.com > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-4818167985729226968_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > On Mon, Jul 22, 2019 at 6:13 AM Mirco <mirch...@gmail.com> wrote: > >> Hi, >> I've tested (with Java 11) the latest beta-2 version of groovy 3 but >> unfortunately the problem I reported some weeks ago on the users mailing >> list is still in place (up until alpha-4 everything works correctly). >> The compiler complains when inside a closure one try to access a public >> field without a getter. >> For convenience I copy the same simple script to reproduce the problem: >> >> """ >> import groovy.transform.CompileStatic >> @CompileStatic >> class Foo { public float field1 = 1; } >> @CompileStatic >> class Main { >> static public void main(String... args) { >> var cl = { >> Foo foo = new Foo() >> assert foo.field1 == 1 >> } >> } >> } >> Main.main() >> """ >> >> The error logged is cryptic: >> /path/to/test.groovy: -1: Access to Foo#foo is forbidden @ line -1, column >> -1. >> >> Kind regards, >> >> M >> >> On Sun, Jul 14, 2019 at 5:39 PM Daniel.Sun <sun...@apache.org> wrote: >> >>> > Note: Apache Groovy 3.0.0-beta-2 was compiled with JDK8, so the illegal >>> access warnings will come back if you use JDK9+. >>> >>> If you want to try Groovy 3.0.0-beta-2 with JDK9+ and do not want to see >>> the >>> illegal access warnings, you can download the source code and build by >>> yourself: >>> >>> 1) Download the source code from the page: >>> >>> http://www.apache.org/dyn/closer.cgi/groovy/3.0.0-beta-2/sources/apache-groovy-src-3.0.0-beta-2.zip >>> 2) Unzip the zip file "apache-groovy-src-3.0.0-beta-2.zip" >>> 3) Run `gradle installGroovy` (Require gradle 5.5 and JDK9+ to build) >>> 4) Get the distribution from the generated directory "install" >>> >>> Cheers, >>> Daniel.Sun >>> >>> >>> >>> >>> ----- >>> Apache Groovy committer & PMC member >>> Blog: http://blog.sunlan.me >>> Twitter: @daniel_sun >>> >>> -- >>> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html >>> >>