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

The following examples show how to use com.android.dx.rop.code.AccessFlags#ACC_STATIC . 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: EncodedMethod.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} constant for the method
 * @param accessFlags access flags
 * @param code {@code null-ok;} code for the method, if it is neither
 * {@code abstract} nor {@code native}
 * @param throwsList {@code non-null;} list of possibly-thrown exceptions,
 * just used in generating debugging output (listings)
 */
public EncodedMethod(CstMethodRef method, int accessFlags,
        DalvCode code, TypeList throwsList) {
    super(accessFlags);

    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    if (code == null) {
        this.code = null;
    } else {
        boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0;
        this.code = new CodeItem(method, code, isStatic, throwsList);
    }
}
 
Example 2
Source File: EncodedMethod.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} constant for the method
 * @param accessFlags access flags
 * @param code {@code null-ok;} code for the method, if it is neither
 * {@code abstract} nor {@code native}
 * @param throwsList {@code non-null;} list of possibly-thrown exceptions,
 * just used in generating debugging output (listings)
 */
public EncodedMethod(CstMethodRef method, int accessFlags,
        DalvCode code, TypeList throwsList) {
    super(accessFlags);

    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    if (code == null) {
        this.code = null;
    } else {
        boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0;
        this.code = new CodeItem(method, code, isStatic, throwsList);
    }
}
 
Example 3
Source File: EncodedMethod.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} constant for the method
 * @param accessFlags access flags
 * @param code {@code null-ok;} code for the method, if it is neither
 * {@code abstract} nor {@code native}
 * @param throwsList {@code non-null;} list of possibly-thrown exceptions,
 * just used in generating debugging output (listings)
 */
public EncodedMethod(CstMethodRef method, int accessFlags,
        DalvCode code, TypeList throwsList) {
    super(accessFlags);

    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    if (code == null) {
        this.code = null;
    } else {
        boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0;
        this.code = new CodeItem(method, code, isStatic, throwsList);
    }
}
 
Example 4
Source File: EncodedMethod.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} constant for the method
 * @param accessFlags access flags
 * @param code {@code null-ok;} code for the method, if it is neither
 * {@code abstract} nor {@code native}
 * @param throwsList {@code non-null;} list of possibly-thrown exceptions,
 * just used in generating debugging output (listings)
 */
public EncodedMethod(CstMethodRef method, int accessFlags,
        DalvCode code, TypeList throwsList) {
    super(accessFlags);

    if (method == null) {
        throw new NullPointerException("method == null");
    }

    this.method = method;

    if (code == null) {
        this.code = null;
    } else {
        boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0;
        this.code = new CodeItem(method, code, isStatic, throwsList);
    }
}
 
Example 5
Source File: AndroidResourcesUtils.java    From Box with Apache License 2.0 5 votes vote down vote up
private static void addResourceFields(ClassNode resCls, ResourceStorage resStorage, boolean rClsExists) {
	Map<Integer, FieldNode> resFieldsMap = fillResFieldsMap(resCls);
	Map<String, ClassNode> innerClsMap = new TreeMap<>();
	if (rClsExists) {
		for (ClassNode innerClass : resCls.getInnerClasses()) {
			innerClsMap.put(innerClass.getShortName(), innerClass);
		}
	}
	for (ResourceEntry resource : resStorage.getResources()) {
		final String resTypeName = resource.getTypeName();
		ClassNode typeCls = innerClsMap.computeIfAbsent(
				resTypeName,
				name -> addClassForResType(resCls, rClsExists, name));
		final String resName;
		if ("style".equals(resTypeName)) {
			resName = resource.getKeyName().replace('.', '_');
		} else {
			resName = resource.getKeyName();
		}
		FieldNode rField = typeCls.searchFieldByName(resName);
		if (rField == null) {
			FieldInfo rFieldInfo = FieldInfo.from(typeCls.dex(), typeCls.getClassInfo(), resName, ArgType.INT);
			rField = new FieldNode(typeCls, rFieldInfo, AccessFlags.ACC_PUBLIC | AccessFlags.ACC_STATIC | AccessFlags.ACC_FINAL);
			rField.addAttr(FieldInitAttr.constValue(resource.getId()));
			typeCls.getFields().add(rField);
			if (rClsExists) {
				rField.addAttr(AType.COMMENTS, "added by JADX");
			}
		}
		FieldNode fieldNode = resFieldsMap.get(resource.getId());
		if (fieldNode != null
				&& !fieldNode.getName().equals(resName)
				&& NameMapper.isValidAndPrintable(resName)
				&& resCls.root().getArgs().isRenameValid()) {
			fieldNode.add(AFlag.DONT_RENAME);
			fieldNode.getFieldInfo().setAlias(resName);
		}
	}
}
 
Example 6
Source File: AccessInfoTest.java    From Box with Apache License 2.0 5 votes vote down vote up
@Test
public void changeVisibility() {
	AccessInfo accessInfo = new AccessInfo(AccessFlags.ACC_PROTECTED | AccessFlags.ACC_STATIC, AFType.METHOD);
	AccessInfo result = accessInfo.changeVisibility(AccessFlags.ACC_PUBLIC);

	assertThat(result.isPublic(), is(true));
	assertThat(result.isPrivate(), is(false));
	assertThat(result.isProtected(), is(false));

	assertThat(result.isStatic(), is(true));
}
 
Example 7
Source File: AndroidResourcesUtils.java    From Box with Apache License 2.0 5 votes vote down vote up
@NotNull
private static ClassNode addClassForResType(ClassNode resCls, boolean rClsExists, String typeName) {
	ClassNode newTypeCls = new ClassNode(resCls.dex(), resCls.getFullName() + '$' + typeName,
			AccessFlags.ACC_PUBLIC | AccessFlags.ACC_STATIC | AccessFlags.ACC_FINAL);
	resCls.addInnerClass(newTypeCls);
	if (rClsExists) {
		newTypeCls.addAttr(AType.COMMENTS, "added by JADX");
	}
	return newTypeCls;
}
 
Example 8
Source File: AndroidResourcesUtils.java    From Box with Apache License 2.0 5 votes vote down vote up
private static void addResourceFields(ClassNode resCls, ResourceStorage resStorage, boolean rClsExists) {
	Map<Integer, FieldNode> resFieldsMap = fillResFieldsMap(resCls);
	Map<String, ClassNode> innerClsMap = new TreeMap<>();
	if (rClsExists) {
		for (ClassNode innerClass : resCls.getInnerClasses()) {
			innerClsMap.put(innerClass.getShortName(), innerClass);
		}
	}
	for (ResourceEntry resource : resStorage.getResources()) {
		final String resTypeName = resource.getTypeName();
		ClassNode typeCls = innerClsMap.computeIfAbsent(
				resTypeName,
				name -> addClassForResType(resCls, rClsExists, name));
		final String resName;
		if ("style".equals(resTypeName)) {
			resName = resource.getKeyName().replace('.', '_');
		} else {
			resName = resource.getKeyName();
		}
		FieldNode rField = typeCls.searchFieldByName(resName);
		if (rField == null) {
			FieldInfo rFieldInfo = FieldInfo.from(typeCls.dex(), typeCls.getClassInfo(), resName, ArgType.INT);
			rField = new FieldNode(typeCls, rFieldInfo, AccessFlags.ACC_PUBLIC | AccessFlags.ACC_STATIC | AccessFlags.ACC_FINAL);
			rField.addAttr(FieldInitAttr.constValue(resource.getId()));
			typeCls.getFields().add(rField);
			if (rClsExists) {
				rField.addAttr(AType.COMMENTS, "added by JADX");
			}
		}
		FieldNode fieldNode = resFieldsMap.get(resource.getId());
		if (fieldNode != null
				&& !fieldNode.getName().equals(resName)
				&& NameMapper.isValidAndPrintable(resName)
				&& resCls.root().getArgs().isRenameValid()) {
			fieldNode.add(AFlag.DONT_RENAME);
			fieldNode.getFieldInfo().setAlias(resName);
		}
	}
}
 
Example 9
Source File: AccessInfoTest.java    From Box with Apache License 2.0 5 votes vote down vote up
@Test
public void changeVisibility() {
	AccessInfo accessInfo = new AccessInfo(AccessFlags.ACC_PROTECTED | AccessFlags.ACC_STATIC, AFType.METHOD);
	AccessInfo result = accessInfo.changeVisibility(AccessFlags.ACC_PUBLIC);

	assertThat(result.isPublic(), is(true));
	assertThat(result.isPrivate(), is(false));
	assertThat(result.isProtected(), is(false));

	assertThat(result.isStatic(), is(true));
}
 
Example 10
Source File: AndroidResourcesUtils.java    From Box with Apache License 2.0 5 votes vote down vote up
@NotNull
private static ClassNode addClassForResType(ClassNode resCls, boolean rClsExists, String typeName) {
	ClassNode newTypeCls = new ClassNode(resCls.dex(), resCls.getFullName() + '$' + typeName,
			AccessFlags.ACC_PUBLIC | AccessFlags.ACC_STATIC | AccessFlags.ACC_FINAL);
	resCls.addInnerClass(newTypeCls);
	if (rClsExists) {
		newTypeCls.addAttr(AType.COMMENTS, "added by JADX");
	}
	return newTypeCls;
}
 
Example 11
Source File: AccessInfo.java    From Box with Apache License 2.0 4 votes vote down vote up
public boolean isStatic() {
	return (accFlags & AccessFlags.ACC_STATIC) != 0;
}
 
Example 12
Source File: AccessInfo.java    From Box with Apache License 2.0 4 votes vote down vote up
public boolean isStatic() {
	return (accFlags & AccessFlags.ACC_STATIC) != 0;
}
 
Example 13
Source File: Ropper.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Gets whether the method being translated is static.
 *
 * @return whether the method being translated is static
 */
private boolean isStatic() {
    int accessFlags = method.getAccessFlags();
    return (accessFlags & AccessFlags.ACC_STATIC) != 0;
}
 
Example 14
Source File: ConcreteMethod.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Tests whether the method is being defined is declared as static.
 * @return true if the method is being defined is declared as static.
 */
public final boolean isStaticMethod() {
    return (getAccessFlags() & AccessFlags.ACC_STATIC) != 0;
}
 
Example 15
Source File: Ropper.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Gets whether the method being translated is static.
 *
 * @return whether the method being translated is static
 */
private boolean isStatic() {
    int accessFlags = method.getAccessFlags();
    return (accessFlags & AccessFlags.ACC_STATIC) != 0;
}
 
Example 16
Source File: ConcreteMethod.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Tests whether the method is being defined is declared as static.
 * @return true if the method is being defined is declared as static.
 */
public final boolean isStaticMethod() {
    return (getAccessFlags() & AccessFlags.ACC_STATIC) != 0;
}
 
Example 17
Source File: Ropper.java    From J2ME-Loader with Apache License 2.0 2 votes vote down vote up
/**
 * Gets whether the method being translated is static.
 *
 * @return whether the method being translated is static
 */
private boolean isStatic() {
    int accessFlags = method.getAccessFlags();
    return (accessFlags & AccessFlags.ACC_STATIC) != 0;
}
 
Example 18
Source File: Ropper.java    From buck with Apache License 2.0 2 votes vote down vote up
/**
 * Gets whether the method being translated is static.
 *
 * @return whether the method being translated is static
 */
private boolean isStatic() {
    int accessFlags = method.getAccessFlags();
    return (accessFlags & AccessFlags.ACC_STATIC) != 0;
}