Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
None
-
None
-
None
-
None
Description
Currently, interface default methods are implemented using traits, i.e. the implementation is not native interface default methods. We must refine the implementation before 3.0.0 final released.
As MOP needs to additional methods like the following, some of which are private, so we maybe have to generate bytecode of Java9+ version. As a result, Java9+ is required to run.
// access flags 0x1004 protected synthetic $getStaticMetaClass()Lgroovy/lang/MetaClass; ALOAD 0 INVOKEVIRTUAL java/lang/Object.getClass ()Ljava/lang/Class; LDC LA;.class IF_ACMPEQ L0 ALOAD 0 INVOKESTATIC org/codehaus/groovy/runtime/ScriptBytecodeAdapter.initMetaClass (Ljava/lang/Object;)Lgroovy/lang/MetaClass; ARETURN L0 FRAME SAME GETSTATIC A.$staticClassInfo : Lorg/codehaus/groovy/reflection/ClassInfo; ASTORE 1 ALOAD 1 IFNONNULL L1 ALOAD 0 INVOKEVIRTUAL java/lang/Object.getClass ()Ljava/lang/Class; INVOKESTATIC org/codehaus/groovy/reflection/ClassInfo.getClassInfo (Ljava/lang/Class;)Lorg/codehaus/groovy/reflection/ClassInfo; DUP ASTORE 1 PUTSTATIC A.$staticClassInfo : Lorg/codehaus/groovy/reflection/ClassInfo; L1 FRAME APPEND [org/codehaus/groovy/reflection/ClassInfo] ALOAD 1 INVOKEVIRTUAL org/codehaus/groovy/reflection/ClassInfo.getMetaClass ()Lgroovy/lang/MetaClass; ARETURN MAXSTACK = 2 MAXLOCALS = 2 // access flags 0x1 public getMetaClass()Lgroovy/lang/MetaClass; @Lgroovy/transform/Generated;() @Lgroovy/transform/Internal;() ALOAD 0 GETFIELD A.metaClass : Lgroovy/lang/MetaClass; DUP IFNULL L0 ARETURN L0 FRAME SAME1 groovy/lang/MetaClass POP ALOAD 0 DUP INVOKEVIRTUAL A.$getStaticMetaClass ()Lgroovy/lang/MetaClass; PUTFIELD A.metaClass : Lgroovy/lang/MetaClass; ALOAD 0 GETFIELD A.metaClass : Lgroovy/lang/MetaClass; ARETURN MAXSTACK = 2 MAXLOCALS = 1 // access flags 0x1 public setMetaClass(Lgroovy/lang/MetaClass;)V @Lgroovy/transform/Generated;() @Lgroovy/transform/Internal;() ALOAD 0 ALOAD 1 PUTFIELD A.metaClass : Lgroovy/lang/MetaClass; RETURN MAXSTACK = 2 MAXLOCALS = 2 // access flags 0x1 public invokeMethod(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; @Lgroovy/transform/Generated;() @Lgroovy/transform/Internal;() ALOAD 0 INVOKEVIRTUAL A.getMetaClass ()Lgroovy/lang/MetaClass; ALOAD 0 ALOAD 1 ALOAD 2 INVOKEINTERFACE groovy/lang/MetaClass.invokeMethod (Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; (itf) ARETURN MAXSTACK = 4 MAXLOCALS = 3 // access flags 0x1 public getProperty(Ljava/lang/String;)Ljava/lang/Object; @Lgroovy/transform/Generated;() @Lgroovy/transform/Internal;() ALOAD 0 INVOKEVIRTUAL A.getMetaClass ()Lgroovy/lang/MetaClass; ALOAD 0 ALOAD 1 INVOKEINTERFACE groovy/lang/MetaClass.getProperty (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object; (itf) ARETURN MAXSTACK = 3 MAXLOCALS = 2 // access flags 0x1 public setProperty(Ljava/lang/String;Ljava/lang/Object;)V @Lgroovy/transform/Generated;() @Lgroovy/transform/Internal;() ALOAD 0 INVOKEVIRTUAL A.getMetaClass ()Lgroovy/lang/MetaClass; ALOAD 0 ALOAD 1 ALOAD 2 INVOKEINTERFACE groovy/lang/MetaClass.setProperty (Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V (itf) RETURN MAXSTACK = 4 MAXLOCALS = 3 // access flags 0x100A private static synthetic $createCallSiteArray_1([Ljava/lang/String;)V ALOAD 0 LDC 0 LDC "println" AASTORE RETURN MAXSTACK = 3 MAXLOCALS = 1 // access flags 0x100A private static synthetic $createCallSiteArray()Lorg/codehaus/groovy/runtime/callsite/CallSiteArray; LDC 1 ANEWARRAY java/lang/String ASTORE 0 ALOAD 0 INVOKESTATIC A.$createCallSiteArray_1 ([Ljava/lang/String;)V NEW org/codehaus/groovy/runtime/callsite/CallSiteArray DUP LDC LA;.class ALOAD 0 INVOKESPECIAL org/codehaus/groovy/runtime/callsite/CallSiteArray.<init> (Ljava/lang/Class;[Ljava/lang/String;)V ARETURN MAXSTACK = 4 MAXLOCALS = 1 // access flags 0x100A private static synthetic $getCallSiteArray()[Lorg/codehaus/groovy/runtime/callsite/CallSite; GETSTATIC A.$callSiteArray : Ljava/lang/ref/SoftReference; IFNULL L0 GETSTATIC A.$callSiteArray : Ljava/lang/ref/SoftReference; INVOKEVIRTUAL java/lang/ref/SoftReference.get ()Ljava/lang/Object; CHECKCAST org/codehaus/groovy/runtime/callsite/CallSiteArray DUP ASTORE 0 IFNONNULL L1 L0 FRAME SAME INVOKESTATIC A.$createCallSiteArray ()Lorg/codehaus/groovy/runtime/callsite/CallSiteArray; ASTORE 0 NEW java/lang/ref/SoftReference DUP ALOAD 0 INVOKESPECIAL java/lang/ref/SoftReference.<init> (Ljava/lang/Object;)V PUTSTATIC A.$callSiteArray : Ljava/lang/ref/SoftReference; L1 FRAME APPEND [org/codehaus/groovy/runtime/callsite/CallSiteArray] ALOAD 0 GETFIELD org/codehaus/groovy/runtime/callsite/CallSiteArray.array : [Lorg/codehaus/groovy/runtime/callsite/CallSite; ARETURN MAXSTACK = 3 MAXLOCALS = 1
Attachments
Issue Links
- is related to
-
GROOVY-8299 Generate bytecode for interface with default, private and static methods
- Closed