Java Code Examples for org.objectweb.asm.Opcodes#ACC_SYNCHRONIZED
The following examples show how to use
org.objectweb.asm.Opcodes#ACC_SYNCHRONIZED .
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: ClassInfo.java From ModTheSpire with MIT License | 6 votes |
/** * Convert an ASM access mask to a reflection Modifier mask. * * @param asmAccessMask the ASM access mask * * @return the Modifier mask */ 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; }
Example 2
Source File: JavaStubGenerator.java From groovy with Apache License 2.0 | 6 votes |
private static void printModifiers(PrintWriter out, int modifiers) { if ((modifiers & Opcodes.ACC_PUBLIC) != 0) out.print("public "); if ((modifiers & Opcodes.ACC_PROTECTED) != 0) out.print("protected "); if ((modifiers & Opcodes.ACC_PRIVATE) != 0) out.print("private "); if ((modifiers & Opcodes.ACC_STATIC) != 0) out.print("static "); if ((modifiers & Opcodes.ACC_SYNCHRONIZED) != 0) out.print("synchronized "); if ((modifiers & Opcodes.ACC_FINAL) != 0) out.print("final "); if ((modifiers & Opcodes.ACC_ABSTRACT) != 0) out.print("abstract "); }
Example 3
Source File: SerialVersionUIDAdder.java From Concurnas with MIT License | 5 votes |
@Override public MethodVisitor visitMethod( final int access, final String name, final String descriptor, final String signature, final String[] exceptions) { // Get constructor and method information (step 5 and 7). Also determine if there is a class // initializer (step 6). if (computeSvuid) { if (CLINIT.equals(name)) { hasStaticInitializer = true; } // Collect the non private constructors and methods. Only the ACC_PUBLIC, ACC_PRIVATE, // ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and // ACC_STRICT flags are used. int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT); if ((access & Opcodes.ACC_PRIVATE) == 0) { if ("<init>".equals(name)) { svuidConstructors.add(new Item(name, mods, descriptor)); } else if (!CLINIT.equals(name)) { svuidMethods.add(new Item(name, mods, descriptor)); } } } return super.visitMethod(access, name, descriptor, signature, exceptions); }
Example 4
Source File: AccessFlags.java From buck with Apache License 2.0 | 5 votes |
/** Gets the access flag (see JVMS8 4.1, 4.5, 4.6) corresponding to the given modifier. */ private static int modifierToAccessFlag(Modifier modifier) { switch (modifier) { case PUBLIC: return Opcodes.ACC_PUBLIC; case PROTECTED: return Opcodes.ACC_PROTECTED; case PRIVATE: return Opcodes.ACC_PRIVATE; case ABSTRACT: return Opcodes.ACC_ABSTRACT; case DEFAULT: return 0; case STATIC: return Opcodes.ACC_STATIC; case FINAL: return Opcodes.ACC_FINAL; case TRANSIENT: return Opcodes.ACC_TRANSIENT; case VOLATILE: return Opcodes.ACC_VOLATILE; case SYNCHRONIZED: return Opcodes.ACC_SYNCHRONIZED; case NATIVE: return Opcodes.ACC_NATIVE; case STRICTFP: return Opcodes.ACC_STRICT; default: throw new IllegalArgumentException(String.format("Unexpected modifier: %s", modifier)); } }
Example 5
Source File: SerialVersionUIDAdder.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
@Override public MethodVisitor visitMethod( final int access, final String name, final String descriptor, final String signature, final String[] exceptions) { // Get constructor and method information (step 5 and 7). Also determine if there is a class // initializer (step 6). if (computeSVUID) { if (CLINIT.equals(name)) { hasStaticInitializer = true; } // Collect the non private constructors and methods. Only the ACC_PUBLIC, ACC_PRIVATE, // ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and // ACC_STRICT flags are used. int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT); if ((access & Opcodes.ACC_PRIVATE) == 0) { if ("<init>".equals(name)) { svuidConstructors.add(new Item(name, mods, descriptor)); } else if (!CLINIT.equals(name)) { svuidMethods.add(new Item(name, mods, descriptor)); } } } return super.visitMethod(access, name, descriptor, signature, exceptions); }
Example 6
Source File: SerialVersionUIDAdder.java From JReFrameworker with MIT License | 5 votes |
@Override public MethodVisitor visitMethod( final int access, final String name, final String descriptor, final String signature, final String[] exceptions) { // Get constructor and method information (step 5 and 7). Also determine if there is a class // initializer (step 6). if (computeSvuid) { if (CLINIT.equals(name)) { hasStaticInitializer = true; } // Collect the non private constructors and methods. Only the ACC_PUBLIC, ACC_PRIVATE, // ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and // ACC_STRICT flags are used. int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT); if ((access & Opcodes.ACC_PRIVATE) == 0) { if ("<init>".equals(name)) { svuidConstructors.add(new Item(name, mods, descriptor)); } else if (!CLINIT.equals(name)) { svuidMethods.add(new Item(name, mods, descriptor)); } } } return super.visitMethod(access, name, descriptor, signature, exceptions); }
Example 7
Source File: MethodNodeDecompiler.java From bytecode-viewer with GNU General Public License v3.0 | 5 votes |
private static String getAccessString(int access) { // public, protected, private, abstract, static, // final, synchronized, native & strictfp are permitted List<String> tokens = new ArrayList<String>(); if ((access & Opcodes.ACC_PUBLIC) != 0) tokens.add("public"); if ((access & Opcodes.ACC_PRIVATE) != 0) tokens.add("private"); if ((access & Opcodes.ACC_PROTECTED) != 0) tokens.add("protected"); if ((access & Opcodes.ACC_STATIC) != 0) tokens.add("static"); if ((access & Opcodes.ACC_ABSTRACT) != 0) tokens.add("abstract"); if ((access & Opcodes.ACC_FINAL) != 0) tokens.add("final"); if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) tokens.add("synchronized"); if ((access & Opcodes.ACC_NATIVE) != 0) tokens.add("native"); if ((access & Opcodes.ACC_STRICT) != 0) tokens.add("strictfp"); if ((access & Opcodes.ACC_BRIDGE) != 0) tokens.add("bridge"); if ((access & Opcodes.ACC_SYNTHETIC) != 0) tokens.add("synthetic"); if ((access & Opcodes.ACC_VARARGS) != 0) tokens.add("varargs"); if (tokens.size() == 0) return ""; // hackery delimeters StringBuilder sb = new StringBuilder(tokens.get(0)); for (int i = 1; i < tokens.size(); i++) { sb.append(" "); sb.append(tokens.get(i)); } return sb.toString(); }
Example 8
Source File: SerialVersionUIDAdder.java From JReFrameworker with MIT License | 5 votes |
@Override public MethodVisitor visitMethod( final int access, final String name, final String descriptor, final String signature, final String[] exceptions) { // Get constructor and method information (step 5 and 7). Also determine if there is a class // initializer (step 6). if (computeSvuid) { if (CLINIT.equals(name)) { hasStaticInitializer = true; } // Collect the non private constructors and methods. Only the ACC_PUBLIC, ACC_PRIVATE, // ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and // ACC_STRICT flags are used. int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT); if ((access & Opcodes.ACC_PRIVATE) == 0) { if ("<init>".equals(name)) { svuidConstructors.add(new Item(name, mods, descriptor)); } else if (!CLINIT.equals(name)) { svuidMethods.add(new Item(name, mods, descriptor)); } } } return super.visitMethod(access, name, descriptor, signature, exceptions); }
Example 9
Source File: StaticStateAnalyzer.java From buck with Apache License 2.0 | 5 votes |
private boolean isClassSafe(ClassNode klass) { boolean isSafe = true; // Look for mutable static fields. for (FieldNode field : klass.fields) { if ((field.access & Opcodes.ACC_STATIC) == 0) { continue; } if ((field.access & Opcodes.ACC_FINAL) == 0) { log.add("Non-final static field: " + describe(klass, field)); isSafe = false; continue; } if (!mutabilityAnalyzer.isTypeImmutable(field.desc)) { log.add("Mut-final static field: " + describe(klass, field)); isSafe = false; continue; } } // Look for static synchronized methods. for (MethodNode method : klass.methods) { if ((method.access & Opcodes.ACC_STATIC) == 0) { continue; } if ((method.access & Opcodes.ACC_SYNCHRONIZED) != 0) { log.add("Synchronized static method: " + describe(klass, method)); isSafe = false; continue; } } return isSafe; }
Example 10
Source File: Engine.java From JReFrameworker with MIT License | 4 votes |
@SuppressWarnings("unused") private static String getAccessModifiers(int access){ LinkedList<String> modifiers = new LinkedList<String>(); if((Opcodes.ACC_ABSTRACT & access) == Opcodes.ACC_ABSTRACT){ modifiers.add("abstract"); } if((Opcodes.ACC_ANNOTATION & access) == Opcodes.ACC_ANNOTATION){ modifiers.add("annotation"); } if((Opcodes.ACC_BRIDGE & access) == Opcodes.ACC_BRIDGE){ modifiers.add("bridge"); } if((Opcodes.ACC_DEPRECATED & access) == Opcodes.ACC_DEPRECATED){ modifiers.add("deprecated"); } if((Opcodes.ACC_ENUM & access) == Opcodes.ACC_ENUM){ modifiers.add("enum"); } if((Opcodes.ACC_FINAL & access) == Opcodes.ACC_FINAL){ modifiers.add("final"); } if((Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE){ modifiers.add("interface"); } if((Opcodes.ACC_MANDATED & access) == Opcodes.ACC_MANDATED){ modifiers.add("mandated"); } if((Opcodes.ACC_NATIVE & access) == Opcodes.ACC_NATIVE){ modifiers.add("native"); } if((Opcodes.ACC_PRIVATE & access) == Opcodes.ACC_PRIVATE){ modifiers.add("private"); } if((Opcodes.ACC_PROTECTED & access) == Opcodes.ACC_PROTECTED){ modifiers.add("protected"); } if((Opcodes.ACC_PUBLIC & access) == Opcodes.ACC_PUBLIC){ modifiers.add("public"); } if((Opcodes.ACC_STATIC & access) == Opcodes.ACC_STATIC){ modifiers.add("static"); } if((Opcodes.ACC_STRICT & access) == Opcodes.ACC_STRICT){ modifiers.add("strict"); } if((Opcodes.ACC_SUPER & access) == Opcodes.ACC_SUPER){ modifiers.add("super"); } if((Opcodes.ACC_SYNCHRONIZED & access) == Opcodes.ACC_SYNCHRONIZED){ modifiers.add("synchronized"); } if((Opcodes.ACC_SYNTHETIC & access) == Opcodes.ACC_SYNTHETIC){ modifiers.add("synthetic"); } if((Opcodes.ACC_TRANSIENT & access) == Opcodes.ACC_TRANSIENT){ modifiers.add("transient"); } if((Opcodes.ACC_VARARGS & access) == Opcodes.ACC_VARARGS){ modifiers.add("varargs"); } if((Opcodes.ACC_VOLATILE & access) == Opcodes.ACC_VOLATILE){ modifiers.add("volatile"); } return modifiers.toString(); }
Example 11
Source File: GizmoClassVisitor.java From gizmo with Apache License 2.0 | 4 votes |
public GizmoMethodVisitor visitMethod(final int access, final String name, final String descriptor, final String signature, final String[] exceptions) { if (currentMethod != null) { throw new IllegalStateException("Multiple active method visitors"); } final MethodVisitor delegate = super.visitMethod(access, name, descriptor, signature, exceptions); final GizmoMethodVisitor zigMethodVisitor = new GizmoMethodVisitor(api, delegate, this); currentMethod = zigMethodVisitor; final Type returnType = Type.getReturnType(descriptor); append("// Access:"); for (int mods = access; mods != 0;) { int mod = Integer.lowestOneBit(mods); switch (mod) { case Opcodes.ACC_PUBLIC: { append(" public"); break; } case Opcodes.ACC_PRIVATE: { append(" private"); break; } case Opcodes.ACC_PROTECTED: { append(" protected"); break; } case Opcodes.ACC_STATIC: { append(" static"); break; } case Opcodes.ACC_FINAL: { append(" final"); break; } case Opcodes.ACC_SYNCHRONIZED: { append(" synchronized"); break; } case Opcodes.ACC_BRIDGE: { append(" bridge"); break; } case Opcodes.ACC_VARARGS: { append(" varargs"); break; } case Opcodes.ACC_NATIVE: { append(" native"); break; } case Opcodes.ACC_ABSTRACT: { append(" abstract"); break; } case Opcodes.ACC_STRICT: { append(" strictfp"); break; } case Opcodes.ACC_SYNTHETIC: { append(" synthetic"); break; } } mods ^= mod; } newLine(); append("Method ").append(name).append(" : ").append(returnType); if (exceptions != null && exceptions.length > 0) { addIndent().newLine().append("throws "); append(exceptions[0]); for (int i = 1; i < exceptions.length; i++) { append(", ").append(exceptions[i]); } removeIndent(); } newLine().append("(").addIndent().newLine(); final Type[] argumentTypes = Type.getArgumentTypes(descriptor); if (argumentTypes.length > 0) { int base = ((access & Opcodes.ACC_STATIC) != 0) ? 0 : 1; append("arg ").append(base).append(" = ").append(argumentTypes[0]); for (int i = 1; i < argumentTypes.length; i ++) { append(',').newLine(); append("arg ").append(base + i).append(" = ").append(argumentTypes[i]); } } else { append("// (no arguments)"); } removeIndent().newLine().append(") {").addIndent().newLine(); return zigMethodVisitor; }
Example 12
Source File: Textifier.java From JReFrameworker with MIT License | 4 votes |
/** * Appends a string representation of the given access flags to {@link #stringBuilder}. * * @param accessFlags some access flags. */ private void appendAccess(final int accessFlags) { if ((accessFlags & Opcodes.ACC_PUBLIC) != 0) { stringBuilder.append("public "); } if ((accessFlags & Opcodes.ACC_PRIVATE) != 0) { stringBuilder.append("private "); } if ((accessFlags & Opcodes.ACC_PROTECTED) != 0) { stringBuilder.append("protected "); } if ((accessFlags & Opcodes.ACC_FINAL) != 0) { stringBuilder.append("final "); } if ((accessFlags & Opcodes.ACC_STATIC) != 0) { stringBuilder.append("static "); } if ((accessFlags & Opcodes.ACC_SYNCHRONIZED) != 0) { stringBuilder.append("synchronized "); } if ((accessFlags & Opcodes.ACC_VOLATILE) != 0) { stringBuilder.append("volatile "); } if ((accessFlags & Opcodes.ACC_TRANSIENT) != 0) { stringBuilder.append("transient "); } if ((accessFlags & Opcodes.ACC_ABSTRACT) != 0) { stringBuilder.append("abstract "); } if ((accessFlags & Opcodes.ACC_STRICT) != 0) { stringBuilder.append("strictfp "); } if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0) { stringBuilder.append("synthetic "); } if ((accessFlags & Opcodes.ACC_MANDATED) != 0) { stringBuilder.append("mandated "); } if ((accessFlags & Opcodes.ACC_ENUM) != 0) { stringBuilder.append("enum "); } }
Example 13
Source File: Textifier.java From JReFrameworker with MIT License | 4 votes |
/** * Appends a string representation of the given access flags to {@link #stringBuilder}. * * @param accessFlags some access flags. */ private void appendAccess(final int accessFlags) { if ((accessFlags & Opcodes.ACC_PUBLIC) != 0) { stringBuilder.append("public "); } if ((accessFlags & Opcodes.ACC_PRIVATE) != 0) { stringBuilder.append("private "); } if ((accessFlags & Opcodes.ACC_PROTECTED) != 0) { stringBuilder.append("protected "); } if ((accessFlags & Opcodes.ACC_FINAL) != 0) { stringBuilder.append("final "); } if ((accessFlags & Opcodes.ACC_STATIC) != 0) { stringBuilder.append("static "); } if ((accessFlags & Opcodes.ACC_SYNCHRONIZED) != 0) { stringBuilder.append("synchronized "); } if ((accessFlags & Opcodes.ACC_VOLATILE) != 0) { stringBuilder.append("volatile "); } if ((accessFlags & Opcodes.ACC_TRANSIENT) != 0) { stringBuilder.append("transient "); } if ((accessFlags & Opcodes.ACC_ABSTRACT) != 0) { stringBuilder.append("abstract "); } if ((accessFlags & Opcodes.ACC_STRICT) != 0) { stringBuilder.append("strictfp "); } if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0) { stringBuilder.append("synthetic "); } if ((accessFlags & Opcodes.ACC_MANDATED) != 0) { stringBuilder.append("mandated "); } if ((accessFlags & Opcodes.ACC_ENUM) != 0) { stringBuilder.append("enum "); } }
Example 14
Source File: Engine.java From JReFrameworker with MIT License | 4 votes |
@SuppressWarnings("unused") private static String getAccessModifiers(int access){ LinkedList<String> modifiers = new LinkedList<String>(); if((Opcodes.ACC_ABSTRACT & access) == Opcodes.ACC_ABSTRACT){ modifiers.add("abstract"); } if((Opcodes.ACC_ANNOTATION & access) == Opcodes.ACC_ANNOTATION){ modifiers.add("annotation"); } if((Opcodes.ACC_BRIDGE & access) == Opcodes.ACC_BRIDGE){ modifiers.add("bridge"); } if((Opcodes.ACC_DEPRECATED & access) == Opcodes.ACC_DEPRECATED){ modifiers.add("deprecated"); } if((Opcodes.ACC_ENUM & access) == Opcodes.ACC_ENUM){ modifiers.add("enum"); } if((Opcodes.ACC_FINAL & access) == Opcodes.ACC_FINAL){ modifiers.add("final"); } if((Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE){ modifiers.add("interface"); } if((Opcodes.ACC_MANDATED & access) == Opcodes.ACC_MANDATED){ modifiers.add("mandated"); } if((Opcodes.ACC_NATIVE & access) == Opcodes.ACC_NATIVE){ modifiers.add("native"); } if((Opcodes.ACC_PRIVATE & access) == Opcodes.ACC_PRIVATE){ modifiers.add("private"); } if((Opcodes.ACC_PROTECTED & access) == Opcodes.ACC_PROTECTED){ modifiers.add("protected"); } if((Opcodes.ACC_PUBLIC & access) == Opcodes.ACC_PUBLIC){ modifiers.add("public"); } if((Opcodes.ACC_STATIC & access) == Opcodes.ACC_STATIC){ modifiers.add("static"); } if((Opcodes.ACC_STRICT & access) == Opcodes.ACC_STRICT){ modifiers.add("strict"); } if((Opcodes.ACC_SUPER & access) == Opcodes.ACC_SUPER){ modifiers.add("super"); } if((Opcodes.ACC_SYNCHRONIZED & access) == Opcodes.ACC_SYNCHRONIZED){ modifiers.add("synchronized"); } if((Opcodes.ACC_SYNTHETIC & access) == Opcodes.ACC_SYNTHETIC){ modifiers.add("synthetic"); } if((Opcodes.ACC_TRANSIENT & access) == Opcodes.ACC_TRANSIENT){ modifiers.add("transient"); } if((Opcodes.ACC_VARARGS & access) == Opcodes.ACC_VARARGS){ modifiers.add("varargs"); } if((Opcodes.ACC_VOLATILE & access) == Opcodes.ACC_VOLATILE){ modifiers.add("volatile"); } return modifiers.toString(); }
Example 15
Source File: ASMClassParser.java From TickDynamic with MIT License | 4 votes |
protected int parseAccessFlags() throws Exception { String current; int access = 0; //They share value(Mutually exclusive, one is for method, one is for field) boolean gotTransient = false; boolean gotVarargs = false; while(true) { current = nextToken(); if(current == null) return access; //A lot of these actually are not a keyword, but something the compiler adds, just keep it here for now if(current.equals("public")) access += Opcodes.ACC_PUBLIC; else if(current.equals("private")) access += Opcodes.ACC_PRIVATE; else if(current.equals("protected")) access += Opcodes.ACC_PROTECTED; else if(current.equals("static")) access += Opcodes.ACC_STATIC; else if(current.equals("final")) access += Opcodes.ACC_FINAL; /*else if(current.equals("super")) access += Opcodes.ACC_SUPER;*/ //This one is added on newer compilers whenever a class has a super class else if(current.equals("synchronized")) access += Opcodes.ACC_SYNCHRONIZED; else if(current.equals("volatile")) access += Opcodes.ACC_VOLATILE; else if(current.equals("bridge")) access += Opcodes.ACC_BRIDGE; else if(current.equals("varargs")) { if(!gotTransient) { access += Opcodes.ACC_VARARGS; gotVarargs = true; } } else if(current.equals("transient")) { if(!gotVarargs) { access += Opcodes.ACC_TRANSIENT; gotTransient = true; } } else if(current.equals("native")) access += Opcodes.ACC_NATIVE; else if(current.equals("interface")) access += Opcodes.ACC_INTERFACE; else if(current.equals("abstract")) access += Opcodes.ACC_ABSTRACT; else if(current.equals("strict")) access += Opcodes.ACC_STRICT; else if(current.equals("synthetic")) access += Opcodes.ACC_SYNTHETIC; else if(current.equals("annotation")) access += Opcodes.ACC_ANNOTATION; else if(current.equals("enum")) access += Opcodes.ACC_ENUM; else if(current.equals("mandated")) access += Opcodes.ACC_MANDATED; else { //Move back from our peek currentToken--; //System.out.println("Access: " + Integer.toHexString(access).toUpperCase()); return access; } } }
Example 16
Source File: AbstractASMBackend.java From JAADAS with GNU General Public License v3.0 | 4 votes |
/** * Utility method to get the access modifiers of a Host * @param modVal The bitset representation of the Host's modifiers * @param host The Host (SootClass, SootField or SootMethod) the modifiers are to be retrieved from * @return A bitset representation of the Host's modifiers in ASM's internal representation */ protected static int getModifiers(int modVal, Host host) { int modifier = 0; // Retrieve visibility-modifier if (Modifier.isPublic(modVal)) { modifier |= Opcodes.ACC_PUBLIC; } else if (Modifier.isPrivate(modVal)) { modifier |= Opcodes.ACC_PRIVATE; } else if (Modifier.isProtected(modVal)) { modifier |= Opcodes.ACC_PROTECTED; } // Retrieve static-modifier if (Modifier.isStatic(modVal) && ((host instanceof SootField) || (host instanceof SootMethod))) { modifier |= Opcodes.ACC_STATIC; } // Retrieve final-modifier if (Modifier.isFinal(modVal)) { modifier |= Opcodes.ACC_FINAL; } // Retrieve synchronized-modifier if (Modifier.isSynchronized(modVal) && host instanceof SootMethod) { modifier |= Opcodes.ACC_SYNCHRONIZED; } // Retrieve volatile/bridge-modifier if (Modifier.isVolatile(modVal) && !(host instanceof SootClass)) { modifier |= Opcodes.ACC_VOLATILE; } // Retrieve transient/varargs-modifier if (Modifier.isTransient(modVal) && !(host instanceof SootClass)) { modifier |= Opcodes.ACC_TRANSIENT; } // Retrieve native-modifier if (Modifier.isNative(modVal) && host instanceof SootMethod) { modifier |= Opcodes.ACC_NATIVE; } // Retrieve interface-modifier if (Modifier.isInterface(modVal) && host instanceof SootClass) { modifier |= Opcodes.ACC_INTERFACE; } else if (host instanceof SootClass) { /* * For all classes except for interfaces the super-flag should be * set. See JVM 8-Specification section 4.1, page 72. */ modifier |= Opcodes.ACC_SUPER; } // Retrieve abstract-modifier if (Modifier.isAbstract(modVal) && !(host instanceof SootField)) { modifier |= Opcodes.ACC_ABSTRACT; } // Retrieve strictFP-modifier if (Modifier.isStrictFP(modVal) && host instanceof SootMethod) { modifier |= Opcodes.ACC_STRICT; } /* * Retrieve synthetic-modifier. Class not present in source-code but * generated by e.g. compiler TODO Do we need both checks? */ if (Modifier.isSynthetic(modVal) || host.hasTag("SyntheticTag")) { modifier |= Opcodes.ACC_SYNTHETIC; } // Retrieve annotation-modifier if (Modifier.isAnnotation(modVal) && host instanceof SootClass) { modifier |= Opcodes.ACC_ANNOTATION; } // Retrieve enum-modifier if (Modifier.isEnum(modVal) && !(host instanceof SootMethod)) { modifier |= Opcodes.ACC_ENUM; } return modifier; }
Example 17
Source File: ASMReflector.java From meghanada-server with GNU General Public License v3.0 | 4 votes |
static String toModifier(int access, boolean hasDefault) { StringBuilder sb = new StringBuilder(7); if ((Opcodes.ACC_PRIVATE & access) > 0) { sb.append("private "); } if ((Opcodes.ACC_PUBLIC & access) > 0) { sb.append("public "); } if ((Opcodes.ACC_PROTECTED & access) > 0) { sb.append("protected "); } if ((Opcodes.ACC_STATIC & access) > 0) { sb.append("static "); } if ((Opcodes.ACC_ABSTRACT & access) > 0) { sb.append("abstract "); } if ((Opcodes.ACC_FINAL & access) > 0) { sb.append("final "); } if ((Opcodes.ACC_INTERFACE & access) > 0) { sb.append("interface "); } if ((Opcodes.ACC_NATIVE & access) > 0) { sb.append("native "); } if ((Opcodes.ACC_STRICT & access) > 0) { sb.append("strict "); } if ((Opcodes.ACC_SYNCHRONIZED & access) > 0) { sb.append("synchronized "); } if (hasDefault) { sb.append("default "); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
Example 18
Source File: Textifier.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
/** * Appends a string representation of the given access modifiers to * {@link #buf buf}. * * @param access * some access modifiers. */ private void appendAccess(final int access) { if ((access & Opcodes.ACC_PUBLIC) != 0) { buf.append("public "); } if ((access & Opcodes.ACC_PRIVATE) != 0) { buf.append("private "); } if ((access & Opcodes.ACC_PROTECTED) != 0) { buf.append("protected "); } if ((access & Opcodes.ACC_FINAL) != 0) { buf.append("final "); } if ((access & Opcodes.ACC_STATIC) != 0) { buf.append("static "); } if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) { buf.append("synchronized "); } if ((access & Opcodes.ACC_VOLATILE) != 0) { buf.append("volatile "); } if ((access & Opcodes.ACC_TRANSIENT) != 0) { buf.append("transient "); } if ((access & Opcodes.ACC_ABSTRACT) != 0) { buf.append("abstract "); } if ((access & Opcodes.ACC_STRICT) != 0) { buf.append("strictfp "); } if ((access & Opcodes.ACC_SYNTHETIC) != 0) { buf.append("synthetic "); } if ((access & Opcodes.ACC_MANDATED) != 0) { buf.append("mandated "); } if ((access & Opcodes.ACC_ENUM) != 0) { buf.append("enum "); } }
Example 19
Source File: MonitorInstrument.java From dacapobench with Apache License 2.0 | 4 votes |
private boolean isSynchronized() { return (access & Opcodes.ACC_SYNCHRONIZED) != 0; }
Example 20
Source File: Textifier.java From Concurnas with MIT License | 4 votes |
/** * Appends a string representation of the given access flags to {@link #stringBuilder}. * * @param accessFlags some access flags. */ private void appendAccess(final int accessFlags) { if ((accessFlags & Opcodes.ACC_PUBLIC) != 0) { stringBuilder.append("public "); } if ((accessFlags & Opcodes.ACC_PRIVATE) != 0) { stringBuilder.append("private "); } if ((accessFlags & Opcodes.ACC_PROTECTED) != 0) { stringBuilder.append("protected "); } if ((accessFlags & Opcodes.ACC_FINAL) != 0) { stringBuilder.append("final "); } if ((accessFlags & Opcodes.ACC_STATIC) != 0) { stringBuilder.append("static "); } if ((accessFlags & Opcodes.ACC_SYNCHRONIZED) != 0) { stringBuilder.append("synchronized "); } if ((accessFlags & Opcodes.ACC_VOLATILE) != 0) { stringBuilder.append("volatile "); } if ((accessFlags & Opcodes.ACC_TRANSIENT) != 0) { stringBuilder.append("transient "); } if ((accessFlags & Opcodes.ACC_ABSTRACT) != 0) { stringBuilder.append("abstract "); } if ((accessFlags & Opcodes.ACC_STRICT) != 0) { stringBuilder.append("strictfp "); } if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0) { stringBuilder.append("synthetic "); } if ((accessFlags & Opcodes.ACC_MANDATED) != 0) { stringBuilder.append("mandated "); } if ((accessFlags & Opcodes.ACC_ENUM) != 0) { stringBuilder.append("enum "); } }