Java Code Examples for com.android.dx.rop.code.AccessFlags#ACC_DECLARED_SYNCHRONIZED
The following examples show how to use
com.android.dx.rop.code.AccessFlags#ACC_DECLARED_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: DexMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Declares a method or constructor. * * @param flags a bitwise combination of {@link Modifier#PUBLIC}, {@link * Modifier#PRIVATE}, {@link Modifier#PROTECTED}, {@link Modifier#STATIC}, * {@link Modifier#FINAL} and {@link Modifier#SYNCHRONIZED}. * <p><strong>Warning:</strong> the {@link Modifier#SYNCHRONIZED} flag * is insufficient to generate a synchronized method. You must also use * {@link Code#monitorEnter} and {@link Code#monitorExit} to acquire * a monitor. */ public Code declare(MethodId<?, ?> method, int flags) { TypeDeclaration typeDeclaration = getTypeDeclaration(method.declaringType); if (typeDeclaration.methods.containsKey(method)) { throw new IllegalStateException("already declared: " + method); } int supportedFlags = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.STATIC | Modifier.FINAL | Modifier.SYNCHRONIZED | Modifier.ABSTRACT | Modifier.NATIVE; if ((flags & ~supportedFlags) != 0) { throw new IllegalArgumentException("Unexpected flag: " + Integer.toHexString(flags)); } if ((flags & Modifier.ABSTRACT) != 0 && (flags & Modifier.NATIVE) != 0) { throw new IllegalArgumentException("Native method can't be abstract"); } // replace the SYNCHRONIZED flag with the DECLARED_SYNCHRONIZED flag if ((flags & Modifier.SYNCHRONIZED) != 0) { flags = (flags & ~Modifier.SYNCHRONIZED) | AccessFlags.ACC_DECLARED_SYNCHRONIZED; } if (method.isConstructor() || method.isStaticInitializer()) { flags |= ACC_CONSTRUCTOR; } MethodDeclaration methodDeclaration = new MethodDeclaration(method, flags); typeDeclaration.methods.put(method, methodDeclaration); return methodDeclaration.code; }
Example 2
Source File: DexMaker.java From dexmaker with Apache License 2.0 | 5 votes |
/** * Declares a method or constructor. * * @param flags a bitwise combination of {@link Modifier#PUBLIC}, {@link * Modifier#PRIVATE}, {@link Modifier#PROTECTED}, {@link Modifier#STATIC}, * {@link Modifier#FINAL} and {@link Modifier#SYNCHRONIZED}. * <p><strong>Warning:</strong> the {@link Modifier#SYNCHRONIZED} flag * is insufficient to generate a synchronized method. You must also use * {@link Code#monitorEnter} and {@link Code#monitorExit} to acquire * a monitor. */ public Code declare(MethodId<?, ?> method, int flags) { TypeDeclaration typeDeclaration = getTypeDeclaration(method.declaringType); if (typeDeclaration.methods.containsKey(method)) { throw new IllegalStateException("already declared: " + method); } int supportedFlags = Modifier.ABSTRACT | Modifier.NATIVE | Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.STATIC | Modifier.FINAL | Modifier.SYNCHRONIZED | AccessFlags.ACC_SYNTHETIC | AccessFlags.ACC_BRIDGE; if ((flags & ~supportedFlags) != 0) { throw new IllegalArgumentException("Unexpected flag: " + Integer.toHexString(flags)); } // replace the SYNCHRONIZED flag with the DECLARED_SYNCHRONIZED flag if ((flags & Modifier.SYNCHRONIZED) != 0) { flags = (flags & ~Modifier.SYNCHRONIZED) | AccessFlags.ACC_DECLARED_SYNCHRONIZED; } if (method.isConstructor() || method.isStaticInitializer()) { flags |= ACC_CONSTRUCTOR; } MethodDeclaration methodDeclaration = new MethodDeclaration(method, flags); typeDeclaration.methods.put(method, methodDeclaration); return methodDeclaration.code; }
Example 3
Source File: AccessInfo.java From Box with Apache License 2.0 | 4 votes |
public boolean isSynchronized() { return (accFlags & (AccessFlags.ACC_SYNCHRONIZED | AccessFlags.ACC_DECLARED_SYNCHRONIZED)) != 0; }
Example 4
Source File: AccessInfo.java From Box with Apache License 2.0 | 4 votes |
public boolean isSynchronized() { return (accFlags & (AccessFlags.ACC_SYNCHRONIZED | AccessFlags.ACC_DECLARED_SYNCHRONIZED)) != 0; }