Example usage for org.objectweb.asm Opcodes ACC_SYNTHETIC

List of usage examples for org.objectweb.asm Opcodes ACC_SYNTHETIC

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ACC_SYNTHETIC.

Prototype

int ACC_SYNTHETIC

To view the source code for org.objectweb.asm Opcodes ACC_SYNTHETIC.

Click Source Link

Usage

From source file:org.jacoco.core.runtime.InjectedClassRuntime.java

License:Open Source License

private static byte[] createClass(final String name) {
    final ClassWriter cw = new ClassWriter(0);
    cw.visit(Opcodes.V9, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_PUBLIC, name.replace('.', '/'), null,
            "java/lang/Object", null);
    cw.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, FIELD_NAME, FIELD_TYPE, null, null);
    cw.visitEnd();/*from   w  w  w.j a v a2  s  .  co  m*/
    return cw.toByteArray();
}

From source file:org.jacoco.core.runtime.ModifiedSystemClassRuntime.java

License:Open Source License

private static void createDataField(final ClassVisitor visitor, final String dataField) {
    visitor.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_TRANSIENT,
            dataField, ACCESS_FIELD_TYPE, null, null);
}

From source file:org.jboss.byteman.agent.adapter.AccessCheckAdapter.java

License:Open Source License

public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature,
        final String[] exceptions) {
    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
    if ((access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC)) == 0
            && matchTargetMethod(name, desc)) {
        setVisited();/* w  ww.  ja va 2  s.  co  m*/
        return new AccessCheckMethodAdapter(mv, getTransformContext(), access, name, desc, signature,
                exceptions);
    }

    return mv;
}

From source file:org.jboss.byteman.agent.TransformContext.java

License:Open Source License

public boolean matchTargetMethod(int access, String name, String desc) {
    return ((access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC)) == 0
            && targetMethodName.equals(name)
            && (targetDescriptor.equals("") || TypeHelper.equalDescriptors(targetDescriptor, desc)));
}

From source file:org.jooby.internal.apitool.BytecodeRouteParser.java

License:Apache License

@SuppressWarnings("unchecked")
private List<Object> lambdas(final ClassLoader loader, final ClassNode owner) {
    List compiled = read(owner.name);
    if (compiled != null) {
        return compiled;
    }/*from   ww  w  .j av  a 2s  .  c  om*/

    if (owner.sourceFile.endsWith(".kt")) {
        return kotlinSource(loader, owner);
    } else {
        List<MethodNode> methods = owner.methods;
        List<Object> handles = methods.stream().filter(access(Opcodes.ACC_SYNTHETIC).negate())
                .flatMap(method -> lambdas(loader, owner, method).stream()).collect(Collectors.toList());
        return handles;
    }
}

From source file:org.jooby.internal.apitool.Filters.java

License:Apache License

public static Predicate<MethodNode> kotlinRouteHandler() {
    return is(MethodNode.class).and(m -> {
        return (m.name.equals("invoke") || m.name.equals("handle"))
                && ((m.access & Opcodes.ACC_SYNTHETIC) == 0);
    });//from  ww w .  jav  a  2  s. co  m
}

From source file:org.jruby.compiler.impl.StandardInvocationCompiler.java

License:LGPL

public void invokeDynamicSelfNoBlockSpecificArity(String name, ArgumentsCallback argsCallback) {
    methodCompiler.loadThis();//from   w w w  . ja  v a2s  .c  om
    methodCompiler.loadThreadContext();
    methodCompiler.loadSelf();
    argsCallback.call(methodCompiler);
    String thisClass = methodCompiler.getScriptCompiler().getClassname();
    String signature1;
    switch (argsCallback.getArity()) {
    case 1:
        signature1 = sig(IRubyObject.class, "L" + thisClass + ";", ThreadContext.class, IRubyObject.class,
                IRubyObject.class);
        break;
    case 2:
        signature1 = sig(IRubyObject.class, "L" + thisClass + ";", ThreadContext.class, IRubyObject.class,
                IRubyObject.class, IRubyObject.class);
        break;
    case 3:
        signature1 = sig(IRubyObject.class, "L" + thisClass + ";", ThreadContext.class, IRubyObject.class,
                IRubyObject.class, IRubyObject.class, IRubyObject.class);
        break;
    default:
        throw new RuntimeException("invalid arity for inline dyncall: " + argsCallback.getArity());
    }
    String synthMethodName = methodCompiler.getNativeMethodName() + "$call"
            + methodCompiler.getScriptCompiler().getAndIncrementMethodIndex();
    SkinnyMethodAdapter m2 = new SkinnyMethodAdapter(methodCompiler.getScriptCompiler().getClassVisitor(),
            Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, synthMethodName, signature1, null,
            null);
    method.invokestatic(thisClass, synthMethodName, signature1);

    SkinnyMethodAdapter oldMethod = methodCompiler.method;
    methodCompiler.method = m2;
    m2.start();
    methodCompiler.getScriptCompiler().getCacheCompiler().cacheMethod(methodCompiler, name);
    m2.aload(1); // ThreadContext
    m2.aload(2); // receiver
    m2.aload(2); // receiver
    m2.invokeinterface(p(IRubyObject.class), "getMetaClass", sig(RubyClass.class));
    m2.ldc(name);

    String signature2;
    switch (argsCallback.getArity()) {
    case 1:
        signature2 = sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, RubyModule.class,
                String.class, IRubyObject.class);
        m2.aload(3);
        break;
    case 2:
        signature2 = sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, RubyModule.class,
                String.class, IRubyObject.class, IRubyObject.class);
        m2.aload(3);
        m2.aload(4);
        break;
    case 3:
        signature2 = sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, RubyModule.class,
                String.class, IRubyObject.class, IRubyObject.class, IRubyObject.class);
        m2.aload(3);
        m2.aload(4);
        m2.aload(5);
        break;
    default:
        throw new RuntimeException("invalid arity for inline dyncall: " + argsCallback.getArity());
    }
    m2.invokevirtual(p(DynamicMethod.class), "call", signature2);
    m2.areturn();
    m2.end();
    methodCompiler.method = oldMethod;
}

From source file:org.kantega.dogmaticmvc.mutation.MutationClassVisitor.java

License:Apache License

@Override
public MethodVisitor visitMethod(int i, String name, String s1, String s2, String[] strings) {
    final MethodVisitor superVisitor = super.visitMethod(i, name, s1, s2, strings);
    if (name.contains("<") || name.contains("$") || (i & Opcodes.ACC_SYNTHETIC) != 0) {
        return superVisitor;
    }//from   www . j a  v a 2s . co m
    return new MutationMethodVisitor(superVisitor, this);
}

From source file:org.mbte.groovypp.compiler.PresentationUtil.java

License:Apache License

public static String getText(ClassNode type) {
    StringBuilder builder = new StringBuilder();
    if (type instanceof ClosureClassNode) {
        builder.append("{ ");
        Parameter[] parameters = ((ClosureClassNode) type).getDoCallMethod().getParameters();
        for (int i = 0; i < parameters.length; i++) {
            if (i > 0)
                builder.append(", ");
            getText(parameters[i].getType(), builder);
        }//from  w ww  .j  a  v  a 2  s  .  c  om
        builder.append(" -> ...}");
    } else {
        if ((type.getModifiers() & Opcodes.ACC_SYNTHETIC) != 0) {
            // This is synthetic closure node, present its super type.
            if (type.getInterfaces().length > 0) {
                type = type.getInterfaces()[0];
            } else if (type.getSuperClass() != null) {
                type = type.getSuperClass();
            }
        }
        getText(type, builder);
    }
    return builder.toString();
}

From source file:org.mbte.groovypp.compiler.TypeUtil.java

License:Apache License

public static MethodNode getReferenceUnboxingMethod(ClassNode classNode) {
    if (classNode instanceof ClosureClassNode || (classNode.getModifiers() & Opcodes.ACC_SYNTHETIC) != 0
            || ClassHelper.isPrimitiveType(classNode))
        return null;
    if (!isTransparentClass(classNode))
        return null;
    MethodNode method = MethodSelection.findPublicMethodInClass(classNode, "get", new ClassNode[0]);
    return method != null && method.getParameters().length == 0
            && !method.getReturnType().equals(ClassHelper.VOID_TYPE) ? method : null;
}