001package io.ebean.enhance.transactional;
002
003import io.ebean.enhance.asm.Label;
004import io.ebean.enhance.asm.MethodVisitor;
005import io.ebean.enhance.asm.commons.AdviceAdapter;
006
007import static io.ebean.enhance.common.EnhanceConstants.NOARG_VOID;
008
009/**
010 * Enhance an existing static initialisation block with a call to our static
011 * _$initProfileLocations() method.
012 */
013public class StaticInitAdapter extends AdviceAdapter {
014
015  private final String className;
016
017  StaticInitAdapter(MethodVisitor mv, int access, String name, String desc, String className) {
018    super(ASM7, mv, access, name, desc);
019    this.className = className;
020  }
021
022  /**
023  * Adds the call to the static _$initProfileLocations() method.
024  */
025  @Override
026  public void visitCode() {
027    super.visitCode();
028    Label l0 = new Label();
029    mv.visitLabel(l0);
030    mv.visitLineNumber(1, l0);
031    mv.visitMethodInsn(INVOKESTATIC, className, "_$initProfileLocations", NOARG_VOID, false);
032  }
033
034}