List of usage examples for org.objectweb.asm Opcodes ACC_ABSTRACT
int ACC_ABSTRACT
To view the source code for org.objectweb.asm Opcodes ACC_ABSTRACT.
Click Source Link
From source file:com.android.tools.layoutlib.create.TransformClassAdapter.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (mDeleteReturns != null) { Type t = Type.getReturnType(desc); if (t.getSort() == Type.OBJECT) { String returnType = t.getInternalName(); if (returnType != null) { if (mDeleteReturns.contains(returnType)) { return null; }/*from ww w . ja v a2 s . c o m*/ } } } String methodSignature = mClassName.replace('/', '.') + "#" + name; // change access to public access &= ~(Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE); access |= Opcodes.ACC_PUBLIC; // remove final access = access & ~Opcodes.ACC_FINAL; // stub this method if they are all to be stubbed or if it is a native method // and don't try to stub interfaces nor abstract non-native methods. if (!mIsInterface && ((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) != Opcodes.ACC_ABSTRACT) && (mStubAll || (access & Opcodes.ACC_NATIVE) != 0) || mStubMethods.contains(methodSignature)) { boolean isStatic = (access & Opcodes.ACC_STATIC) != 0; boolean isNative = (access & Opcodes.ACC_NATIVE) != 0; // remove abstract, final and native access = access & ~(Opcodes.ACC_ABSTRACT | Opcodes.ACC_FINAL | Opcodes.ACC_NATIVE); String invokeSignature = methodSignature + desc; mLog.debug(" Stub: %s (%s)", invokeSignature, isNative ? "native" : ""); MethodVisitor mw = super.visitMethod(access, name, desc, signature, exceptions); return new StubMethodAdapter(mw, name, returnType(desc), invokeSignature, isStatic, isNative); } else { mLog.debug(" Keep: %s %s", name, desc); return super.visitMethod(access, name, desc, signature, exceptions); } }
From source file:com.android.tools.lint.checks.ClickableViewAccessibilityDetector.java
License:Apache License
@Override public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { scanForAndCheckSetOnTouchListenerCalls(context, classNode); // Ignore abstract classes. if ((classNode.access & Opcodes.ACC_ABSTRACT) != 0) { return;//from www . j ava 2s . c o m } if (context.getDriver().isSubclassOf(classNode, ANDROID_VIEW_VIEW)) { checkView(context, classNode); } if (implementsOnTouchListener(classNode)) { checkOnTouchListener(context, classNode); } }
From source file:com.android.tools.lint.checks.FragmentDetector.java
License:Apache License
@Override public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { if ((classNode.access & Opcodes.ACC_ABSTRACT) != 0) { // Ignore abstract classes since they are clearly (and by definition) not intended to // be instantiated. We're looking for accidental non-static or missing constructor // scenarios here. return;// w w w.j a v a2 s. c o m } LintDriver driver = context.getDriver(); if (!(driver.isSubclassOf(classNode, FRAGMENT) || driver.isSubclassOf(classNode, FRAGMENT_V4))) { return; } if ((classNode.access & Opcodes.ACC_PUBLIC) == 0) { context.report(ISSUE, context.getLocation(classNode), String.format("This fragment class should be public (%1$s)", ClassContext.createSignature(classNode.name, null, null)), null); return; } if (classNode.name.indexOf('$') != -1 && !LintUtils.isStaticInnerClass(classNode)) { context.report(ISSUE, context.getLocation(classNode), String.format("This fragment inner class should be static (%1$s)", ClassContext.createSignature(classNode.name, null, null)), null); return; } boolean hasDefaultConstructor = false; @SuppressWarnings("rawtypes") // ASM API List methodList = classNode.methods; for (Object m : methodList) { MethodNode method = (MethodNode) m; if (method.name.equals(CONSTRUCTOR_NAME)) { if (method.desc.equals("()V")) { //$NON-NLS-1$ // The constructor must be public if ((method.access & Opcodes.ACC_PUBLIC) != 0) { hasDefaultConstructor = true; } else { context.report(ISSUE, context.getLocation(method, classNode), "The default constructor must be public", null); // Also mark that we have a constructor so we don't complain again // below since we've already emitted a more specific error related // to the default constructor hasDefaultConstructor = true; } } else if (!method.desc.contains("()")) { //$NON-NLS-1$ context.report(ISSUE, context.getLocation(method, classNode), // TODO: Use separate issue for this which isn't an error "Avoid non-default constructors in fragments: use a default constructor " + "plus Fragment#setArguments(Bundle) instead", null); } } } if (!hasDefaultConstructor) { context.report(ISSUE, context.getLocation(classNode), String.format( "This fragment should provide a default constructor (a public " + "constructor with no arguments) (%1$s)", ClassContext.createSignature(classNode.name, null, null)), null); } }
From source file:com.android.tools.lint.checks.RegistrationDetector.java
License:Apache License
@Override public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { // Abstract classes do not need to be registered if ((classNode.access & Opcodes.ACC_ABSTRACT) != 0) { return;// w ww .j av a2 s . c o m } String curr = classNode.name; int lastIndex = curr.lastIndexOf('$'); if (lastIndex != -1 && lastIndex < curr.length() - 1) { if (Character.isDigit(curr.charAt(lastIndex + 1))) { // Anonymous inner class, doesn't need to be registered return; } } while (curr != null) { for (String s : sClasses) { if (curr.equals(s)) { Collection<String> registered = mManifestRegistrations != null ? mManifestRegistrations.get(curr) : null; if (registered == null || !registered.contains(classNode.name)) { report(context, classNode, curr); } } } curr = context.getDriver().getSuperClass(curr); } }
From source file:com.android.tools.lint.checks.ViewConstructorDetector.java
License:Apache License
@Override public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { if (classNode.name.indexOf('$') != -1 && (classNode.access & Opcodes.ACC_STATIC) == 0) { // Ignore inner classes that aren't static: we can't create these // anyway since we'd need the outer instance return;//from www. ja va 2s . c om } // Ignore abstract classes if ((classNode.access & Opcodes.ACC_ABSTRACT) != 0) { return; } if (isViewClass(context, classNode)) { checkConstructors(context, classNode); } }
From source file:com.codename1.tools.translator.Parser.java
License:Open Source License
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {/*from ww w. j av a 2s.co m*/ cls.setBaseClass(superName); cls.setBaseInterfaces(interfaces); if ((access & Opcodes.ACC_ABSTRACT) == Opcodes.ACC_ABSTRACT) { cls.setIsAbstract(true); } if ((access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE) { cls.setIsInterface(true); } if ((access & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL) { cls.setFinalClass(true); } if ("com/codename1/testing/UnitTest".equals(superName) || "com/codename1/testing/AbstractTest".equals(superName)) { cls.setIsUnitTest(true); } if ((access & Opcodes.ACC_ENUM) == Opcodes.ACC_ENUM) { cls.setIsEnum(true); } super.visit(version, access, name, signature, superName, interfaces); }
From source file:com.facebook.buck.jvm.java.abi.AbiFilteringClassVisitorTest.java
License:Apache License
@Test public void testNotConfusedByOtherMethodAccessFlagsIncluding() { testIncludesMethodWithAccess(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNCHRONIZED); }
From source file:com.facebook.buck.jvm.java.abi.AbiFilteringClassVisitorTest.java
License:Apache License
@Test public void testNotConfusedByOtherMethodAccessFlagsExcluding() { testExcludesMethodWithAccess(Opcodes.ACC_PRIVATE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNCHRONIZED); }
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. *//* ww w . j av a 2s.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.AccessFlags.java
License:Apache License
/** 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://from w ww . ja v a 2 s. com 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)); } }