Example usage for org.objectweb.asm Opcodes ACC_STATIC

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

Introduction

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

Prototype

int ACC_STATIC

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

Click Source Link

Usage

From source file:com.gargoylesoftware.js.nashorn.internal.ir.debug.NashornTextifier.java

License:Open Source License

private static void appendAccess(final StringBuilder sb, final int access) {
    if ((access & Opcodes.ACC_PUBLIC) != 0) {
        sb.append("public ");
    }/*from  w  w  w  . j  a va 2  s .  c  o  m*/
    if ((access & Opcodes.ACC_PRIVATE) != 0) {
        sb.append("private ");
    }
    if ((access & Opcodes.ACC_PROTECTED) != 0) {
        sb.append("protected ");
    }
    if ((access & Opcodes.ACC_FINAL) != 0) {
        sb.append("final ");
    }
    if ((access & Opcodes.ACC_STATIC) != 0) {
        sb.append("static ");
    }
    if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
        sb.append("synchronized ");
    }
    if ((access & Opcodes.ACC_VOLATILE) != 0) {
        sb.append("volatile ");
    }
    if ((access & Opcodes.ACC_TRANSIENT) != 0) {
        sb.append("transient ");
    }
    if ((access & Opcodes.ACC_ABSTRACT) != 0) {
        sb.append("abstract ");
    }
    if ((access & Opcodes.ACC_STRICT) != 0) {
        sb.append("strictfp ");
    }
    if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
        sb.append("synthetic ");
    }
    if ((access & Opcodes.ACC_MANDATED) != 0) {
        sb.append("mandated ");
    }
    if ((access & Opcodes.ACC_ENUM) != 0) {
        sb.append("enum ");
    }
}

From source file:com.gargoylesoftware.js.nashorn.internal.tools.nasgen.MemberInfo.java

License:Open Source License

boolean isStatic() {
    return (javaAccess & Opcodes.ACC_STATIC) != 0;
}

From source file:com.gargoylesoftware.js.nashorn.internal.tools.nasgen.ScriptClassInfoCollector.java

License:Open Source License

@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName, final String fieldDesc,
        final String signature, final Object value) {
    final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Main.ASM_VERSION, delegateFV) {
        @Override//from ww  w .  j a v  a 2s.c  o  m
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Main.ASM_VERSION, delegateAV) {
                    // These could be "null" if values are not supplied,
                    // in which case we have to use the default values.
                    private String name;
                    private Integer attributes;
                    private String clazz = "";
                    private Where where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null ? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}

From source file:com.gargoylesoftware.js.nashorn.internal.tools.nasgen.ScriptClassInfoCollector.java

License:Open Source License

@Override
public MethodVisitor visitMethod(final int methodAccess, final String methodName, final String methodDesc,
        final String signature, final String[] exceptions) {

    final MethodVisitor delegateMV = super.visitMethod(methodAccess, methodName, methodDesc, signature,
            exceptions);/*from   w  w  w. ja v a 2s  .  c  om*/

    return new MethodVisitor(Main.ASM_VERSION, delegateMV) {

        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);
            final Kind annoKind = ScriptClassInfo.annotations.get(descriptor);

            if (annoKind != null) {
                if ((methodAccess & Opcodes.ACC_STATIC) == 0) {
                    error(methodName, methodDesc, "nasgen method annotations cannot be on instance methods");
                }

                final MemberInfo memInfo = new MemberInfo();

                // annoKind == GETTER or SPECIALIZED_FUNCTION
                memInfo.setKind(annoKind);
                memInfo.setJavaName(methodName);
                memInfo.setJavaDesc(methodDesc);
                memInfo.setJavaAccess(methodAccess);

                addScriptMember(memInfo);

                return new AnnotationVisitor(Main.ASM_VERSION, delegateAV) {
                    // These could be "null" if values are not supplied,
                    // in which case we have to use the default values.
                    private String name;
                    private Integer attributes;
                    private Integer arity;
                    private Where where;
                    private boolean isSpecializedConstructor;
                    private boolean isOptimistic;
                    private Type linkLogicClass = MethodGenerator.EMPTY_LINK_LOGIC_TYPE;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            if (name.isEmpty()) {
                                name = null;
                            }
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "arity":
                            this.arity = (Integer) annotationValue;
                            break;
                        case "isConstructor":
                            assert annoKind == Kind.SPECIALIZED_FUNCTION;
                            this.isSpecializedConstructor = (Boolean) annotationValue;
                            break;
                        case "isOptimistic":
                            assert annoKind == Kind.SPECIALIZED_FUNCTION;
                            this.isOptimistic = (Boolean) annotationValue;
                            break;
                        case "linkLogic":
                            this.linkLogicClass = (Type) annotationValue;
                            break;
                        default:
                            break;
                        }

                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        switch (enumName) {
                        case "where":
                            if (WHERE_ENUM_DESC.equals(desc)) {
                                this.where = Where.valueOf(enumValue);
                            }
                            break;
                        default:
                            break;
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @SuppressWarnings("fallthrough")
                    @Override
                    public void visitEnd() {
                        super.visitEnd();

                        if (memInfo.getKind() == Kind.CONSTRUCTOR) {
                            memInfo.setName(name == null ? scriptClassName : name);
                        } else {
                            memInfo.setName(name == null ? methodName : name);
                        }
                        memInfo.setAttributes(attributes == null ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);

                        memInfo.setArity((arity == null) ? MemberInfo.DEFAULT_ARITY : arity);
                        if (where == null) {
                            // by default @Getter/@Setter belongs to INSTANCE
                            // @Function belong to PROTOTYPE.
                            switch (memInfo.getKind()) {
                            case GETTER:
                            case SETTER:
                                where = Where.INSTANCE;
                                break;
                            case CONSTRUCTOR:
                                where = Where.CONSTRUCTOR;
                                break;
                            case FUNCTION:
                                where = Where.PROTOTYPE;
                                break;
                            case SPECIALIZED_FUNCTION:
                                where = isSpecializedConstructor ? Where.CONSTRUCTOR : Where.PROTOTYPE;
                                //fallthru
                            default:
                                break;
                            }
                        }
                        memInfo.setWhere(where);
                        memInfo.setLinkLogicClass(linkLogicClass);
                        memInfo.setIsSpecializedConstructor(isSpecializedConstructor);
                        memInfo.setIsOptimistic(isOptimistic);
                    }
                };
            }

            return delegateAV;
        }
    };
}

From source file:com.geeksaga.light.profiler.util.ASMUtil.java

License:Apache License

public static boolean isStatic(ClassNodeWrapper clazz) {
    return containsAccess(clazz, Opcodes.ACC_STATIC);
}

From source file:com.geeksaga.light.profiler.util.ASMUtil.java

License:Apache License

public static boolean isStatic(MethodNode methodNode) {
    return containsAccess(methodNode, Opcodes.ACC_STATIC);
}

From source file:com.geeksaga.light.profiler.util.ASMUtil.java

License:Apache License

public static boolean isStatic(FieldNode field) {
    return containsAccess(field, Opcodes.ACC_STATIC);
}

From source file:com.geeksaga.light.profiler.util.ASMUtil.java

License:Apache License

public static boolean isStatic(int access) {
    return containsAccess(access, Opcodes.ACC_STATIC);
}

From source file:com.github.anba.es6draft.compiler.assembler.InstructionAssembler.java

License:Open Source License

private boolean isInstanceMethod() {
    return (method.access & Opcodes.ACC_STATIC) == 0;
}

From source file:com.github.jasmo.obfuscate.FullAccessFlags.java

License:Open Source License

private int access(int access) {
    int a = Opcodes.ACC_PUBLIC;
    if ((access & Opcodes.ACC_NATIVE) != 0)
        a |= Opcodes.ACC_NATIVE;// w w  w. jav a  2 s. c om
    if ((access & Opcodes.ACC_ABSTRACT) != 0)
        a |= Opcodes.ACC_ABSTRACT;
    if ((access & Opcodes.ACC_ANNOTATION) != 0)
        a |= Opcodes.ACC_ANNOTATION;
    if ((access & Opcodes.ACC_BRIDGE) != 0)
        a |= Opcodes.ACC_BRIDGE;
    //if ((access & Opcodes.ACC_DEPRECATED) != 0) a |= Opcodes.ACC_DEPRECATED;
    if ((access & Opcodes.ACC_ENUM) != 0)
        a |= Opcodes.ACC_ENUM;
    if ((access & Opcodes.ACC_FINAL) != 0)
        a |= Opcodes.ACC_FINAL;
    if ((access & Opcodes.ACC_INTERFACE) != 0)
        a |= Opcodes.ACC_INTERFACE;
    if ((access & Opcodes.ACC_MANDATED) != 0)
        a |= Opcodes.ACC_MANDATED;
    if ((access & Opcodes.ACC_MODULE) != 0)
        a |= Opcodes.ACC_MODULE;
    if ((access & Opcodes.ACC_OPEN) != 0)
        a |= Opcodes.ACC_OPEN;
    if ((access & Opcodes.ACC_STATIC) != 0)
        a |= Opcodes.ACC_STATIC;
    if ((access & Opcodes.ACC_STATIC_PHASE) != 0)
        a |= Opcodes.ACC_STATIC_PHASE;
    if ((access & Opcodes.ACC_STRICT) != 0)
        a |= Opcodes.ACC_STRICT;
    if ((access & Opcodes.ACC_SUPER) != 0)
        a |= Opcodes.ACC_SUPER;
    if ((access & Opcodes.ACC_SYNCHRONIZED) != 0)
        a |= Opcodes.ACC_SYNCHRONIZED;
    if ((access & Opcodes.ACC_SYNTHETIC) != 0)
        a |= Opcodes.ACC_SYNTHETIC;
    if ((access & Opcodes.ACC_TRANSIENT) != 0)
        a |= Opcodes.ACC_TRANSIENT;
    if ((access & Opcodes.ACC_TRANSITIVE) != 0)
        a |= Opcodes.ACC_TRANSITIVE;
    if ((access & Opcodes.ACC_VARARGS) != 0)
        a |= Opcodes.ACC_VARARGS;
    if ((access & Opcodes.ACC_VOLATILE) != 0)
        a |= Opcodes.ACC_VOLATILE;
    return a;
}