You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Curtis Mackie (JIRA)" <ji...@apache.org> on 2018/08/20 23:09:00 UTC
[jira] [Created] (GROOVY-8758) @WithReadLock in inner class of
@CompileStatic class causes java.lang.VerifyError
Curtis Mackie created GROOVY-8758:
-------------------------------------
Summary: @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
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)