See email discussion: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2017-May/023453.html
Summary of problem:
If we create bytecode that does a "new" but which then fails to call invokespecial with a constructor, and uses that "reference" for a monitorenter or monitorexit, the hotspot verifier does not complain. In constrast IBM's J9 fails verification with:
Exception in thread "main" java.lang.VerifyError: JVMVRFY012 stack shape
inconsistent; class=Search, method=main([Ljava/lang/String;)V, pc=6
Exception Details:
Location:
Search.main([Ljava/lang/String;)V @6: JBmonitorenter
Reason:
Type 'uninitialized' (current frame, stack[1]) is not assignable to
'java/lang/Object'
Current Frame:
bci: @6
flags: { }
locals: { 'Search', '[Ljava/lang/String;' }
stack: { 'uninitialized', 'uninitialized' }
at T.main(T.java:4)
Summary of problem:
If we create bytecode that does a "new" but which then fails to call invokespecial with a constructor, and uses that "reference" for a monitorenter or monitorexit, the hotspot verifier does not complain. In constrast IBM's J9 fails verification with:
Exception in thread "main" java.lang.VerifyError: JVMVRFY012 stack shape
inconsistent; class=Search, method=main([Ljava/lang/String;)V, pc=6
Exception Details:
Location:
Search.main([Ljava/lang/String;)V @6: JBmonitorenter
Reason:
Type 'uninitialized' (current frame, stack[1]) is not assignable to
'java/lang/Object'
Current Frame:
bci: @6
flags: { }
locals: { 'Search', '[Ljava/lang/String;' }
stack: { 'uninitialized', 'uninitialized' }
at T.main(T.java:4)
- duplicates
-
JDK-8181066 An un-initialized object can be monitored
-
- Closed
-
- relates to
-
JDK-8366271 Valhalla: verification adjustments for operations on 'uninitialized'
-
- Resolved
-
-
JDK-8180615 monitorenter on null object produces unexpected IllegalMonitorStateException
-
- Closed
-