use of com.android.dx.rop.annotation.Annotations in project buck by facebook.
the class CfTranslator method processFields.
/**
* Processes the fields of the given class.
*
* @param cf {@code non-null;} class being translated
* @param out {@code non-null;} output class
* @param dexFile {@code non-null;} dex output
*/
private static void processFields(DirectClassFile cf, ClassDefItem out, DexFile dexFile) {
CstType thisClass = cf.getThisClass();
FieldList fields = cf.getFields();
int sz = fields.size();
for (int i = 0; i < sz; i++) {
Field one = fields.get(i);
try {
CstFieldRef field = new CstFieldRef(thisClass, one.getNat());
int accessFlags = one.getAccessFlags();
if (AccessFlags.isStatic(accessFlags)) {
TypedConstant constVal = one.getConstantValue();
EncodedField fi = new EncodedField(field, accessFlags);
if (constVal != null) {
constVal = coerceConstant(constVal, field.getType());
}
out.addStaticField(fi, constVal);
} else {
EncodedField fi = new EncodedField(field, accessFlags);
out.addInstanceField(fi);
}
Annotations annotations = AttributeTranslator.getAnnotations(one.getAttributes());
if (annotations.size() != 0) {
out.addFieldAnnotations(field, annotations, dexFile);
}
dexFile.getFieldIds().intern(field);
} catch (RuntimeException ex) {
String msg = "...while processing " + one.getName().toHuman() + " " + one.getDescriptor().toHuman();
throw ExceptionWithContext.withContext(ex, msg);
}
}
}
use of com.android.dx.rop.annotation.Annotations in project buck by facebook.
the class StdAttributeFactory method runtimeVisibleAnnotations.
/**
* Parses a {@code RuntimeVisibleAnnotations} attribute.
*/
private Attribute runtimeVisibleAnnotations(DirectClassFile cf, int offset, int length, ParseObserver observer) {
if (length < 2) {
throwSeverelyTruncated();
}
AnnotationParser ap = new AnnotationParser(cf, offset, length, observer);
Annotations annotations = ap.parseAnnotationAttribute(AnnotationVisibility.RUNTIME);
return new AttRuntimeVisibleAnnotations(annotations, length);
}
use of com.android.dx.rop.annotation.Annotations in project buck by facebook.
the class StdAttributeFactory method runtimeInvisibleAnnotations.
/**
* Parses a {@code RuntimeInvisibleAnnotations} attribute.
*/
private Attribute runtimeInvisibleAnnotations(DirectClassFile cf, int offset, int length, ParseObserver observer) {
if (length < 2) {
throwSeverelyTruncated();
}
AnnotationParser ap = new AnnotationParser(cf, offset, length, observer);
Annotations annotations = ap.parseAnnotationAttribute(AnnotationVisibility.BUILD);
return new AttRuntimeInvisibleAnnotations(annotations, length);
}
use of com.android.dx.rop.annotation.Annotations in project buck by facebook.
the class AnnotationParser method parseAnnotationsList.
/**
* Parses a list of annotation lists.
*
* @param visibility {@code non-null;} visibility of the parsed annotations
* @return {@code non-null;} the list of annotation lists read from the attribute
* data
*/
private AnnotationsList parseAnnotationsList(AnnotationVisibility visibility) throws IOException {
int count = input.readUnsignedByte();
if (observer != null) {
parsed(1, "num_parameters: " + Hex.u1(count));
}
AnnotationsList outerList = new AnnotationsList(count);
for (int i = 0; i < count; i++) {
if (observer != null) {
parsed(0, "parameter_annotations[" + i + "]:");
changeIndent(1);
}
Annotations annotations = parseAnnotations(visibility);
outerList.set(i, annotations);
if (observer != null) {
observer.changeIndent(-1);
}
}
outerList.setImmutable();
return outerList;
}
use of com.android.dx.rop.annotation.Annotations in project J2ME-Loader by nikita36078.
the class AnnotationParser method parseAnnotations.
/**
* Parses an annotation list.
*
* @param visibility {@code non-null;} visibility of the parsed annotations
* @return {@code non-null;} the list of annotations read from the attribute
* data
*/
private Annotations parseAnnotations(AnnotationVisibility visibility) throws IOException {
int count = input.readUnsignedShort();
if (observer != null) {
parsed(2, "num_annotations: " + Hex.u2(count));
}
Annotations annotations = new Annotations();
for (int i = 0; i < count; i++) {
if (observer != null) {
parsed(0, "annotations[" + i + "]:");
changeIndent(1);
}
Annotation annotation = parseAnnotation(visibility);
annotations.add(annotation);
if (observer != null) {
observer.changeIndent(-1);
}
}
annotations.setImmutable();
return annotations;
}
Aggregations