List of usage examples for org.objectweb.asm Opcodes ACC_ANNOTATION
int ACC_ANNOTATION
To view the source code for org.objectweb.asm Opcodes ACC_ANNOTATION.
Click Source Link
From source file:com.android.build.gradle.shrinker.DependencyFinderVisitor.java
License:Apache License
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {//from w w w. j a v a2 s. com if (interfaces == null) { interfaces = new String[0]; } mKlass = mGraph.getClassReference(name); if (superName != null && !isSdkPackage(superName)) { // Don't create graph edges for obvious things. handleDependency(mKlass, mGraph.getClassReference(superName), DependencyType.REQUIRED_CLASS_STRUCTURE); } if (interfaces.length > 0) { handleInterfaceInheritance(mKlass); if (!Objects.equal(superName, "java/lang/Object")) { // It's possible the superclass is implementing a method from the interface, we may // need to add more edges to the graph to represent this. handleMultipleInheritance(mKlass); } } mClassName = name; mIsAnnotation = (access & Opcodes.ACC_ANNOTATION) != 0; if (signature != null) { SignatureReader reader = new SignatureReader(signature); SignatureVisitor visitor = new DependencyFinderSignatureVisitor(); reader.accept(visitor); } super.visit(version, access, name, signature, superName, interfaces); }
From source file:com.android.builder.shrinker.DependencyFinderVisitor.java
License:Apache License
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {//from w ww. j av a 2 s . c o m if (interfaces == null) { interfaces = new String[0]; } mKlass = mGraph.getClassReference(name); if (!superName.equals("java/lang/Object")) { // Don't create graph edges for obvious things. handleDependency(mKlass, mGraph.getClassReference(superName), DependencyType.REQUIRED); } // We don't create edges for interfaces, because interfaces can be removed by the shrinker, // if they are not used. if (interfaces.length > 0 && !mGraph.isLibraryClass(mGraph.getClassReference(superName))) { // It's possible the superclass is implementing a method from the interface, we may need // to add more edges to the graph to represent this. mMultipleInheritance.add(mKlass); } mClassName = name; mIsAnnotation = (access & Opcodes.ACC_ANNOTATION) != 0; if (signature != null) { handleClassSignature(mKlass, signature); } super.visit(version, access, name, signature, superName, interfaces); }
From source file:com.facebook.buck.jvm.java.abi.AbiFilteringClassVisitor.java
License:Apache License
private boolean isAnnotation(int access) { return (access & Opcodes.ACC_ANNOTATION) > 0; }
From source file:com.facebook.buck.jvm.java.abi.AccessFlags.java
License:Apache License
/** * Gets the class access flags (see JVMS8 4.1) for the given type element, augmented by the * special ASM pseudo-access flag for @Deprecated types. *//*from w ww .j a v a2 s .c o m*/ public int getAccessFlags(TypeElement typeElement) { int result = getCommonAccessFlags(typeElement); switch (typeElement.getKind()) { case ANNOTATION_TYPE: // No ACC_SUPER here per JVMS 4.1 result = result | Opcodes.ACC_ANNOTATION; result = result | Opcodes.ACC_INTERFACE; result = result | Opcodes.ACC_ABSTRACT; break; case ENUM: result = result | Opcodes.ACC_SUPER; // JVMS 4.1 result = result | Opcodes.ACC_ENUM; // Enums have this lovely property that you can't declare them abstract in source, even // if they have abstract methods or incompletely implemented interfaces, yet the class // file will have ACC_ABSTRACT in that case. Because it's a pain to figure out if an // enum is abstract (and impossible in the no-deps case), and you can't instantiate or // subclass one directly anyway, we just leave the flag off. break; case INTERFACE: // No ACC_SUPER here per JVMS 4.1 result = result | Opcodes.ACC_ABSTRACT; result = result | Opcodes.ACC_INTERFACE; break; // $CASES-OMITTED$ default: result = result | Opcodes.ACC_SUPER; // JVMS 4.1 break; } return result; }
From source file:com.facebook.buck.jvm.java.abi.AccessFlagsTest.java
License:Apache License
@Test public void testAnnotationTypeFlags() throws IOException { testTypeFlags("@java.lang.annotation.Documented @interface Foo { }", "Foo", Opcodes.ACC_ANNOTATION | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT); }
From source file:com.gargoylesoftware.js.nashorn.internal.ir.debug.NashornTextifier.java
License:Open Source License
@Override public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { final int major = version & 0xFFFF; final int minor = version >>> 16; currentClassName = name;/*www.j av a2 s . c o m*/ final StringBuilder sb = new StringBuilder(); sb.append("// class version ").append(major).append('.').append(minor).append(" (").append(version) .append(")\n"); if ((access & Opcodes.ACC_DEPRECATED) != 0) { sb.append("// DEPRECATED\n"); } sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN append(Integer.toHexString(access).toUpperCase()).append('\n'); appendDescriptor(sb, CLASS_SIGNATURE, signature); if (signature != null) { final TraceSignatureVisitor sv = new TraceSignatureVisitor(access); final SignatureReader r = new SignatureReader(signature); r.accept(sv); sb.append("// declaration: ").append(name).append(sv.getDeclaration()).append('\n'); } appendAccess(sb, access & ~Opcodes.ACC_SUPER); if ((access & Opcodes.ACC_ANNOTATION) != 0) { sb.append("@interface "); } else if ((access & Opcodes.ACC_INTERFACE) != 0) { sb.append("interface "); } else if ((access & Opcodes.ACC_ENUM) == 0) { sb.append("class "); } appendDescriptor(sb, INTERNAL_NAME, name); if (superName != null && !"java/lang/Object".equals(superName)) { sb.append(" extends "); appendDescriptor(sb, INTERNAL_NAME, superName); sb.append(' '); } if (interfaces != null && interfaces.length > 0) { sb.append(" implements "); for (final String interface1 : interfaces) { appendDescriptor(sb, INTERNAL_NAME, interface1); sb.append(' '); } } sb.append(" {\n"); addText(sb); }
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;/*from w ww .j a va 2 s .c o m*/ 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; }
From source file:com.google.gwt.dev.javac.CompilationUnitTypeOracleUpdater.java
License:Apache License
/** * Doesn't retain a reference to the TypeData. */// w w w .j a v a 2 s . c o m private JRealClassType createType(TypeData typeData, CollectClassData collectClassData, CollectClassData enclosingClassData) { int access = collectClassData.getAccess(); String simpleName = Shared.getShortName(typeData.sourceName); JRealClassType type = null; String packageName = typeData.packageName; JPackage pkg = typeOracle.getOrCreatePackage(packageName); boolean isInterface = (access & Opcodes.ACC_INTERFACE) != 0; assert !collectClassData.hasNoExternalName(); String enclosingSimpleName = null; if (enclosingClassData != null) { enclosingSimpleName = enclosingClassData.getNestedSourceName(); } if ((access & Opcodes.ACC_ANNOTATION) != 0) { type = newAnnotationType(pkg, enclosingSimpleName, simpleName); } else if ((access & Opcodes.ACC_ENUM) != 0) { type = newEnumType(pkg, enclosingSimpleName, simpleName); } else { JTypeParameter[] typeParams = getTypeParametersForClass(collectClassData); if ((typeParams != null && typeParams.length > 0) || nonStaticInsideGeneric(collectClassData, enclosingClassData)) { type = new JGenericType(typeOracle, pkg, enclosingSimpleName, simpleName, isInterface, typeParams); } else { type = newRealClassType(pkg, enclosingSimpleName, simpleName, isInterface); } } type.addModifierBits(mapBits(ASM_TO_SHARED_MODIFIERS, access)); if (isInterface) { // Always add implicit modifiers on interfaces. type.addModifierBits(Shared.MOD_STATIC | Shared.MOD_ABSTRACT); } type.addLastModifiedTime(typeData.lastModifiedTime); return type; }
From source file:com.google.gwt.dev.javac.TypeOracleMediator.java
License:Open Source License
private JRealClassType createType(CompiledClass compiledClass, CollectClassData classData, CollectClassData enclosingClassData) { int access = classData.getAccess(); String qname = compiledClass.getSourceName(); String className = Shared.getShortName(qname); JRealClassType resultType = null;/*from ww w. j av a 2s .co m*/ String jpkgName = compiledClass.getPackageName(); JPackage pkg = typeOracle.getOrCreatePackage(jpkgName); boolean isIntf = (access & Opcodes.ACC_INTERFACE) != 0; assert !classData.hasNoExternalName(); String enclosingTypeName = null; if (enclosingClassData != null) { enclosingTypeName = InternalName.toSourceName(InternalName.getClassName(enclosingClassData.getName())); } if ((access & Opcodes.ACC_ANNOTATION) != 0) { resultType = newAnnotationType(pkg, enclosingTypeName, className); } else if ((access & Opcodes.ACC_ENUM) != 0) { resultType = newEnumType(pkg, enclosingTypeName, className); } else { JTypeParameter[] typeParams = getTypeParametersForClass(classData); if ((typeParams != null && typeParams.length > 0) || nonStaticInsideGeneric(classData, enclosingClassData)) { resultType = new JGenericType(typeOracle, pkg, enclosingTypeName, className, isIntf, typeParams); } else { resultType = newRealClassType(pkg, enclosingTypeName, className, isIntf); } } /* * Declare type parameters for all methods; we must do this during the first * pass. */ // if (typeDecl.methods != null) { // for (AbstractMethodDeclaration method : typeDecl.methods) { // declareTypeParameters(method.typeParameters()); // } // } /* * Add modifiers since these are needed for * TypeOracle.getParameterizedType's error checking code. */ resultType.addModifierBits(mapBits(ASM_TO_SHARED_MODIFIERS, access)); if (isIntf) { // Always add implicit modifiers on interfaces. resultType.addModifierBits(Shared.MOD_STATIC | Shared.MOD_ABSTRACT); } return resultType; }
From source file:com.googlecode.dex2jar.ir.ToStringUtil.java
License:Apache License
public static String getAccDes(int acc) { StringBuilder sb = new StringBuilder(); if ((acc & Opcodes.ACC_PUBLIC) != 0) { sb.append("public "); }//from w ww . j ava 2 s .c o m if ((acc & Opcodes.ACC_PROTECTED) != 0) { sb.append("protected "); } if ((acc & Opcodes.ACC_PRIVATE) != 0) { sb.append("private "); } if ((acc & Opcodes.ACC_STATIC) != 0) { sb.append("static "); } if ((acc & Opcodes.ACC_ABSTRACT) != 0 && (acc & Opcodes.ACC_INTERFACE) == 0) { sb.append("abstract "); } if ((acc & Opcodes.ACC_ANNOTATION) != 0) { sb.append("annotation "); } if ((acc & Opcodes.ACC_BRIDGE) != 0) { sb.append("bridge "); } if ((acc & Opcodes.ACC_DEPRECATED) != 0) { sb.append("deprecated "); } if ((acc & Opcodes.ACC_ENUM) != 0) { sb.append("enum "); } if ((acc & Opcodes.ACC_FINAL) != 0) { sb.append("final "); } if ((acc & Opcodes.ACC_INTERFACE) != 0) { sb.append("interace "); } if ((acc & Opcodes.ACC_NATIVE) != 0) { sb.append("native "); } if ((acc & Opcodes.ACC_STRICT) != 0) { sb.append("strict "); } if ((acc & Opcodes.ACC_SYNCHRONIZED) != 0) { sb.append("synchronized "); } if ((acc & Opcodes.ACC_TRANSIENT) != 0) { sb.append("transient "); } if ((acc & Opcodes.ACC_VARARGS) != 0) { sb.append("varargs "); } if ((acc & Opcodes.ACC_VOLATILE) != 0) { sb.append("volatile "); } return sb.toString(); }