Java Code Examples for org.objectweb.asm.Opcodes#ASM5

The following examples show how to use org.objectweb.asm.Opcodes#ASM5 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdviceAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcode,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
    return;
  }
  mv.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
  doVisitMethodInsn(opcode, descriptor);
}
 
Example 2
Source File: InstructionAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
public void invokespecial(
    final String owner, final String name, final String descriptor, final boolean isInterface) {
  if (api < Opcodes.ASM5) {
    if (isInterface) {
      throw new IllegalArgumentException("INVOKESPECIAL on interfaces require ASM 5");
    }
    invokespecial(owner, name, descriptor);
    return;
  }
  mv.visitMethodInsn(Opcodes.INVOKESPECIAL, owner, name, descriptor, isInterface);
}
 
Example 3
Source File: InstructionAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
/**
 * Generates the instruction to call the given special method.
 *
 * @param owner the internal name of the method's owner class (see {@link
 *     Type#getInternalName()}).
 * @param name the method's name.
 * @param descriptor the method's descriptor (see {@link Type}).
 * @param isInterface if the method's owner class is an interface.
 */
public void invokespecial(
    final String owner, final String name, final String descriptor, final boolean isInterface) {
  if (api < Opcodes.ASM5) {
    if (isInterface) {
      throw new IllegalArgumentException("INVOKESPECIAL on interfaces require ASM 5");
    }
    invokespecial(owner, name, descriptor);
    return;
  }
  mv.visitMethodInsn(Opcodes.INVOKESPECIAL, owner, name, descriptor, isInterface);
}
 
Example 4
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Deprecated.
 *
 * @param owner the internal name of the method's owner class.
 * @param name the method's name.
 * @param descriptor the method's descriptor (see {@link Type}).
 * @deprecated use {@link #invokevirtual(String, String, String, boolean)} instead.
 */
@Deprecated
public void invokevirtual(final String owner, final String name, final String descriptor) {
  if (api >= Opcodes.ASM5) {
    invokevirtual(owner, name, descriptor, false);
    return;
  }
  mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, descriptor);
}
 
Example 5
Source File: InstructionAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
/**
 * Deprecated.
 *
 * @param owner the internal name of the method's owner class.
 * @param name the method's name.
 * @param descriptor the method's descriptor (see {@link Type}).
 * @deprecated use {@link #invokevirtual(String, String, String, boolean)} instead.
 */
@Deprecated
public void invokevirtual(final String owner, final String name, final String descriptor) {
  if (api >= Opcodes.ASM5) {
    invokevirtual(owner, name, descriptor, false);
    return;
  }
  mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, descriptor);
}
 
Example 6
Source File: MethodAnnotationVisitor.java    From OSRS-Deobfuscator with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MethodAnnotationVisitor(Method method, Type type)
{
	super(Opcodes.ASM5);
	
	this.method = method;
	this.type = type;
	
	annotation = new Annotation(method.getAnnotations());
	annotation.setType(type);
}
 
Example 7
Source File: MethodRemapper.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcode,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
    return;
  }
  doVisitMethodInsn(opcode, owner, name, descriptor, isInterface);
}
 
Example 8
Source File: ASMifier.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Deprecated.
 *
 * @deprecated use {@link #visitMethodInsn(int, String, String, String, boolean)} instead.
 */
@Deprecated
@Override
public void visitMethodInsn(
    final int opcode, final String owner, final String name, final String descriptor) {
  if (api >= Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor);
    return;
  }
  doVisitMethodInsn(opcode, owner, name, descriptor, opcode == Opcodes.INVOKEINTERFACE);
}
 
Example 9
Source File: CheckMethodAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Deprecated.
 *
 * @deprecated use {@link #visitMethodInsn(int, String, String, String, boolean)} instead.
 */
@Deprecated
@Override
public void visitMethodInsn(
    final int opcode, final String owner, final String name, final String descriptor) {
  if (api >= Opcodes.ASM5) {
    super.visitMethodInsn(opcode, owner, name, descriptor);
    return;
  }
  doVisitMethodInsn(opcode, owner, name, descriptor, opcode == Opcodes.INVOKEINTERFACE);
}
 
Example 10
Source File: LdcTransformUnit.java    From authlib-agent with MIT License 4 votes vote down vote up
LdcClassVisitor(ClassVisitor cv) {
	super(Opcodes.ASM5, cv);
}
 
Example 11
Source File: RemappingSignatureAdapter.java    From bytecode-viewer with GNU General Public License v3.0 4 votes vote down vote up
public RemappingSignatureAdapter(final SignatureVisitor v,
                                 final org.objectweb.asm.commons.Remapper remapper) {
    this(Opcodes.ASM5, v, remapper);
}
 
Example 12
Source File: JAXRSFieldVisitor.java    From jaxrs-analyzer with Apache License 2.0 4 votes vote down vote up
JAXRSFieldVisitor(final ClassResult classResult, final String desc, final String signature) {
    super(Opcodes.ASM5);
    this.classResult = classResult;
    this.signature = signature == null ? desc : signature;
}
 
Example 13
Source File: ASMHelper.java    From jaop with Apache License 2.0 4 votes vote down vote up
public static ClassNode getClassNode(byte[] classBytes) {
    ClassReader reader = new ClassReader(classBytes);
    ClassNode classNode = new ClassNode(Opcodes.ASM5);
    reader.accept(classNode, ClassReader.EXPAND_FRAMES);
    return classNode;
}
 
Example 14
Source File: RemappingAnnotationAdapter.java    From Concurnas with MIT License 4 votes vote down vote up
public RemappingAnnotationAdapter(final AnnotationVisitor av,
        final Remapper remapper) {
    this(Opcodes.ASM5, av, remapper);
}
 
Example 15
Source File: VersionClassVisitor.java    From OSRS-Deobfuscator with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public VersionClassVisitor()
{
	super(Opcodes.ASM5);
}
 
Example 16
Source File: YggdrasilPublicKeyTransformUnit.java    From authlib-agent with MIT License 4 votes vote down vote up
AbstractPublickeyTransformer(ClassVisitor cv) {
	super(Opcodes.ASM5, cv);
}
 
Example 17
Source File: SpecialArmorApplyVisitor.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SpecialArmorApplyVisitor(MethodVisitor mv) {
    super(Opcodes.ASM5, mv);
}
 
Example 18
Source File: RemappingMethodAdapter.java    From Concurnas with MIT License 4 votes vote down vote up
public RemappingMethodAdapter(final int access, final String desc,
        final MethodVisitor mv, final Remapper remapper) {
    this(Opcodes.ASM5, access, desc, mv, remapper);
}
 
Example 19
Source File: ByteCodeTypePrinter.java    From bazel with Apache License 2.0 4 votes vote down vote up
public TextifierExt() {
  super(Opcodes.ASM5);
}
 
Example 20
Source File: WMRouterTransform.java    From WMRouter with Apache License 2.0 4 votes vote down vote up
/**
 * 生成格式如下的代码,其中ServiceInit_xxx由注解生成器生成。
 * <pre>
 * package com.sankuai.waimai.router.generated;
 *
 * public class ServiceLoaderInit {
 *
 *     public static void init() {
 *         ServiceInit_xxx1.init();
 *         ServiceInit_xxx2.init();
 *     }
 * }
 * </pre>
 */
private void generateServiceInitClass(String directory, Set<String> classes) {

    if (classes.isEmpty()) {
        WMRouterLogger.info(GENERATE_INIT + "skipped, no service found");
        return;
    }

    try {
        WMRouterLogger.info(GENERATE_INIT + "start...");
        long ms = System.currentTimeMillis();

        ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
        ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, writer) {
        };
        String className = Const.SERVICE_LOADER_INIT.replace('.', '/');
        cv.visit(50, Opcodes.ACC_PUBLIC, className, null, "java/lang/Object", null);

        MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC,
                Const.INIT_METHOD, "()V", null, null);

        mv.visitCode();

        for (String clazz : classes) {
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazz.replace('.', '/'),
                    "init",
                    "()V",
                    false);
        }
        mv.visitMaxs(0, 0);
        mv.visitInsn(Opcodes.RETURN);
        mv.visitEnd();
        cv.visitEnd();

        File dest = new File(directory, className + SdkConstants.DOT_CLASS);
        dest.getParentFile().mkdirs();
        new FileOutputStream(dest).write(writer.toByteArray());

        WMRouterLogger.info(GENERATE_INIT + "cost %s ms", System.currentTimeMillis() - ms);

    } catch (IOException e) {
        WMRouterLogger.fatal(e);
    }
}