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

The following examples show how to use jdk.internal.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: Main.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean hasModuleTarget(InputStream in) throws IOException {
    ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
    ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
        @Override
        public void visitAttribute(Attribute attr) {
            if (attr instanceof ModuleTargetAttribute) {
                modTargets[0] = (ModuleTargetAttribute)attr;
            }
        }
    };

    // prototype of attributes that should be parsed
    Attribute[] attrs = new Attribute[] {
        new ModuleTargetAttribute()
    };

    // parse module-info.class
    ClassReader cr = new ClassReader(in);
    cr.accept(cv, attrs, 0);
    return modTargets[0] != null && modTargets[0].targetPlatform() != null;
}
 
Example 2
Source File: Printer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method instruction. See
 * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
 */
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        if (itf != (opcode == Opcodes.INVOKEINTERFACE)) {
            throw new IllegalArgumentException(
                    "INVOKESPECIAL/STATIC on interfaces require ASM 5");
        }
        visitMethodInsn(opcode, owner, name, desc);
        return;
    }
    throw new RuntimeException("Must be overriden");
}
 
Example 3
Source File: AnalyzerAdapter.java    From jdk8u-jdk 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 desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        super.visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    doVisitMethodInsn(opcode, owner, name, desc, itf);
}
 
Example 4
Source File: AnalyzerAdapter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Deprecated
@Override
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc) {
    if (api >= Opcodes.ASM5) {
        super.visitMethodInsn(opcode, owner, name, desc);
        return;
    }
    doVisitMethodInsn(opcode, owner, name, desc,
            opcode == Opcodes.INVOKEINTERFACE);
}
 
Example 5
Source File: CodeSizeEvaluator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Deprecated
@Override
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc) {
    if (api >= Opcodes.ASM5) {
        super.visitMethodInsn(opcode, owner, name, desc);
        return;
    }
    doVisitMethodInsn(opcode, owner, name, desc,
            opcode == Opcodes.INVOKEINTERFACE);
}
 
Example 6
Source File: InstructionAdapter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void invokestatic(final String owner, final String name,
        final String desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        if (itf) {
            throw new IllegalArgumentException(
                    "INVOKESTATIC on interfaces require ASM 5");
        }
        invokestatic(owner, name, desc);
        return;
    }
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, itf);
}
 
Example 7
Source File: ASMifier.java    From TencentKona-8 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 desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        super.visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    doVisitMethodInsn(opcode, owner, name, desc, itf);
}
 
Example 8
Source File: InstructionAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Deprecated
public void invokevirtual(final String owner, final String name,
        final String desc) {
    if (api >= Opcodes.ASM5) {
        invokevirtual(owner, name, desc, false);
        return;
    }
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc);
}
 
Example 9
Source File: AnalyzerAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Deprecated
@Override
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc) {
    if (api >= Opcodes.ASM5) {
        super.visitMethodInsn(opcode, owner, name, desc);
        return;
    }
    doVisitMethodInsn(opcode, owner, name, desc,
            opcode == Opcodes.INVOKEINTERFACE);
}
 
Example 10
Source File: ASMifier.java    From openjdk-jdk8u 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 desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        super.visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    doVisitMethodInsn(opcode, owner, name, desc, itf);
}
 
Example 11
Source File: CodeSizeEvaluator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public CodeSizeEvaluator(final MethodVisitor mv) {
    this(Opcodes.ASM5, mv);
}
 
Example 12
Source File: TraceAnnotationVisitor.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public TraceAnnotationVisitor(final AnnotationVisitor av, final Printer p) {
    super(Opcodes.ASM5, av);
    this.p = p;
}
 
Example 13
Source File: SignatureWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link SignatureWriter} object.
 */
public SignatureWriter() {
    super(Opcodes.ASM5);
}
 
Example 14
Source File: CodeSizeEvaluator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public CodeSizeEvaluator(final MethodVisitor mv) {
    this(Opcodes.ASM5, mv);
}
 
Example 15
Source File: TraceSignatureVisitor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public TraceSignatureVisitor(final int access) {
    super(Opcodes.ASM5);
    isInterface = (access & Opcodes.ACC_INTERFACE) != 0;
    this.declaration = new StringBuffer();
}
 
Example 16
Source File: CheckFieldAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new {@link CheckFieldAdapter}. <i>Subclasses must not use
 * this constructor</i>. Instead, they must use the
 * {@link #CheckFieldAdapter(int, FieldVisitor)} version.
 *
 * @param fv
 *            the field visitor to which this adapter must delegate calls.
 * @throws IllegalStateException
 *             If a subclass calls this constructor.
 */
public CheckFieldAdapter(final FieldVisitor fv) {
    this(Opcodes.ASM5, fv);
    if (getClass() != CheckFieldAdapter.class) {
        throw new IllegalStateException();
    }
}
 
Example 17
Source File: SignatureVisitor.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new {@link SignatureVisitor}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 */
public SignatureVisitor(final int api) {
    if (api != Opcodes.ASM4 && api != Opcodes.ASM5) {
        throw new IllegalArgumentException();
    }
    this.api = api;
}
 
Example 18
Source File: CheckMethodAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new {@link CheckMethodAdapter} object. This method adapter
 * will not perform any data flow check (see
 * {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)}).
 * <i>Subclasses must not use this constructor</i>. Instead, they must use
 * the {@link #CheckMethodAdapter(int, MethodVisitor, Map)} version.
 *
 * @param mv
 *            the method visitor to which this adapter must delegate calls.
 * @param labels
 *            a map of already visited labels (in other methods).
 * @throws IllegalStateException
 *             If a subclass calls this constructor.
 */
public CheckMethodAdapter(final MethodVisitor mv,
        final Map<Label, Integer> labels) {
    this(Opcodes.ASM5, mv, labels);
    if (getClass() != CheckMethodAdapter.class) {
        throw new IllegalStateException();
    }
}
 
Example 19
Source File: SerialVersionUIDAdder.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a new {@link SerialVersionUIDAdder}. <i>Subclasses must not use
 * this constructor</i>. Instead, they must use the
 * {@link #SerialVersionUIDAdder(int, ClassVisitor)} version.
 *
 * @param cv
 *            a {@link ClassVisitor} to which this visitor will delegate
 *            calls.
 * @throws IllegalStateException
 *             If a subclass calls this constructor.
 */
public SerialVersionUIDAdder(final ClassVisitor cv) {
    this(Opcodes.ASM5, cv);
    if (getClass() != SerialVersionUIDAdder.class) {
        throw new IllegalStateException();
    }
}
 
Example 20
Source File: NashornTextifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new {@link NashornTextifier}. <i>Subclasses must not use this
 * constructor</i>. Instead, they must use the {@link #NashornTextifier(int)}
 * version.
 * @param env script environment
 * @param cr a customized classreader for gathering, among other things, label
 * information
 */
public NashornTextifier(final ScriptEnvironment env, final NashornClassReader cr) {
    this(Opcodes.ASM5);
    this.env = env;
    this.cr = cr;
}