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 2022/10/19 14:46:00 UTC
[jira] [Comment Edited] (GROOVY-10109) IllegalAccessError with package-access base class
[ https://issues.apache.org/jira/browse/GROOVY-10109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17620363#comment-17620363 ]
Eric Milles edited comment on GROOVY-10109 at 10/19/22 2:45 PM:
----------------------------------------------------------------
Groovy 2.5.19 picked up this bug. Our example using {{StringBuilder}} and {{AbstractStringBuilder}}:
{code:groovy}
@groovy.transform.CompileStatic
String test(String string) {
new StringBuilder().with {
int len = length()
append(string)
toString()
}
}
print test('x')
{code}
"IllegalAccessError: tried to access class java.lang.AbstractStringBuilder from class Scratch$_test_closure1"
In this case, {{StringBuilder#length()}} is a synthetic, bridge method. That is why this script started to exhibit the error in 2.5.19 -- see GROOVY-8638 and GROOVY-10120.
was (Author: emilles):
Groovy 2.5.19 picked up this bug. Our example using {{StringBuilder}} and {{AbstractStringBuilder}}:
{code:groovy}
@groovy.transform.CompileStatic
String test(String string) {
new StringBuilder().with {
int len = length()
append(string)
toString()
}
}
print test('x')
{code}
"IllegalAccessError: tried to access class java.lang.AbstractStringBuilder from class Scratch$_test_closure1"
> IllegalAccessError with package-access base class
> -------------------------------------------------
>
> Key: GROOVY-10109
> URL: https://issues.apache.org/jira/browse/GROOVY-10109
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 3.0.8, 2.5.19, 4.0.6
> Reporter: Christopher Smith
> Assignee: Eric Milles
> Priority: Major
>
> It seems that the Groovy compiler is running afoul of an interaction glitch [similar to that which appeared around the introduction of JDK 9|https://stackoverflow.com/q/36100552/1189885]: when a public class extends a package-access base class that declares public methods, the static compiler permits calling {{Derived#inheritedPublicMethod()}}, but an {{IllegalAccessError}} is produced at runtime.
> Specifically, I'm trying to use the (abandoned) Overpasser library, and I'm tripping on [{{OverpassFilterQuery#end()}}|https://github.com/zsoltk/overpasser/blob/master/library/src/main/java/hu/supercluster/overpasser/library/query/OverpassFilterQuery.java], which is the "done with this section" method of the DSL. Using it compiles fine but results in
> {code}
> java.lang.IllegalAccessError: failed to access class hu.supercluster.overpasser.library.query.AbstractOverpassSubQuery from class com.example.ThingDoer$_run_closure6 (hu.supercluster.overpasser.library.query.AbstractOverpassSubQuery and com.example.ThingDoer$_run_closure6 are in unnamed module of loader 'app')
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)