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 2020/12/08 23:32:00 UTC

[jira] [Assigned] (GROOVY-9805) Multiple assignment statements seperated by semicolons on a single line within a try catch block can lead to java.lang.VerifyError

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

Eric Milles reassigned GROOVY-9805:
-----------------------------------

    Assignee: Eric Milles

> Multiple assignment statements seperated by semicolons on a single line within a try catch block can lead to java.lang.VerifyError
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9805
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9805
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.0-rc-1, 4.0.0-alpha-1, 2.5.13, 3.0.6
>            Reporter: Matthew Donaghey
>            Assignee: Eric Milles
>            Priority: Major
>
> I've been working on upgrading Groovy from 2.4.17 to 3.0.6 and came across a snippet of code that no longer works.
> Here's an example to illustrate the issue:
> {code:java}
> def x; try { x = System.nanoTime(); x = "ok" } catch( ex ) {}{code}
> This results in the following error:
> {code:java}
> java.lang.VerifyError: Stack map does not match the one at exception handler 39
>  Exception Details:
>  Location:
>  Test.main([Ljava/lang/String;)V @39: astore
>  Reason:
>  Type 'java/lang/Object' (current frame, locals[2]) is not assignable to 'java/lang/String' (stack map, locals[2])
>  Current Frame:
>  bci: @24
>  flags: { }
>  locals: { '[Ljava/lang/String;', '[Lorg/codehaus/groovy/runtime/callsite/CallSite;', 'java/lang/Object', 'java/lang/Object' }
>  stack: { 'java/lang/Exception' }
>  Stackmap Frame:
>  bci: @39
>  flags: { }
>  locals: { '[Ljava/lang/String;', '[Lorg/codehaus/groovy/runtime/callsite/CallSite;', 'java/lang/String' }
>  stack: { 'java/lang/Exception' }
>  Bytecode:
>  0x0000000: b800 184c 014d 2c57 2b12 2532 1227 1229
>  0x0000010: b900 2f03 004e 2d4d 2d57 1231 3a04 1904
>  0x0000020: 4d19 0457 a700 093a 0500 a700 03a7 0008
>  0x0000030: 3a06 1906 bfb1 
>  Exception Handler Table:
>  bci [8, 39] => handler: 39
>  bci [8, 39] => handler: 48
>  bci [39, 42] => handler: 48
>  Stackmap Table:
>  full_frame(@39,{Object57,Object59,Object61},{Object51})
>  same_frame(@45)
>  same_locals_1_stack_item_frame(@48,Object63)
>  same_frame(@53) at java.lang.Class.getDeclaredMethods0(Native Method)
>  at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
>  at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
>  at java.lang.Class.getMethod0(Class.java:3018)
>  at java.lang.Class.getMethod(Class.java:1784)
>  at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
>  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
>  Error: A JNI error has occurred, please check your installation and try again
>  Exception in thread "main"{code}
> I've been able to refactor the code so it works in a couple of different ways. The most preferable was removing the assignment of System.nanoTime() to x as really it was unused however something strange still seems to be happening here.
> Interestingly the same code works if you provide a new line i.e:
> {code:java}
> def x; try{ x = System.nanoTime(); 
>             x = "ok" } catch( ex ) {}
> {code}
>  
> It also works if you remove the try catch block:
> {code:java}
> def x; x = System.nanoTime(); x = 'ok'{code}
> I've tested different versions of Groovy and this appears to no longer work from 2.5.0-rc-1.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)