Java Code Examples for com.android.dx.rop.code.AccessFlags#ACC_SYNTHETIC

The following examples show how to use com.android.dx.rop.code.AccessFlags#ACC_SYNTHETIC . 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 dexmaker with Apache License 2.0 6 votes vote down vote up
/**
 * Declares {@code type}.
 *
 * @param flags a bitwise combination of {@link Modifier#PUBLIC}, {@link
 *     Modifier#FINAL} and {@link Modifier#ABSTRACT}.
 */
public void declare(TypeId<?> type, String sourceFile, int flags,
                    TypeId<?> supertype, TypeId<?>... interfaces) {
    TypeDeclaration declaration = getTypeDeclaration(type);
    int supportedFlags = Modifier.PUBLIC | Modifier.FINAL | Modifier.ABSTRACT
            | AccessFlags.ACC_SYNTHETIC;
    if ((flags & ~supportedFlags) != 0) {
        throw new IllegalArgumentException("Unexpected flag: "
                + Integer.toHexString(flags));
    }
    if (declaration.declared) {
        throw new IllegalStateException("already declared: " + type);
    }
    declaration.declared = true;
    declaration.flags = flags;
    declaration.supertype = supertype;
    declaration.sourceFile = sourceFile;
    declaration.interfaces = new TypeList(interfaces);
}
 
Example 2
Source File: DexMaker.java    From dexmaker with Apache License 2.0 6 votes vote down vote up
/**
 * Declares a field.
 *
 * @param flags a bitwise combination of {@link Modifier#PUBLIC}, {@link
 *     Modifier#PRIVATE}, {@link Modifier#PROTECTED}, {@link Modifier#STATIC},
 *     {@link Modifier#FINAL}, {@link Modifier#VOLATILE}, and {@link
 *     Modifier#TRANSIENT}.
 * @param staticValue a constant representing the initial value for the
 *     static field, possibly null. This must be null if this field is
 *     non-static.
 */
public void declare(FieldId<?, ?> fieldId, int flags, Object staticValue) {
    TypeDeclaration typeDeclaration = getTypeDeclaration(fieldId.declaringType);
    if (typeDeclaration.fields.containsKey(fieldId)) {
        throw new IllegalStateException("already declared: " + fieldId);
    }

    int supportedFlags = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED
            | Modifier.STATIC | Modifier.FINAL | Modifier.VOLATILE | Modifier.TRANSIENT
            | AccessFlags.ACC_SYNTHETIC;
    if ((flags & ~supportedFlags) != 0) {
        throw new IllegalArgumentException("Unexpected flag: "
                + Integer.toHexString(flags));
    }

    if ((flags & Modifier.STATIC) == 0 && staticValue != null) {
        throw new IllegalArgumentException("staticValue is non-null, but field is not static");
    }

    FieldDeclaration fieldDeclaration = new FieldDeclaration(fieldId, flags, staticValue);
    typeDeclaration.fields.put(fieldId, fieldDeclaration);
}
 
Example 3
Source File: DexMaker.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
/**
 * 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 4
Source File: AccessInfo.java    From Box with Apache License 2.0 4 votes vote down vote up
public boolean isSynthetic() {
	return (accFlags & AccessFlags.ACC_SYNTHETIC) != 0;
}
 
Example 5
Source File: AccessInfo.java    From Box with Apache License 2.0 4 votes vote down vote up
public boolean isSynthetic() {
	return (accFlags & AccessFlags.ACC_SYNTHETIC) != 0;
}