You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/08/21 05:25:00 UTC

[jira] [Commented] (GROOVY-8758) @WithReadLock in inner class of @CompileStatic class causes java.lang.VerifyError

    [ https://issues.apache.org/jira/browse/GROOVY-8758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586948#comment-16586948 ] 

ASF GitHub Bot commented on GROOVY-8758:
----------------------------------------

GitHub user paulk-asert opened a pull request:

    https://github.com/apache/groovy/pull/787

    GROOVY-8758: @WithReadLock in inner class of @CompileStatic class cau…

    …ses java.lang.VerifyError

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/paulk-asert/groovy groovy8758

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/787.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #787
    
----
commit 3e2888e0f6f76054d5a3f4a6b2a5075a28495a4d
Author: Paul King <pa...@...>
Date:   2018-08-21T05:22:21Z

    GROOVY-8758: @WithReadLock in inner class of @CompileStatic class causes java.lang.VerifyError

----


> @WithReadLock in inner class of @CompileStatic class causes java.lang.VerifyError
> ---------------------------------------------------------------------------------
>
>                 Key: GROOVY-8758
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8758
>             Project: Groovy
>          Issue Type: Bug
>          Components: bytecode, Static compilation
>    Affects Versions: 2.5.2
>         Environment: Ubuntu 18.04 x86_64, OpenJDK 10
>            Reporter: Curtis Mackie
>            Assignee: Paul King
>            Priority: Major
>
> Minimal reproduction:
> {code:java}
> import groovy.transform.CompileStatic
> import groovy.transform.WithReadLock
> @CompileStatic
> class A {
>     private class B {
>         @WithReadLock
>         int getFoo() {
>             0
>         }
>     }
>     private B b
>     A() {
>         b = new B()
>     }
> }
> def a = new A()
> {code}
> Output from groovy:
> {noformat}
> Caught: java.lang.VerifyError: Bad type on operand stack
> Exception Details:
>   Location:
>     A$B.getFoo()I @4: invokevirtual
>   Reason:
>     Type 'A' (current frame, stack[0]) is not assignable to 'java/util/concurrent/locks/ReentrantReadWriteLock$ReadLock'
>   Current Frame:
>     bci: @4
>     flags: { }
>     locals: { 'A$B' }
>     stack: { 'A' }
>   Bytecode:
>     0x0000000: 2ab4 0015 b600 2d01 5703 3c00 2ab4 0015
>     0x0000010: b600 3001 5700 1bac 0000 bf00 0000 0000
>     0x0000020: 0000 0000 0000 00bf 4d2a b400 15b6 0030
>     0x0000030: 0157 2cbf 0000 bf                      
>   Exception Handler Table:
>     bci [9, 12] => handler: 40
>     bci [22, 24] => handler: 40
>   Stackmap Table:
>     full_frame(@24,{},{Object[#51]})
>     same_locals_1_stack_item_frame(@27,Object[#51])
>     full_frame(@40,{Object[#2]},{Object[#51]})
>     full_frame(@52,{},{Object[#51]})
> java.lang.VerifyError: Bad type on operand stack
> Exception Details:
>   Location:
>     A$B.getFoo()I @4: invokevirtual
>   Reason:
>     Type 'A' (current frame, stack[0]) is not assignable to 'java/util/concurrent/locks/ReentrantReadWriteLock$ReadLock'
>   Current Frame:
>     bci: @4
>     flags: { }
>     locals: { 'A$B' }
>     stack: { 'A' }
>   Bytecode:
>     0x0000000: 2ab4 0015 b600 2d01 5703 3c00 2ab4 0015
>     0x0000010: b600 3001 5700 1bac 0000 bf00 0000 0000
>     0x0000020: 0000 0000 0000 00bf 4d2a b400 15b6 0030
>     0x0000030: 0157 2cbf 0000 bf                      
>   Exception Handler Table:
>     bci [9, 12] => handler: 40
>     bci [22, 24] => handler: 40
>   Stackmap Table:
>     full_frame(@24,{},{Object[#51]})
>     same_locals_1_stack_item_frame(@27,Object[#51])
>     full_frame(@40,{Object[#2]},{Object[#51]})
>     full_frame(@52,{},{Object[#51]})
>     at A.<init>(test.groovy:16)
>     at test.run(test.groovy:20){noformat}
> From a glance at the bytecode, it looks like Groovy is creating the $reentrantlock field in A$B as it should, but in the actual method it tries to use this$0 (i.e. the reference to the enclosing outer A object) as a ReentrantReadWriteLock instead.
> This error also occurs with @WithWriteLock, but doesn't occur with @Synchronized.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)