Emits the synthetic $getStaticMetaClass implementation.
(final MethodVisitor mv)
| 584 | * Emits the synthetic {@code $getStaticMetaClass} implementation. |
| 585 | */ |
| 586 | @Override |
| 587 | public void visit(final MethodVisitor mv) { |
| 588 | mv.visitVarInsn(ALOAD, 0); |
| 589 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;", false); |
| 590 | if (BytecodeHelper.isClassLiteralPossible(node) || BytecodeHelper.isSameCompilationUnit(classNode, node)) { |
| 591 | BytecodeHelper.visitClassLiteral(mv, node); |
| 592 | } else { |
| 593 | mv.visitMethodInsn(INVOKESTATIC, classInternalName, "$get$$class$" + classInternalName.replace('/', '$'), "()Ljava/lang/Class;", false); |
| 594 | } |
| 595 | Label l1 = new Label(); |
| 596 | mv.visitJumpInsn(IF_ACMPEQ, l1); |
| 597 | |
| 598 | mv.visitVarInsn(ALOAD, 0); |
| 599 | mv.visitMethodInsn(INVOKESTATIC, "org/codehaus/groovy/runtime/ScriptBytecodeAdapter", "initMetaClass", "(Ljava/lang/Object;)Lgroovy/lang/MetaClass;", false); |
| 600 | mv.visitInsn(ARETURN); |
| 601 | |
| 602 | mv.visitLabel(l1); |
| 603 | |
| 604 | mv.visitFieldInsn(GETSTATIC, classInternalName, staticMetaClassFieldName, "Lorg/codehaus/groovy/reflection/ClassInfo;"); |
| 605 | mv.visitVarInsn(ASTORE, 1); |
| 606 | mv.visitVarInsn(ALOAD, 1); |
| 607 | Label l0 = new Label(); |
| 608 | mv.visitJumpInsn(IFNONNULL, l0); |
| 609 | |
| 610 | mv.visitVarInsn(ALOAD, 0); |
| 611 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;", false); |
| 612 | mv.visitMethodInsn(INVOKESTATIC, "org/codehaus/groovy/reflection/ClassInfo", "getClassInfo", "(Ljava/lang/Class;)Lorg/codehaus/groovy/reflection/ClassInfo;", false); |
| 613 | mv.visitInsn(DUP); |
| 614 | mv.visitVarInsn(ASTORE, 1); |
| 615 | mv.visitFieldInsn(PUTSTATIC, classInternalName, staticMetaClassFieldName, "Lorg/codehaus/groovy/reflection/ClassInfo;"); |
| 616 | |
| 617 | mv.visitLabel(l0); |
| 618 | |
| 619 | mv.visitVarInsn(ALOAD, 1); |
| 620 | mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/reflection/ClassInfo", "getMetaClass", "()Lgroovy/lang/MetaClass;", false); |
| 621 | mv.visitInsn(ARETURN); |
| 622 | } |
| 623 | }) |
| 624 | ); |
| 625 | } |
nothing calls this directly
no test coverage detected