JDK-8133111 : Method handles of outer classes are resolved via the inner class
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u51,9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-08-05
  • Updated: 2015-10-08
  • Resolved: 2015-10-08
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux raftop 3.16.0-34-generic #47-Ubuntu SMP Fri Apr 10 18:02:58 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
javac references outer classes by their inner class instance when creating a method handle within this inner class. This does not work when requiring the outer instance within a constructor call such as when calling an auxiliary constructor.

REGRESSION.  Last worked in version 8u51

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this code: https://gist.github.com/raphw/972137a8f5cdcb294c29

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should not throw an VerifierError.
ACTUAL -
Throws an VerifierError.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/leonhart/javac/issue/reproduce/Example$InnerClass.<init>(Lcom/leonhart/javac/issue/reproduce/Example;Ljava/util/function/Function;)V @4: invokedynamic
  Reason:
    Type uninitializedThis (current frame, stack[3]) is not assignable to 'com/leonhart/javac/issue/reproduce/Example$InnerClass'
  Current Frame:
    bci: @4
    flags: { flagThisUninit }
    locals: { uninitializedThis, 'com/leonhart/javac/issue/reproduce/Example', 'java/util/function/Function' }
    stack: { uninitializedThis, 'com/leonhart/javac/issue/reproduce/Example', 'java/util/function/Function', uninitializedThis }
  Bytecode:
    0x0000000: 2a2b 2c2a ba00 0100 00b9 0002 0200 b700
    0x0000010: 03b1                                   

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Run this code: https://gist.github.com/raphw/972137a8f5cdcb294c29
---------- END SOURCE ----------


Comments
I have an evolving fix for https://bugs.openjdk.java.net/browse/JDK-8129740 which also solves this problem. I'll include the reported case from here into the tests on behalf og https://bugs.openjdk.java.net/browse/JDK-8129740
08-10-2015

Likely a duplicate of https://bugs.openjdk.java.net/browse/JDK-8129740
07-10-2015

1) Run the attached test cases (Main.java) 2) Checked this on Linux and Windows 7 (64-bit) with JDK 8u45, 8u51, 8u60 ea b26 and 9 ea b75. **************************************************************************************** 8u45: FAIL 8u51: FAIL 8u60 b26: FAIL 9 ea b75: FAIL ****************************************************************************************** 3) Output with 8u51: > java Example Exception in thread "main" java.lang.VerifyError: Bad type on operand stack Exception Details: Location: Example$InnerClass.<init>(LExample;Ljava/util/function/Function;)V @4: invokedynamic Reason: Type uninitializedThis (current frame, stack[3]) is not assignable to 'Example$InnerClass' Current Frame: bci: @4 flags: { flagThisUninit } locals: { uninitializedThis, 'Example', 'java/util/function/Function' } stack: { uninitializedThis, 'Example', 'java/util/function/Function', uninitializedThis } Bytecode: 0000000: 2a2b 2c2a ba00 0100 00b9 0002 0200 c000 0000010: 03b7 0004 b1 at Example.<init>(Example.java:8) at Example.main(Example.java:23) 4) This issue is reproducible with JDK 8-all and 9 ea b75. Moving this up for further evaluation.
06-08-2015