Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
am 4cd5f4e: Merge "Add user-friendly constructors to StdField"
Browse files Browse the repository at this point in the history
Merge commit '4cd5f4e3732f5fc5f4f13aeefc1a479f2bf77618' into dalvik-dev

* commit '4cd5f4e3732f5fc5f4f13aeefc1a479f2bf77618':
  Add user-friendly constructors to StdField
  • Loading branch information
brettchabot authored and Android Git Automerger committed Sep 23, 2010
2 parents f6fd271 + 4cd5f4e commit 88d74f7
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion dexgen/src/com/android/dexgen/rop/StdField.java
Expand Up @@ -18,6 +18,7 @@

import com.android.dexgen.rop.cst.CstNat;
import com.android.dexgen.rop.cst.CstType;
import com.android.dexgen.rop.cst.CstUtf8;
import com.android.dexgen.rop.cst.TypedConstant;

/**
Expand All @@ -38,6 +39,34 @@ public StdField(CstType definingClass, int accessFlags, CstNat nat,
super(definingClass, accessFlags, nat, attributes);
}

/**
* Constructs an instance having Java field as its pattern.
*
* @param field {@code non-null;} pattern for dex field
*/
public StdField(java.lang.reflect.Field field) {
this(CstType.intern(field.getDeclaringClass()),
field.getModifiers(),
new CstNat(new CstUtf8(field.getName()),
CstType.intern(field.getType()).getDescriptor()),
new StdAttributeList(0));
}

/**
* Constructs an instance taking field description as user-friendly arguments.
*
* @param declaringClass {@code non-null;} the class field belongs to
* @param type {@code non-null;} type of the field
* @param name {@code non-null;} name of the field
* @param modifiers access flags of the field
*/
public StdField(Class definingClass, Class type, String name, int modifiers) {
this(CstType.intern(definingClass),
modifiers,
new CstNat(new CstUtf8(name), CstType.intern(type).getDescriptor()),
new StdAttributeList(0));
}

/** {@inheritDoc} */
public TypedConstant getConstantValue() {
AttributeList attribs = getAttributes();
Expand All @@ -50,4 +79,4 @@ public TypedConstant getConstantValue() {

return cval.getConstantValue();
}
}
}

0 comments on commit 88d74f7

Please sign in to comment.