[
https://issues.apache.org/jira/browse/ARIES-1724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16024906#comment-16024906
]
Thomas Watson commented on ARIES-1724:
--------------------------------------
Here is an example IllegalAccessError that Java 9 throws.
{code}
java.lang.IllegalAccessError: Update to static final field
app1.web.SomeImpl.methodFieldef495d45_ff8b_4fd0_b90f_c0fdade1aa6a attempted
from a different method (static_init_04df3c80_2877_4f6c_99e2_5a25e11d5535) than
the initializer method <clinit>
at
app1.web.SomeImpl.static_init_04df3c80_2877_4f6c_99e2_5a25e11d5535(SomeImpl.java)
at app1.web.SomeImpl.<clinit>(SomeImpl.java)
at app1.web.TestServletA.testServer1(TestServletA.java:31)
{code}
> Proxy generates calls to static methods in <clinit> which can fail on Java 9
> ----------------------------------------------------------------------------
>
> Key: ARIES-1724
> URL: https://issues.apache.org/jira/browse/ARIES-1724
> Project: Aries
> Issue Type: Bug
> Components: Proxy
> Environment: Java 9
> Reporter: Thomas Watson
>
> The issue is that the JVMS was changed in Java 9 to disallow "final" fields
> from being modified outside of the <clinit> method. Even other methods
> called by <clinit>.
> "if the field is final the instruction must occur in the < clinit > method of
> the current class. Otherwise, an IllegalAccessError is thrown."
> The issue here is that aires generates method proxies that stores references
> to the generated methods in 'private static final' fields, which it then
> assigns in woven static init weaving code by calling another generated static
> method.
> It seems that we can trivially fix this by removing the 'final' modifier of
> the generated method field.
> Here is what the current generated code would looking as a java class:
> {code:title=Foo.java|borderStyle=solid}
> public class Foo {
> static final boolean bar;
> static {
> setBar(); // blows up with IAE as of class version >= 53
> }
> static void setBar() {
> bar = true;
> }
> }
> {code}
> Where the bar field is a field declared by the proxy code and set by another
> static method which is called by the <clinit> block. A proper fix would be
> to change the generated code to do something more like this:
> {code:title=Foo.java|borderStyle=solid}
> public class Foo {
> static final boolean bar;
> static {
> bar = getBar();
> }
> static boolean getBar() {
> return true;
> }
> }
> {code}
> But as of now I am not sure how complicated of a change that would be to the
> proxy code. The simple fix is to not generate these static private fields as
> final.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)