Tabnine Logo
MethodVisitor.visitLdcInsn
Code IndexAdd Tabnine to your IDE (free)

How to use
visitLdcInsn
method
in
org.objectweb.asm.MethodVisitor

Best Java code snippets using org.objectweb.asm.MethodVisitor.visitLdcInsn (Showing top 20 results out of 1,305)

Refine searchRefine arrow

  • MethodVisitor.visitInsn
  • MethodVisitor.visitMethodInsn
origin: scouter-project/scouter

public static void PUSH(MethodVisitor mv, String value) {
  if (value == null)
    mv.visitInsn(ACONST_NULL);
  else
    mv.visitLdcInsn(value);
}
origin: CalebFenton/simplify

private void visitMethodStub(MethodVisitor mv) {
  mv.visitTypeInsn(Opcodes.NEW, "java/lang/RuntimeException");
  mv.visitInsn(Opcodes.DUP);
  mv.visitLdcInsn("Stub!");
  String owner = "java/lang/RuntimeException";
  String name = "<init>";
  String desc = "(Ljava/lang/String;)V";
  mv.visitMethodInsn(Opcodes.INVOKESPECIAL, owner, name, desc, false);
  mv.visitInsn(Opcodes.ATHROW);
}
origin: JCTools/JCTools

private static void writeRelease(MethodVisitor methodVisitor, int wOffset, int type, Class<? extends ProxyChannelRingBuffer> backendType) {
  methodVisitor.visitVarInsn(Opcodes.ALOAD, LOCALS_INDEX_THIS);
  methodVisitor.visitVarInsn(Opcodes.LLOAD, wOffset);
  methodVisitor.visitLdcInsn(type);
  methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(backendType), "writeRelease", "(JI)V", false);
}
origin: org.ow2.asm/asm

case Constants.MONITORENTER:
case Constants.MONITOREXIT:
 methodVisitor.visitInsn(opcode);
 currentOffset += 1;
 break;
 break;
case Constants.LDC:
 methodVisitor.visitLdcInsn(
   readConst(classFileBuffer[currentOffset + 1] & 0xFF, charBuffer));
 currentOffset += 2;
case Constants.LDC_W:
case Constants.LDC2_W:
 methodVisitor.visitLdcInsn(readConst(readUnsignedShort(currentOffset + 1), charBuffer));
 currentOffset += 3;
 break;
   boolean isInterface =
     classFileBuffer[cpInfoOffset - 1] == Symbol.CONSTANT_INTERFACE_METHODREF_TAG;
   methodVisitor.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
origin: pxb1988/dex2jar

  @Override
  public void handleMethodTranslateException(Method method, DexMethodNode methodNode, MethodVisitor mv, Exception e) {
    // replace the generated code with
    // 'return new RuntimeException("D2jFail translate: xxxxxxxxxxxxx");'
    StringWriter s = new StringWriter();
    s.append("d2j fail translate: ");
    e.printStackTrace(new PrintWriter(s));
    String msg = s.toString();
    mv.visitTypeInsn(Opcodes.NEW, "java/lang/RuntimeException");
    mv.visitInsn(Opcodes.DUP);
    mv.visitLdcInsn(msg);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/RuntimeException", "<init>", "(Ljava/lang/String;)V");
    mv.visitInsn(Opcodes.ATHROW);
  }
}
origin: JCTools/JCTools

private static void loadLocalIndexAndApplyDelta(MethodVisitor methodVisitor, int localVariableIndex, long delta) {
  methodVisitor.visitVarInsn(Opcodes.LLOAD, localVariableIndex);
  if (delta != 0) {
    methodVisitor.visitLdcInsn(delta);
    methodVisitor.visitInsn(Opcodes.LADD);
  }
}
origin: scouter-project/scouter

@Override
public void visitCode() {
  AsmUtil.PUSH(mv, fullname_hash);
  mv.visitLdcInsn(fullname);
  mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, START_METHOD, START_SIGNATURE, false);
  statIdx = newLocal(Type.getType(Object.class));
  mv.visitVarInsn(Opcodes.ASTORE, statIdx);
  mv.visitLabel(startFinally);
  mv.visitCode();
}
origin: pxb1988/dex2jar

  mv.visitLdcInsn(e.getKey());
  mv.visitInsn(ARETURN);
mv.visitInsn(DUP);
mv.visitLdcInsn("invalid idx");
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/RuntimeException", "<init>", "(Ljava/lang/String;)V");
mv.visitInsn(ATHROW);
mv.visitMaxs(-1, -1);
mv.visitEnd();
origin: scouter-project/scouter

public static void PUSH(MethodVisitor mv, long value) {
  if (value == 0)
    mv.visitInsn(LCONST_0);
  else if (value == 1)
    mv.visitInsn(LCONST_1);
  else
    mv.visitLdcInsn(new Long(value));
  // LDC2_W
}
origin: scouter-project/scouter

@Override
public void visitCode() {
  AsmUtil.PUSH(mv, fullname_hash);
  mv.visitLdcInsn(fullname);
  if (isStatic) {
    AsmUtil.PUSHNULL(mv);
  } else {
    mv.visitVarInsn(Opcodes.ALOAD, 0);
  }
  mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACE_SQL, START_METHOD, START_SIGNATURE, false);
  statIdx = newLocal(Type.getType(Object.class));
  mv.visitVarInsn(Opcodes.ASTORE, statIdx);
  mv.visitLabel(startFinally);
  mv.visitCode();
}
origin: alibaba/TProfiler

mv.visitInsn(Opcodes.ACONST_NULL);
mv.visitVarInsn(Opcodes.ASTORE, 30);
mv.visitInsn(Opcodes.DUP);
mv.visitVarInsn(Opcodes.ALOAD, 4);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "com/mysql/jdbc/Buffer", "getByteBuffer", "()[B");
mv.visitLdcInsn("utf-8");
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/String", "<init>", "([BLjava/lang/String;)V");
mv.visitVarInsn(Opcodes.ASTORE, 30);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/taobao/profile/Profiler", "start4Mysql", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V");
mv.visitCode();
origin: scouter-project/scouter

/**
 * @param mv
 * @param value
 */
public static void PUSH(MethodVisitor mv, double value) {
  if (value == 0)
    mv.visitInsn(DCONST_0);
  else if (value == 1)
    mv.visitInsn(DCONST_1);
  else
    mv.visitLdcInsn(new Double(value));
}
origin: glowroot/glowroot

private void addCodeForSetTransactionX(MethodVisitor mv, String templateGetterName,
    String threadContextSetterName) {
  mv.visitVarInsn(ALOAD, 0);
  mv.visitVarInsn(ALOAD, 4);
  // methodMetaInternalName is non-null when transactionNameTemplate or
  // transactionUserTemplate are non-empty
  checkNotNull(methodMetaInternalName);
  mv.visitMethodInsn(INVOKEVIRTUAL, methodMetaInternalName, templateGetterName,
      "()Lorg/glowroot/agent/bytecode/api/MessageTemplate;", false);
  mv.visitVarInsn(ALOAD, 1);
  mv.visitVarInsn(ALOAD, 2);
  mv.visitVarInsn(ALOAD, 3);
  mv.visitMethodInsn(INVOKESTATIC, "org/glowroot/agent/bytecode/api/Bytecode",
      "getMessageText",
      "(Lorg/glowroot/agent/bytecode/api/MessageTemplate;Ljava/lang/Object;"
          + "Ljava/lang/String;[Ljava/lang/Object;)"
          + "Ljava/lang/String;",
      false);
  mv.visitLdcInsn(priorityForSetters);
  mv.visitMethodInsn(INVOKEINTERFACE, "org/glowroot/agent/plugin/api/ThreadContext",
      threadContextSetterName, "(Ljava/lang/String;I)V", true);
}
origin: SpongePowered/SpongeAPI

mv.visitInsn(DUP);
mv.visitLdcInsn("A method was invoked on a dummy class, due to the static field %s not being initialized "
    + "(most likely in a CatalogType-related class).\n"
    + "Method: " + method);
mv.visitLdcInsn(1);
mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
mv.visitLdcInsn(0);
mv.visitInsn(AASTORE);
mv.visitMethodInsn(INVOKESTATIC, Type.getInternalName(String.class), "format",
  "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false);
mv.visitMethodInsn(INVOKESPECIAL, internalException, "<init>", "(Ljava/lang/String;)V", false);
mv.visitInsn(ATHROW);
mv.visitMaxs(0, 0);
mv.visitEnd();
origin: scouter-project/scouter

public static void PUSH(MethodVisitor mv, float value) {
  if (value == 0.0)
    mv.visitInsn(FCONST_0);
  else if (value == 1.0)
    mv.visitInsn(FCONST_1);
  else if (value == 2.0)
    mv.visitInsn(FCONST_2);
  else
    mv.visitLdcInsn(new Float(value));
}
origin: glowroot/glowroot

private static void loadArrayType(MethodVisitor mv, Type type, Type ownerType) {
  loadType(mv, type.getElementType(), ownerType);
  mv.visitLdcInsn(type.getDimensions());
  mv.visitMethodInsn(INVOKESTATIC, bytecodeUtilType.getInternalName(),
      "getArrayClass", "(Ljava/lang/Class;I)Ljava/lang/Class;", false);
}
origin: pxb1988/dex2jar

mv.visitInsn(DUP);
if (hasThis) {
  mv.visitVarInsn(ALOAD, 0);
  start = 1;
} else {
  mv.visitInsn(ACONST_NULL);
  start = 0;
  mv.visitInsn(ACONST_NULL);
} else {
  mv.visitLdcInsn(args.length);
  mv.visitTypeInsn(ANEWARRAY, "java/lang/Object");
  for (int i = 0; i < args.length; i++) {
    mv.visitInsn(DUP);
    mv.visitLdcInsn(i);
    mv.visitVarInsn(args[i].getOpcode(ILOAD), i + start);
    box(args[i], mv);
mv.visitLdcInsn(nextIdx);
mv.visitMethodInsn(INVOKESPECIAL, getCurrentInvocationName(), "<init>",
    "(Ljava/lang/Object;[Ljava/lang/Object;I)V");
mv.visitMethodInsn(INVOKESTATIC, toInternal(mapTo.owner), mapTo.name, mapTo.desc);
unBox(ret, Type.getReturnType(mapTo.desc), mv);
mv.visitInsn(ret.getOpcode(IRETURN));
origin: cglib/cglib

public void push(float value) {
  if (value == 0f || value == 1f || value == 2f) {
    mv.visitInsn(TypeUtils.FCONST(value));
  } else {
    mv.visitLdcInsn(new Float(value));
  }
}
public void push(double value) {
origin: glowroot/glowroot

private void addCodeForOptionalTransactionAttributes(MethodVisitor mv) {
  if (!config.transactionType().isEmpty() && !config.isTransaction()) {
    mv.visitVarInsn(ALOAD, 0);
    mv.visitLdcInsn(config.transactionType());
    mv.visitLdcInsn(priorityForSetters);
    mv.visitMethodInsn(INVOKEINTERFACE, "org/glowroot/agent/plugin/api/ThreadContext",
        "setTransactionType", "(Ljava/lang/String;I)V", true);
  for (String attrName : config.transactionAttributeTemplates().keySet()) {
    mv.visitVarInsn(ALOAD, 0);
    mv.visitLdcInsn(attrName);
    mv.visitVarInsn(ALOAD, 4);
    mv.visitMethodInsn(INVOKEVIRTUAL, methodMetaInternalName,
        "getTransactionAttributeTemplate" + i++,
        "()Lorg/glowroot/agent/bytecode/api/MessageTemplate;", false);
  if (slowThresholdMillis != null) {
    mv.visitVarInsn(ALOAD, 0);
    mv.visitLdcInsn(slowThresholdMillis.longValue());
    mv.visitFieldInsn(GETSTATIC, "java/util/concurrent/TimeUnit", "MILLISECONDS",
        "Ljava/util/concurrent/TimeUnit;");
    mv.visitLdcInsn(priorityForSetters);
    mv.visitMethodInsn(INVOKEINTERFACE, "org/glowroot/agent/plugin/api/ThreadContext",
        "setTransactionSlowThreshold", "(JLjava/util/concurrent/TimeUnit;I)V", true);
origin: pxb1988/dex2jar

  mv.visitLdcInsn(i);
  mv.visitInsn(AALOAD);
  unBox(args[i], OBJECT_TYPE, mv);
mv.visitMethodInsn(opcode, toInternal(t.owner), t.name, t.desc);
Type ret = Type.getReturnType(t.desc);
box(ret, mv);
mv.visitInsn(ARETURN);
mv.visitMaxs(-1, -1);
mv.visitEnd();
org.objectweb.asmMethodVisitorvisitLdcInsn

Javadoc

Visits a LDC instruction. Note that new constant types may be added in future versions of the Java Virtual Machine. To easily detect new constant types, implementations of this method should check for unexpected constant types, like this:
 
if (cst instanceof Integer) { 
// ... 
} else if (cst instanceof Float) { 
// ... 
} else if (cst instanceof Long) { 
// ... 
} else if (cst instanceof Double) { 
// ... 
} else if (cst instanceof String) { 
// ... 
} else if (cst instanceof Type) { 
int sort = ((Type) cst).getSort(); 
if (sort == Type.OBJECT) { 
// ... 
} else if (sort == Type.ARRAY) { 
// ... 
} else if (sort == Type.METHOD) { 
// ... 
} else { 
// throw an exception 
} 
} else if (cst instanceof Handle) { 
// ... 
} else { 
// throw an exception 
} 

Popular methods of MethodVisitor

  • visitMethodInsn
    Visits a method instruction. A method instruction is an instruction that invokes a method.
  • visitInsn
    Visits a zero operand instruction.
  • visitVarInsn
    Visits a local variable instruction. A local variable instruction is an instruction that loads or st
  • visitMaxs
    Visits the maximum stack size and the maximum number of local variables of the method.
  • visitEnd
    Visits the end of the method. This method, which is the last one to be called, is used to inform the
  • visitCode
    Starts the visit of the method's code, if any (i.e. non abstract method).
  • visitFieldInsn
    Visits a field instruction. A field instruction is an instruction that loads or stores the value of
  • visitTypeInsn
    Visits a type instruction. A type instruction is an instruction that takes the internal name of a cl
  • visitLabel
    Visits a label. A label designates the instruction that will be visited just after it.
  • visitJumpInsn
    Visits a jump instruction. A jump instruction is an instruction that may jump to another instruction
  • visitIntInsn
    Visits an instruction with a single int operand.
  • visitLocalVariable
    Visits a local variable declaration.
  • visitIntInsn,
  • visitLocalVariable,
  • visitAnnotation,
  • visitTryCatchBlock,
  • visitLineNumber,
  • visitFrame,
  • visitTableSwitchInsn,
  • visitParameterAnnotation,
  • visitIincInsn

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • Menu (java.awt)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now