Example usage for org.objectweb.asm Opcodes ACC_NATIVE

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

Introduction

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

Prototype

int ACC_NATIVE

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

Click Source Link

Usage

From source file:net.sf.profiler4j.agent.BytecodeTransformer.java

License:Apache License

private static boolean canProfileMethod(Type classType, int access, String name, String desc, String signature,
        String[] exceptions, Config config, String globalName, String localName) {
    if (((access & Opcodes.ACC_ABSTRACT) | (access & Opcodes.ACC_NATIVE)
            | (access & Opcodes.ACC_SYNTHETIC)) != 0) {
        return false;
    }/*from  w  w  w  .  ja  v  a2 s  .  c om*/
    // if (name.equals("<init>") || name.equals("<clinit>")) {
    // return false;
    // }
    return true;
    /*List<Rule> rules = config.getRules();
    if (rules == null) {
       return false;
    }
    Rule selectedRule = null;
    for (Rule rule : rules) {
       if (rule.matches(globalName)) {
    selectedRule = rule;
    break;
       }
    }
    if (selectedRule == null) {
       return false;
    }
    if (selectedRule.getAction() == Rule.Action.ACCEPT) {
       if (selectedRule.isBooleanOptionSet(Rule.Option.BEANPROPS, config)
       && isGetterSetter(access, name, desc)) {
    return false;
       }
       boolean packageAccess = (access & 0x7) == 0;
       boolean protectedAccess = (access & Opcodes.ACC_PROTECTED) != 0;
       boolean publicAccess = (access & Opcodes.ACC_PUBLIC) != 0;
       String accessStr = selectedRule.getOption(Rule.Option.ACCESS, config);
       boolean acceptVisiblity = "private".equals(accessStr)
       || ("package".equals(accessStr) && (packageAccess || protectedAccess || publicAccess))
       || ("protected".equals(access) && (protectedAccess || publicAccess) || ("public"
       .equals(access) && publicAccess));
       return acceptVisiblity;
    }
            
    return false;   */
}

From source file:net.sf.profiler4j.agent.BytecodeTransformer.java

License:Apache License

private static boolean isGetterSetter(int flag, String name, String methodDescriptor) {
    if ((Opcodes.ACC_PUBLIC | flag) == 0 || ((Opcodes.ACC_STATIC | flag) | (Opcodes.ACC_NATIVE | flag)
            | (Opcodes.ACC_ABSTRACT | flag) | (Opcodes.ACC_SYNCHRONIZED | flag)) != 0) {
        return false;
    }//from w w  w.j a  v  a  2 s  . com
    Type[] pTypes = Type.getArgumentTypes(methodDescriptor);
    Type rType = Type.getReturnType(methodDescriptor);
    if (getterRegex.matcher(name).matches() || getterBoolRegex.matcher(name).matches()) {
        return pTypes.length == 0 && !rType.equals(Type.VOID_TYPE);
    }
    if (setterRegex.matcher(name).matches()) {
        return pTypes.length == 1 && !rType.equals(Type.VOID_TYPE);
    }
    return false;
}

From source file:org.adjective.stout.writer.ByteCodeWriter.java

License:Apache License

private int getModifierCode(Set<ElementModifier> modifiers, MemberType type) {
    int code = getModifierCode(modifiers, (Sort) null);
    int illegal = Opcodes.ACC_ANNOTATION | Opcodes.ACC_BRIDGE | Opcodes.ACC_ENUM | Opcodes.ACC_INTERFACE
            | Opcodes.ACC_SUPER;//  ww w  . j  a v a2 s.c  o  m
    switch (type) {
    case FIELD:
        illegal |= Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT | Opcodes.ACC_SYNCHRONIZED;
        break;
    case METHOD:
        if (isBitSet(Opcodes.ACC_ABSTRACT, code)) {
            illegal |= Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_STATIC
                    | Opcodes.ACC_FINAL;
        }
        break;
    }
    if (isBitSet(illegal, code)) {
        throw new IllegalStateException(
                "Illegal combination of modifier codes: " + code + " (illegal codes: " + illegal + ")");
    }
    return code;
}

From source file:org.apache.aries.versioning.utils.GenericDeclaration.java

License:Apache License

public GenericDeclaration(int access, String name, String signature) {
    int updatedAccess = access;
    // ignore the native or synchronized modifier as they do not affect binary compatibility
    if (Modifier.isNative(access)) {
        updatedAccess = updatedAccess - Opcodes.ACC_NATIVE;
    }/*from w  w  w . j a v a2s  .  c o  m*/
    if (Modifier.isSynchronized(access)) {
        updatedAccess = updatedAccess - Opcodes.ACC_SYNCHRONIZED;
    }
    this.access = access;
    this.name = name;
    this.signature = signature;
}

From source file:org.apache.commons.javaflow.providers.asm3.ContinuableClassVisitor.java

License:Apache License

public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
    final boolean skip = skipEnchancing || null == classInfo || mv == null
            || (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) > 0 || "<init>".equals(name)
            || !classInfo.isContinuableMethod(access, name, desc, signature);
    if (skip) {/* ww w . j  a v  a  2 s .  c om*/
        return mv;
    } else {
        return new ContinuableMethodNode(access, name, desc, signature, exceptions, className, cciResolver, mv);
    }
}

From source file:org.apache.tika.parser.asm.XHTMLClassVisitor.java

License:Apache License

private void writeAccess(int access) throws SAXException {
    writeAccess(access, Opcodes.ACC_PRIVATE, "private");
    writeAccess(access, Opcodes.ACC_PROTECTED, "protected");
    writeAccess(access, Opcodes.ACC_PUBLIC, "public");
    writeAccess(access, Opcodes.ACC_STATIC, "static");
    writeAccess(access, Opcodes.ACC_FINAL, "final");
    writeAccess(access, Opcodes.ACC_ABSTRACT, "abstract");
    writeAccess(access, Opcodes.ACC_SYNCHRONIZED, "synchronized");
    writeAccess(access, Opcodes.ACC_TRANSIENT, "transient");
    writeAccess(access, Opcodes.ACC_VOLATILE, "volatile");
    writeAccess(access, Opcodes.ACC_NATIVE, "native");
}

From source file:org.codehaus.groovy.antlr.AntlrParserPlugin.java

License:Apache License

protected void constructorDef(AST constructorDef) {
    List<AnnotationNode> annotations = new ArrayList<>();
    AST node = constructorDef.getFirstChild();
    int modifiers = Opcodes.ACC_PUBLIC;
    if (isType(MODIFIERS, node)) {
        modifiers = modifiers(node, annotations, modifiers);
        checkNoInvalidModifier(constructorDef, "Constructor", modifiers, Opcodes.ACC_STATIC, "static");
        checkNoInvalidModifier(constructorDef, "Constructor", modifiers, Opcodes.ACC_FINAL, "final");
        checkNoInvalidModifier(constructorDef, "Constructor", modifiers, Opcodes.ACC_ABSTRACT, "abstract");
        checkNoInvalidModifier(constructorDef, "Constructor", modifiers, Opcodes.ACC_NATIVE, "native");
        node = node.getNextSibling();/*from  ww w .  ja va  2 s .c o  m*/
    }

    assertNodeType(PARAMETERS, node);
    Parameter[] parameters = parameters(node);
    if (parameters == null)
        parameters = Parameter.EMPTY_ARRAY;
    node = node.getNextSibling();

    ClassNode[] exceptions = ClassNode.EMPTY_ARRAY;
    if (isType(LITERAL_throws, node)) {
        AST throwsNode = node.getFirstChild();
        List<ClassNode> exceptionList = new ArrayList<>();
        throwsList(throwsNode, exceptionList);
        exceptions = exceptionList.toArray(exceptions);
        node = node.getNextSibling();
    }

    assertNodeType(SLIST, node);
    boolean syntheticPublic = ((modifiers & Opcodes.ACC_SYNTHETIC) != 0);
    modifiers &= ~Opcodes.ACC_SYNTHETIC;
    ConstructorNode constructorNode = classNode.addConstructor(modifiers, parameters, exceptions, null);
    MethodNode oldMethod = methodNode;
    methodNode = constructorNode;
    Statement code = statementList(node);
    methodNode = oldMethod;
    constructorNode.setCode(code);
    constructorNode.setSyntheticPublic(syntheticPublic);
    constructorNode.addAnnotations(annotations);
    configureAST(constructorNode, constructorDef);
}

From source file:org.codehaus.groovy.antlr.AntlrParserPlugin.java

License:Apache License

protected int modifiers(AST modifierNode, List<AnnotationNode> annotations, int defaultModifiers) {
    assertNodeType(MODIFIERS, modifierNode);

    boolean access = false;
    int answer = 0;

    for (AST node = modifierNode.getFirstChild(); node != null; node = node.getNextSibling()) {
        int type = node.getType();
        switch (type) {
        case STATIC_IMPORT:
            // ignore
            break;

        // annotations
        case ANNOTATION:
            annotations.add(annotation(node));
            break;

        // core access scope modifiers
        case LITERAL_private:
            answer = setModifierBit(node, answer, Opcodes.ACC_PRIVATE);
            access = setAccessTrue(node, access);
            break;

        case LITERAL_protected:
            answer = setModifierBit(node, answer, Opcodes.ACC_PROTECTED);
            access = setAccessTrue(node, access);
            break;

        case LITERAL_public:
            answer = setModifierBit(node, answer, Opcodes.ACC_PUBLIC);
            access = setAccessTrue(node, access);
            break;

        // other modifiers
        case ABSTRACT:
            answer = setModifierBit(node, answer, Opcodes.ACC_ABSTRACT);
            break;

        case FINAL:
            answer = setModifierBit(node, answer, Opcodes.ACC_FINAL);
            break;

        case LITERAL_native:
            answer = setModifierBit(node, answer, Opcodes.ACC_NATIVE);
            break;

        case LITERAL_static:
            answer = setModifierBit(node, answer, Opcodes.ACC_STATIC);
            break;

        case STRICTFP:
            answer = setModifierBit(node, answer, Opcodes.ACC_STRICT);
            break;

        case LITERAL_synchronized:
            answer = setModifierBit(node, answer, Opcodes.ACC_SYNCHRONIZED);
            break;

        case LITERAL_transient:
            answer = setModifierBit(node, answer, Opcodes.ACC_TRANSIENT);
            break;

        case LITERAL_volatile:
            answer = setModifierBit(node, answer, Opcodes.ACC_VOLATILE);
            break;

        default://  w  ww .ja  v a 2 s. c o  m
            unknownAST(node);
        }
    }
    if (!access) {
        answer |= defaultModifiers;
        // ACC_SYNTHETIC isn't used here, use it as a special flag
        if (defaultModifiers == Opcodes.ACC_PUBLIC)
            answer |= Opcodes.ACC_SYNTHETIC;
    }
    return answer;
}

From source file:org.codehaus.groovy.eclipse.codeassist.processors.NewMethodCompletionProcessor.java

License:Apache License

private void createMethod(MethodNode method, StringBuffer completion) {
    //// Modifiers
    // flush uninteresting modifiers
    int insertedModifiers = method.getModifiers()
            & ~(Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_PUBLIC);
    ASTNode.printModifiers(insertedModifiers, completion);

    //// Type parameters
    // ignore too difficult and not really needed for Groovy

    //        GenericsType[] typeVariableBindings = method.getGenericsTypes();
    //        if(typeVariableBindings != null && typeVariableBindings.length != 0) {
    //            completion.append('<');
    //            for (int i = 0; i < typeVariableBindings.length; i++) {
    //                if(i != 0) {
    //                    completion.append(',');
    //                    completion.append(' ');
    //                }
    //                createTypeVariable(typeVariableBindings[i], completion);
    //            }
    //            completion.append('>');
    //            completion.append(' ');
    //        }//from  w w w. ja v a2s.  c  om

    //// Return type
    createType(method.getReturnType(), completion, false);
    completion.append(' ');

    //// Selector
    completion.append(method.getName());

    completion.append('(');

    ////Parameters
    Parameter[] parameters = method.getParameters();
    int length = parameters.length;
    for (int i = 0; i < length; i++) {
        if (i != 0) {
            completion.append(',');
            completion.append(' ');
        }
        createType(parameters[i].getType(), completion, true);
        completion.append(' ');
        completion.append(parameters[i].getName());
    }

    completion.append(')');

    //// Exceptions
    ClassNode[] exceptions = method.getExceptions();

    if (exceptions != null && exceptions.length > 0) {
        completion.append(' ');
        completion.append("throws");
        completion.append(' ');
        for (int i = 0; i < exceptions.length; i++) {
            if (i != 0) {
                completion.append(' ');
                completion.append(',');
            }
            createType(exceptions[i], completion, false);
        }
    }
}

From source file:org.codehaus.groovy.parser.antlr4.ASTBuilder.java

License:Apache License

/**
 * Traverse through modifiers, and combine them in one int value. Raise an error if there is multiple occurrences of same modifier.
 *
 * @param ctxList                   modifiers list.
 * @param defaultVisibilityModifier Default visibility modifier. Can be null. Applied if providen, and no visibility modifier exists in the ctxList.
 * @return tuple of int modifier and boolean flag, signalising visibility modifiers presence(true if there is visibility modifier in list, false otherwise).
 * @see #checkModifierDuplication(int, int, TerminalNode)
 *///from   www.  j  a v a2s. co m
public List<Object> parseModifiers(List<? extends GroovyLangParser.MemberModifierContext> ctxList,
        Integer defaultVisibilityModifier) {
    int modifiers = 0;
    boolean hasVisibilityModifier = false;
    for (GroovyLangParser.MemberModifierContext it : ctxList) {
        TerminalNode child = (TerminalNode) it.getChild(0);
        switch (child.getSymbol().getType()) {
        case GroovyLangLexer.KW_STATIC:
            modifiers |= checkModifierDuplication(modifiers, Opcodes.ACC_STATIC, child);
            break;
        case GroovyLangLexer.KW_ABSTRACT:
            modifiers |= checkModifierDuplication(modifiers, Opcodes.ACC_ABSTRACT, child);
            break;
        case GroovyLangLexer.KW_FINAL:
            modifiers |= checkModifierDuplication(modifiers, Opcodes.ACC_FINAL, child);
            break;
        case GroovyLangLexer.KW_NATIVE:
            modifiers |= checkModifierDuplication(modifiers, Opcodes.ACC_NATIVE, child);
            break;
        case GroovyLangLexer.KW_SYNCHRONIZED:
            modifiers |= checkModifierDuplication(modifiers, Opcodes.ACC_SYNCHRONIZED, child);
            break;
        case GroovyLangLexer.KW_TRANSIENT:
            modifiers |= checkModifierDuplication(modifiers, Opcodes.ACC_TRANSIENT, child);
            break;
        case GroovyLangLexer.KW_VOLATILE:
            modifiers |= checkModifierDuplication(modifiers, Opcodes.ACC_VOLATILE, child);
            break;
        case GroovyLangLexer.VISIBILITY_MODIFIER:
            modifiers |= parseVisibilityModifiers(child);
            hasVisibilityModifier = true;
            break;
        }
    }
    if (!hasVisibilityModifier && defaultVisibilityModifier != null)
        modifiers |= defaultVisibilityModifier;

    return new LinkedList<Object>(Arrays.asList(modifiers, hasVisibilityModifier));
}