List of usage examples for org.objectweb.asm Opcodes ACC_PRIVATE
int ACC_PRIVATE
To view the source code for org.objectweb.asm Opcodes ACC_PRIVATE.
Click Source Link
From source file:com.nginious.http.xsp.MessageTagPart.java
License:Apache License
/** * Creates bytecode in a separate method for evaluating this message tag part. * // ww w . j av a2 s. c om * @param intClassName the binary class name of the class being created * @param writer the class writer * @throws XspException if unable to create bytecode */ void compileMethod(String intClassName, ClassWriter writer) throws XspException { MethodVisitor visitor = writer.visitMethod(Opcodes.ACC_PRIVATE, this.methodName, "(Lcom/nginious/http/HttpRequest;Lcom/nginious/http/HttpResponse;Ljava/lang/StringBuffer;)V", null, null); visitor.visitCode(); if (this.var != null) { visitor.visitVarInsn(Opcodes.ALOAD, 1); var.compile(visitor, Type.STRING); } else { visitor.visitVarInsn(Opcodes.ALOAD, 3); } bundle.compile(visitor, Type.STRING); visitor.visitVarInsn(Opcodes.ALOAD, 2); visitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, "com/nginious/http/HttpResponse", "getLocale", "()Ljava/util/Locale;"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/util/ResourceBundle", "getBundle", "(Ljava/lang/String;Ljava/util/Locale;)Ljava/util/ResourceBundle;"); key.compile(visitor, Type.STRING); visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/ResourceBundle", "getString", "(Ljava/lang/String;)Ljava/lang/String;"); if (this.args != null) { try { String expression = args.getExpressionContent(); ExpressionParser parser = new ExpressionParser(); TreeExpression expr = parser.parse(expression); if (expr.getType() != Type.ANY) { throw new XspException("Expression in attribute value in args " + getName() + " is not an attribute or bean property " + " at line " + getLocationDescriptor()); } expr.compile(visitor, Type.ANY); visitor.visitTypeInsn(Opcodes.CHECKCAST, "[Ljava/lang/Object;"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/text/MessageFormat", "format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;"); } catch (ExpressionException e) { throw new XspException("Invalid expression in attribute value in tag " + getName() + " at line " + getLocationDescriptor(), e); } } if (this.var != null) { visitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, "com/nginious/http/HttpRequest", "setAttribute", "(Ljava/lang/String;Ljava/lang/Object;)V"); } else { visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); visitor.visitInsn(Opcodes.POP); } visitor.visitInsn(Opcodes.RETURN); visitor.visitMaxs(5, 5); visitor.visitEnd(); super.compileMethod(intClassName, writer); }
From source file:com.nginious.http.xsp.StaticPart.java
License:Apache License
/** * Creates bytecode in a separate method for evaluating an expression. * //from w w w. j a v a2s. c o m * @param intClassName the binary class name of the class being created * @param writer the class writer * @throws XspException if unable to create bytecode */ void compileMethod(String intClassName, ClassWriter writer) throws XspException { if (!isExpression()) { return; } try { ExpressionParser parser = new ExpressionParser(); TreeExpression expr = parser.parse(getExpressionContent()); MethodVisitor visitor = writer.visitMethod(Opcodes.ACC_PRIVATE, this.methodName, "(Ljava/lang/StringBuffer;)V", null, null); visitor.visitCode(); visitor.visitVarInsn(Opcodes.ALOAD, 1); if (expr.getType() == Type.ANY) { expr.compile(visitor, Type.STRING); } else { expr.compile(visitor); } if (expr.getType() == Type.BOOLEAN) { visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Z)Ljava/lang/StringBuffer;"); } else if (expr.getType() == Type.DOUBLE) { visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(D)Ljava/lang/StringBuffer;"); } else if (expr.getType() == Type.INT) { visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(I)Ljava/lang/StringBuffer;"); } else if (expr.getType() == Type.STRING || expr.getType() == Type.ANY) { visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); } visitor.visitInsn(Opcodes.POP); visitor.visitInsn(Opcodes.RETURN); visitor.visitMaxs(5, 5); visitor.visitEnd(); } catch (ExpressionException e) { throw new XspException("Invalid expression at " + getLocationDescriptor(), e); } }
From source file:com.poolik.classfinder.info.ClassInfo.java
License:BSD License
/** * Convert an ASM access mask to a reflection Modifier mask. * * @param asmAccessMask the ASM access mask * @return the Modifier mask//from w ww. j ava 2 s . c om */ private int convertAccessMaskToModifierMask(int asmAccessMask) { int modifier = 0; // Convert the ASM access info into Reflection API modifiers. if ((asmAccessMask & Opcodes.ACC_FINAL) != 0) modifier |= Modifier.FINAL; if ((asmAccessMask & Opcodes.ACC_NATIVE) != 0) modifier |= Modifier.NATIVE; if ((asmAccessMask & Opcodes.ACC_INTERFACE) != 0) modifier |= Modifier.INTERFACE; if ((asmAccessMask & Opcodes.ACC_ABSTRACT) != 0) modifier |= Modifier.ABSTRACT; if ((asmAccessMask & Opcodes.ACC_PRIVATE) != 0) modifier |= Modifier.PRIVATE; if ((asmAccessMask & Opcodes.ACC_PROTECTED) != 0) modifier |= Modifier.PROTECTED; if ((asmAccessMask & Opcodes.ACC_PUBLIC) != 0) modifier |= Modifier.PUBLIC; if ((asmAccessMask & Opcodes.ACC_STATIC) != 0) modifier |= Modifier.STATIC; if ((asmAccessMask & Opcodes.ACC_STRICT) != 0) modifier |= Modifier.STRICT; if ((asmAccessMask & Opcodes.ACC_SYNCHRONIZED) != 0) modifier |= Modifier.SYNCHRONIZED; if ((asmAccessMask & Opcodes.ACC_TRANSIENT) != 0) modifier |= Modifier.TRANSIENT; if ((asmAccessMask & Opcodes.ACC_VOLATILE) != 0) modifier |= Modifier.VOLATILE; return modifier; }
From source file:com.sun.fortress.runtimeSystem.InstantiatingClassloader.java
License:Open Source License
private static byte[] instantiateWrappedArrow(String name, List<String> parameters) { ManglingClassWriter cw = new ManglingClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); /*/*from w w w . j a v a2s.c o m*/ * extends AbstractArrow[\parameters\] * * private final Arrow[\Object...Object\] wrappee * * Arrow[\Object...Object\] getWrappee() * * WrappedArrow[\parameters\](Arrow[\Object...Object\] _wrappee) * * public range_parameter apply( domain_parameters ) = * (range_parameter) wrappee.apply( domain_parameters ) */ Triple<List<String>, List<String>, String> stuff = normalizeArrowParameters(parameters); List<String> flat_params_and_ret = stuff.getA(); List<String> tupled_params_and_ret = stuff.getB(); String tupleType = stuff.getC(); List<String> flat_obj_params_and_ret = Useful.applyToAll(flat_params_and_ret, toJLO); List<String> norm_obj_params_and_ret = normalizeArrowParametersAndReturn(flat_obj_params_and_ret); List<String> norm_params_and_ret = normalizeArrowParametersAndReturn(flat_params_and_ret); String extendsClass = stringListToGeneric(ABSTRACT_ARROW, norm_params_and_ret); // List<String> objectified_parameters = Useful.applyToAll(flat_params_and_ret, toJLO); //String obj_sig = stringListToGeneric("AbstractArrow", objectified_parameters); String obj_intf_sig = stringListToGeneric(Naming.ARROW_TAG, norm_obj_params_and_ret); String wrappee_name = "wrappee"; //extends AbstractArrow[\parameters\] cw.visit(JVM_BYTECODE_VERSION, ACC_PUBLIC + ACC_SUPER, name, null, extendsClass, null); // private final Arrow[\Object...Object\] wrappee cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, wrappee_name, Naming.internalToDesc(obj_intf_sig), null /* for non-generic */, null /* instance has no value */); // WrappedArrow[\parameters\](Arrow[\Object...Object\] _wrappee) MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(" + Naming.internalToDesc(obj_intf_sig) + ")V", null, null); mv.visitCode(); // super() mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, extendsClass, "<init>", "()V"); // this.wrappee = wrappee mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitFieldInsn(PUTFIELD, name, wrappee_name, Naming.internalToDesc(obj_intf_sig)); // done mv.visitInsn(RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // getWrappee mv = cw.visitMethod(ACC_PUBLIC, getWrappee, "()" + Naming.internalToDesc(obj_intf_sig), null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, name, wrappee_name, Naming.internalToDesc(obj_intf_sig)); mv.visitInsn(ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // public range_parameter apply( domain_parameters ) = // (range_parameter) wrappee.apply( domain_parameters ) String flattened_apply_sig; if (parameters.size() == 2 && parameters.get(0).equals(Naming.INTERNAL_SNOWMAN)) flattened_apply_sig = arrowParamsToJVMsig(parameters.subList(1, 2)); else flattened_apply_sig = arrowParamsToJVMsig(flat_params_and_ret); String obj_apply_sig = arrowParamsToJVMsig(flat_obj_params_and_ret); mv = cw.visitMethod(ACC_PUBLIC, Naming.APPLY_METHOD, flattened_apply_sig, null, null); mv.visitCode(); // load wrappee for delegation mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, name, wrappee_name, Naming.internalToDesc(obj_intf_sig)); // Push parameters. // i is indexed so that it corresponds to parameters pushed, even though // the types are ignored here (for now). for (int i = 0; i < flat_params_and_ret.size() - 1; i++) { String t = flat_params_and_ret.get(i); if (!t.equals(Naming.INTERNAL_SNOWMAN)) { mv.visitVarInsn(ALOAD, i + 1); } else { /* we are calling the object-interface version of this, * we need something on the stack, or else it will fail. * * This is also a naming/refactoring FAIL; this information * needs to come from somewhere else. */ mv.visitInsn(Opcodes.ACONST_NULL); // mv.visitMethodInsn(Opcodes.INVOKESTATIC, // Naming.runtimeValues + "FVoid", "make", // "()" + Naming.internalToDesc(Naming.runtimeValues + "FVoid")); } } mv.visitMethodInsn(INVOKEINTERFACE, obj_intf_sig, Naming.APPLY_METHOD, obj_apply_sig); // mv.visitTypeInsn(Opcodes.CHECKCAST, parameters.get(parameters.size()-1)); generalizedCastTo(mv, flat_params_and_ret.get(flat_params_and_ret.size() - 1)); // done mv.visitInsn(ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); //getRTTI - forwards to wrapped arrow { mv = cw.visitMethod(ACC_PUBLIC, Naming.RTTI_GETTER, "()" + Naming.RTTI_CONTAINER_DESC, null, null); mv.visitCode(); // load wrappee for delegation mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, name, wrappee_name, Naming.internalToDesc(obj_intf_sig)); //invoke interface getRTTI method mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, Naming.ANY_TYPE_CLASS, Naming.RTTI_GETTER, Naming.STATIC_PARAMETER_GETTER_SIG); mv.visitInsn(ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
From source file:com.sun.fortress.runtimeSystem.InstantiatingClassloader.java
License:Open Source License
private byte[] instantiateConcreteTuple(String dename, List<String> parameters) { /*/*ww w . ja va2 s .com*/ * extends AnyConcreteTuple[\ N \] * * implements Tuple[\ parameters \] * * defines f1 ... fN * defines e1 ... eN * defines o1 ... oN */ ManglingClassWriter cw = new ManglingClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); final int n = parameters.size(); final String any_tuple_n = ANY_TUPLE + Naming.LEFT_OXFORD + n + Naming.RIGHT_OXFORD; final String any_concrete_tuple_n = ANY_CONCRETE_TUPLE + Naming.LEFT_OXFORD + n + Naming.RIGHT_OXFORD; final String tuple_params = stringListToTuple(parameters); String[] superInterfaces = { tuple_params }; cw.visit(JVM_BYTECODE_VERSION, ACC_PUBLIC + ACC_SUPER, dename, null, any_concrete_tuple_n, superInterfaces); /* Outline of what must be generated: // fields // init method // factory method // getRTTI method // is instance method -- takes an Object // is instance method // cast method // typed getters // untyped getters */ // fields { for (int i = 0; i < n; i++) { String f = TUPLE_FIELD_PFX + (i + Naming.TUPLE_ORIGIN); String sig = Naming.internalToDesc(parameters.get(i)); cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, f, sig, null /* for non-generic */, null /* instance has no value */); } } // init method { String init_sig = tupleParamsToJvmInitSig(parameters); MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", init_sig, null, null); mv.visitCode(); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, any_concrete_tuple_n, "<init>", Naming.voidToVoid); for (int i = 0; i < n; i++) { String f = TUPLE_FIELD_PFX + (i + Naming.TUPLE_ORIGIN); String sig = Naming.internalToDesc(parameters.get(i)); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, i + 1); mv.visitFieldInsn(Opcodes.PUTFIELD, dename, f, sig); } mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); mv.visitEnd(); } // factory method -- same args as init, returns a new one. { String init_sig = tupleParamsToJvmInitSig(parameters); String make_sig = toJvmSig(parameters, Naming.javaDescForTaggedFortressType(tuple_params)); MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "make", make_sig, null, null); mv.visitCode(); // eep(mv, "before new"); mv.visitTypeInsn(NEW, dename); mv.visitInsn(DUP); // push params for init for (int i = 0; i < n; i++) { mv.visitVarInsn(Opcodes.ALOAD, i); } // eep(mv, "before init"); mv.visitMethodInsn(INVOKESPECIAL, dename, "<init>", init_sig); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); mv.visitEnd(); } // getRTTI method/field and static initialization { final String classname = dename; MethodVisitor mv = cw.visitNoMangleMethod(Opcodes.ACC_PUBLIC, // acccess Naming.RTTI_GETTER, // name Naming.STATIC_PARAMETER_GETTER_SIG, // sig null, // generics sig? null); // exceptions mv.visitCode(); mv.visitFieldInsn(GETSTATIC, classname, Naming.RTTI_FIELD, Naming.RTTI_CONTAINER_DESC); areturnEpilogue(mv); MethodVisitor imv = cw.visitMethod(ACC_STATIC, "<clinit>", Naming.voidToVoid, null, null); //taken from codegen.emitRttiField InitializedStaticField isf = new InitializedStaticField.StaticForRttiFieldOfTuple(classname, this); isf.forClinit(imv); cw.visitField(ACC_PUBLIC + ACC_STATIC + ACC_FINAL, isf.asmName(), isf.asmSignature(), null /* for non-generic */, null /* instance has no value */); imv.visitInsn(RETURN); imv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); imv.visitEnd(); } // is instance method -- takes an Object { String sig = "(Ljava/lang/Object;)Z"; MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, IS_A, sig, null, null); Label fail = new Label(); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitTypeInsn(Opcodes.INSTANCEOF, any_tuple_n); mv.visitJumpInsn(Opcodes.IFEQ, fail); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitTypeInsn(Opcodes.CHECKCAST, any_tuple_n); mv.visitMethodInsn(Opcodes.INVOKESTATIC, dename, IS_A, "(" + Naming.internalToDesc(any_tuple_n) + ")Z"); mv.visitInsn(Opcodes.IRETURN); mv.visitLabel(fail); mv.visitIntInsn(BIPUSH, 0); mv.visitInsn(Opcodes.IRETURN); mv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); mv.visitEnd(); } // is instance method -- takes an AnyTuple[\N\] { String sig = "(" + Naming.internalToDesc(any_tuple_n) + ")Z"; MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, IS_A, sig, null, null); Label fail = new Label(); for (int i = 0; i < n; i++) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(INVOKEINTERFACE, any_tuple_n, TUPLE_OBJECT_ELT_PFX + (Naming.TUPLE_ORIGIN + i), UNTYPED_GETTER_SIG); String cast_to = parameters.get(i); generalizedInstanceOf(mv, cast_to); mv.visitJumpInsn(Opcodes.IFEQ, fail); } mv.visitIntInsn(BIPUSH, 1); mv.visitInsn(Opcodes.IRETURN); mv.visitLabel(fail); mv.visitIntInsn(BIPUSH, 0); mv.visitInsn(Opcodes.IRETURN); mv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); mv.visitEnd(); } // cast method { String sig = "(" + Naming.internalToDesc(any_tuple_n) + ")" + Naming.internalToDesc(tuple_params); String make_sig = toJvmSig(parameters, Naming.javaDescForTaggedFortressType(tuple_params)); MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, CAST_TO, sig, null, null); // Get the parameters to make, and cast them. for (int i = 0; i < n; i++) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(INVOKEINTERFACE, any_tuple_n, TUPLE_OBJECT_ELT_PFX + (Naming.TUPLE_ORIGIN + i), UNTYPED_GETTER_SIG); String cast_to = parameters.get(i); generalizedCastTo(mv, cast_to); } mv.visitMethodInsn(INVOKESTATIC, dename, "make", make_sig); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); mv.visitEnd(); } // typed getters // untyped getters for (int i = 0; i < n; i++) { String untyped = TUPLE_OBJECT_ELT_PFX + (Naming.TUPLE_ORIGIN + i); String typed = TUPLE_TYPED_ELT_PFX + (Naming.TUPLE_ORIGIN + i); String field = TUPLE_FIELD_PFX + (Naming.TUPLE_ORIGIN + i); String param_type = parameters.get(i); String param_desc = Naming.internalToDesc(param_type); { MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, untyped, UNTYPED_GETTER_SIG, null, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(GETFIELD, dename, field, param_desc); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); mv.visitEnd(); } { MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, typed, "()" + param_desc, null, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(GETFIELD, dename, field, param_desc); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(Naming.ignoredMaxsParameter, Naming.ignoredMaxsParameter); mv.visitEnd(); } } cw.visitEnd(); return cw.toByteArray(); }
From source file:com.sun.tdk.jcov.instrument.DataClass.java
License:Open Source License
/** * Checks whether this class has 'private' modifier * * @return true if class is private/* w ww.ja v a 2 s .co m*/ */ public boolean hasPrivateModifier() { return (access & Opcodes.ACC_PRIVATE) != 0; }
From source file:com.sun.tdk.jcov.report.ClassCoverage.java
License:Open Source License
/** * <p> Use getAccess() method to check for more specific modifiers. * getAccess() method returns a bit-mask of org.objectweb.asm.Opcodes * constants. </p>// w ww . j a v a 2 s . com * * @return true if class is <b>public</b> * @see ClassCoverage#getAccess() */ public boolean isPrivate() { return (access & Opcodes.ACC_PRIVATE) != 0; }
From source file:cuchaz.enigma.TestJarIndexInheritanceTree.java
License:Open Source License
@Test public void access() { assertThat(index.getEntryIndex().getFieldAccess(nameField), is(new AccessFlags(Opcodes.ACC_PRIVATE))); assertThat(index.getEntryIndex().getFieldAccess(numThingsField), is(new AccessFlags(Opcodes.ACC_PRIVATE))); }
From source file:cz.vutbr.fit.xhriba01.bc.lib.Utils.java
License:Open Source License
/** * Creates text representation of asm method access flag. * /*from ww w . j a v a 2 s . c o m*/ * @param flag asm method access flag * @return formatted string representing the access flag */ public static String formatMethodAccessFlags(int flag) { List<String> accesses = new ArrayList<>(); if ((flag & Opcodes.ACC_PUBLIC) != 0) { accesses.add("public"); } if ((flag & Opcodes.ACC_PROTECTED) != 0) { accesses.add("protected"); } if ((flag & Opcodes.ACC_PRIVATE) != 0) { accesses.add("private"); } if ((flag & Opcodes.ACC_STATIC) != 0) { accesses.add("static"); } if ((flag & Opcodes.ACC_ABSTRACT) != 0) { accesses.add("abstract"); } if ((flag & Opcodes.ACC_FINAL) != 0) { accesses.add("final"); } return join(accesses.toArray(new String[accesses.size()]), " "); }
From source file:cz.vutbr.fit.xhriba01.bc.lib.Utils.java
License:Open Source License
/** * Creates text representation of asm class access flag. * //w w w. jav a 2s . co m * @param flag asm class access flag * @return formatted string representing the access flag */ public static String formatClassAccessFlags(int flag) { List<String> accesses = new ArrayList<>(); if ((flag & Opcodes.ACC_PUBLIC) != 0) { accesses.add("public"); } if ((flag & Opcodes.ACC_PROTECTED) != 0) { accesses.add("protected"); } if ((flag & Opcodes.ACC_PRIVATE) != 0) { accesses.add("private"); } if ((flag & Opcodes.ACC_STATIC) != 0) { accesses.add("static"); } if ((flag & Opcodes.ACC_ABSTRACT) != 0) { accesses.add("abstract"); } if ((flag & Opcodes.ACC_FINAL) != 0) { accesses.add("final"); } if ((flag & Opcodes.ACC_ENUM) != 0) { accesses.add("enum"); } else if ((flag & Opcodes.ACC_INTERFACE) != 0) { accesses.add("interface"); } else { accesses.add("class"); } return join(accesses.toArray(new String[accesses.size()]), " "); }