Java Code Examples for org.objectweb.asm.Opcodes#ACC_TRANSIENT
The following examples show how to use
org.objectweb.asm.Opcodes#ACC_TRANSIENT .
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: SerialVersionUIDAdder.java From Concurnas with MIT License | 5 votes |
@Override public FieldVisitor visitField( final int access, final String name, final String desc, final String signature, final Object value) { // Get the class field information for step 4 of the algorithm. Also determine if the class // already has a SVUID. if (computeSvuid) { if ("serialVersionUID".equals(name)) { // Since the class already has SVUID, we won't be computing it. computeSvuid = false; hasSvuid = true; } // Collect the non private fields. Only the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, // ACC_STATIC, ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when computing // serialVersionUID values. if ((access & Opcodes.ACC_PRIVATE) == 0 || (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) { int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT); svuidFields.add(new Item(name, mods, desc)); } } return super.visitField(access, name, desc, signature, value); }
Example 3
Source File: ModifierReviewable.java From byte-buddy with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public FieldPersistence getFieldPersistence() { int modifiers = getModifiers(); switch (modifiers & Opcodes.ACC_TRANSIENT) { case Opcodes.ACC_TRANSIENT: return FieldPersistence.TRANSIENT; case EMPTY_MASK: return FieldPersistence.PLAIN; default: throw new IllegalStateException("Unexpected modifiers: " + modifiers); } }
Example 4
Source File: SerialVersionUIDAdder.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
@Override public FieldVisitor visitField( final int access, final String name, final String desc, final String signature, final Object value) { // Get the class field information for step 4 of the algorithm. Also determine if the class // already has a SVUID. if (computeSVUID) { if ("serialVersionUID".equals(name)) { // Since the class already has SVUID, we won't be computing it. computeSVUID = false; hasSVUID = true; } // Collect the non private fields. Only the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, // ACC_STATIC, ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when computing // serialVersionUID values. if ((access & Opcodes.ACC_PRIVATE) == 0 || (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) { int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT); svuidFields.add(new Item(name, mods, desc)); } } return super.visitField(access, name, desc, signature, value); }
Example 5
Source File: FieldNodeDecompiler.java From bytecode-viewer with GNU General Public License v3.0 | 5 votes |
private static String getAccessString(int access) { 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_SYNTHETIC) != 0) tokens.add("synthetic"); if ((access & Opcodes.ACC_STATIC) != 0) tokens.add("static"); if ((access & Opcodes.ACC_FINAL) != 0) tokens.add("final"); if ((access & Opcodes.ACC_TRANSIENT) != 0) tokens.add("transient"); if ((access & Opcodes.ACC_VOLATILE) != 0) tokens.add("volatile"); 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 6
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 7
Source File: FieldNodeDecompiler.java From java-disassembler with GNU General Public License v3.0 | 5 votes |
private static String getAccessString(int access) { List<String> tokens = new ArrayList<>(); 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_SYNTHETIC) != 0) tokens.add("synthetic"); if ((access & Opcodes.ACC_STATIC) != 0) tokens.add("static"); if ((access & Opcodes.ACC_FINAL) != 0) tokens.add("final"); if ((access & Opcodes.ACC_TRANSIENT) != 0) tokens.add("transient"); if ((access & Opcodes.ACC_VOLATILE) != 0) tokens.add("volatile"); 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 FieldVisitor visitField( final int access, final String name, final String desc, final String signature, final Object value) { // Get the class field information for step 4 of the algorithm. Also determine if the class // already has a SVUID. if (computeSvuid) { if ("serialVersionUID".equals(name)) { // Since the class already has SVUID, we won't be computing it. computeSvuid = false; hasSvuid = true; } // Collect the non private fields. Only the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, // ACC_STATIC, ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when computing // serialVersionUID values. if ((access & Opcodes.ACC_PRIVATE) == 0 || (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) { int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT); svuidFields.add(new Item(name, mods, desc)); } } return super.visitField(access, name, desc, signature, value); }
Example 9
Source File: SerialVersionUIDAdder.java From JReFrameworker with MIT License | 5 votes |
@Override public FieldVisitor visitField( final int access, final String name, final String desc, final String signature, final Object value) { // Get the class field information for step 4 of the algorithm. Also determine if the class // already has a SVUID. if (computeSvuid) { if ("serialVersionUID".equals(name)) { // Since the class already has SVUID, we won't be computing it. computeSvuid = false; hasSvuid = true; } // Collect the non private fields. Only the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, // ACC_STATIC, ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when computing // serialVersionUID values. if ((access & Opcodes.ACC_PRIVATE) == 0 || (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) { int mods = access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT); svuidFields.add(new Item(name, mods, desc)); } } return super.visitField(access, name, desc, signature, value); }
Example 10
Source File: ASMClassNodeAdapter.java From pinpoint with Apache License 2.0 | 4 votes |
private int getFieldAccessFlags() { // Field added by pinpoint must not be serialized return Opcodes.ACC_PRIVATE | Opcodes.ACC_TRANSIENT; }
Example 11
Source File: GizmoClassVisitor.java From gizmo with Apache License 2.0 | 4 votes |
public FieldVisitor visitField(final int access, final String name, final String descriptor, final String signature, final Object value) { // int ACC_PUBLIC = 0x0001; // class, field, method // int ACC_PRIVATE = 0x0002; // class, field, method // int ACC_PROTECTED = 0x0004; // class, field, method // int ACC_STATIC = 0x0008; // field, method // int ACC_FINAL = 0x0010; // class, field, method, parameter // int ACC_SUPER = 0x0020; // class // int ACC_SYNCHRONIZED = 0x0020; // method // int ACC_OPEN = 0x0020; // module // int ACC_TRANSITIVE = 0x0020; // module requires // int ACC_VOLATILE = 0x0040; // field // int ACC_BRIDGE = 0x0040; // method // int ACC_STATIC_PHASE = 0x0040; // module requires // int ACC_VARARGS = 0x0080; // method // int ACC_TRANSIENT = 0x0080; // field // int ACC_NATIVE = 0x0100; // method // int ACC_INTERFACE = 0x0200; // class // int ACC_ABSTRACT = 0x0400; // class, method // int ACC_STRICT = 0x0800; // method // int ACC_SYNTHETIC = 0x1000; // class, field, method, parameter, module * // int ACC_ANNOTATION = 0x2000; // class // int ACC_ENUM = 0x4000; // class(?) field inner // int ACC_MANDATED = 0x8000; // parameter, module, module * // int ACC_MODULE = 0x8000; // class 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_VOLATILE: { append(" volatile"); break; } case Opcodes.ACC_TRANSIENT: { append(" transient"); break; } case Opcodes.ACC_SYNTHETIC: { append(" synthetic"); break; } case Opcodes.ACC_ENUM: { append(" enum"); break; } } mods ^= mod; } newLine(); append("Field ").append(name).append(" : ").append(Type.getType(descriptor)).newLine().newLine(); return super.visitField(access, name, descriptor, signature, value); }
Example 12
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 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: 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 15
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 16
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 17
Source File: LogASTTransformation.java From groovy with Apache License 2.0 | 4 votes |
private int lookupLogFieldModifiers(AnnotatedNode targetClass, AnnotationNode logAnnotation) { int modifiers = getVisibility(logAnnotation, targetClass, ClassNode.class, Opcodes.ACC_PRIVATE); return Opcodes.ACC_FINAL | Opcodes.ACC_TRANSIENT | Opcodes.ACC_STATIC | modifiers; }
Example 18
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 19
Source File: TheScopeFrame.java From Concurnas with MIT License | 4 votes |
public ArrayList<VarAtScopeLevel> getAllVariablesAtScopeLevel(boolean justFinals, boolean removeNestingIndicactorHelperVars, boolean ignoreIsOverride, boolean justNonNullable) { ArrayList<VarAtScopeLevel> ret = new ArrayList<VarAtScopeLevel>(); for(String varname : this.vars.keySet()) { TypeAndLocation tal = this.vars.get(varname); if(!justFinals || tal.getLocation().isFinal()){ if(null != tal){ Location loc = tal.getLocation(); if(!removeNestingIndicactorHelperVars || !varname.contains("$n") || loc.localClassImportedField){ int extraModifiers = 0; boolean assignedOnCreationAndFinal = false; boolean assignedOnCreation = false; if(loc instanceof LocationStaticField){ LocationStaticField asstataic = (LocationStaticField)loc; if(asstataic.enumValue){ extraModifiers += Opcodes.ACC_ENUM + Opcodes.ACC_STATIC; } } else if(loc instanceof LocationClassField) { if(ignoreIsOverride && ((LocationClassField)loc).isOverride) { continue; } assignedOnCreation = ((LocationClassField)loc).assignedOnCreation; assignedOnCreationAndFinal = assignedOnCreation && loc.isFinal(); } if(loc.isTransient()){ extraModifiers += Opcodes.ACC_TRANSIENT; } //TODO: add annotation to variable if shared { Matcher m = nestedName.matcher(varname);//JPT: a bit hacky, better to find out where $n1$n2 is coming from if(m.find() && m.find()){//if there are >=2 nested $n then we ignore this continue; } } if(justNonNullable) { Type tt = tal.getType(); if(assignedOnCreation) { continue; } if(tt instanceof PrimativeType && !tt.hasArrayLevels()) { continue; } if(tt.getNullStatus() == NullStatus.NULLABLE) { continue; } if(TypeCheckUtils.hasRefLevels(tt)) { continue; } } ret.add(new VarAtScopeLevel(varname, tal.getType(), loc.isFinal(), loc.getAccessModifier(), extraModifiers, loc.annotations, assignedOnCreationAndFinal, assignedOnCreation, loc.isInjected, loc.isShared())); } } } } return ret; }
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 "); } }