[jira] [Resolved] (ARIES-1724) Proxy generates calls to static methods in <clinit> which can fail on Java 9

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jira] [Resolved] (ARIES-1724) Proxy generates calls to static methods in <clinit> which can fail on Java 9

JIRA jira@apache.org

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

Thomas Watson resolved ARIES-1724.
----------------------------------
    Resolution: Fixed

> 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
>            Assignee: 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)
Loading...