Skip to content

Commit

Permalink
automated reading and writing of GenericAttribute tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Bodden committed Dec 14, 2011
1 parent e854fc6 commit 7715d8f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Improvements and API changes in trunk
9. Improved support for custom entry points in the points-to analysis.
10.Added option allowing putiry analysis to add a "Pure" bytecode
attribute for pure methods.
11.GenericAttribute instances are now automatically read from class
files and stored in class files.

Improvements and API changes in version 2.4.0

Expand Down
1 change: 1 addition & 0 deletions src/soot/coffi/ClassFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ else if (s.compareTo(attribute_info.AnnotationDefault)==0){
}
a = (attribute_info)ga;
}
if(this.toString().endsWith("Main")) System.out.println(s);
a.attribute_name = j;
a.attribute_length = len;
ai[i] = a;
Expand Down
18 changes: 18 additions & 0 deletions src/soot/coffi/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ else if (fieldInfo.attributes[j] instanceof Signature_attribute){
else if (fieldInfo.attributes[j] instanceof RuntimeVisibleAnnotations_attribute || fieldInfo.attributes[j] instanceof RuntimeInvisibleAnnotations_attribute)
{
addAnnotationVisibilityAttribute(field, fieldInfo.attributes[j], coffiClass, references);
}
else if (fieldInfo.attributes[j] instanceof Generic_attribute)
{
Generic_attribute attr = (Generic_attribute) fieldInfo.attributes[j];
String name = ((CONSTANT_Utf8_info)(coffiClass.constant_pool[attr.attribute_name])).convert();
field.addTag(new GenericAttribute(name, attr.info));
}
}
}
Expand Down Expand Up @@ -295,6 +301,12 @@ else if (methodInfo.attributes[j] instanceof AnnotationDefault_attribute)
ArrayList<AnnotationElem> list = createElementTags(1, coffiClass, input);
method.addTag(new AnnotationDefaultTag(list.get(0)));
}
else if (methodInfo.attributes[j] instanceof Generic_attribute)
{
Generic_attribute attr = (Generic_attribute) methodInfo.attributes[j];
String name = ((CONSTANT_Utf8_info)(coffiClass.constant_pool[attr.attribute_name])).convert();
method.addTag(new GenericAttribute(name, attr.info));
}
}
}

Expand Down Expand Up @@ -401,6 +413,12 @@ else if (coffiClass.attributes[i] instanceof RuntimeVisibleAnnotations_attribute
{
addAnnotationVisibilityAttribute(bclass, coffiClass.attributes[i], coffiClass, references);
}
else if (coffiClass.attributes[i] instanceof Generic_attribute)
{
Generic_attribute attr = (Generic_attribute) coffiClass.attributes[i];
String name = ((CONSTANT_Utf8_info)(coffiClass.constant_pool[attr.attribute_name])).convert();
bclass.addTag(new GenericAttribute(name, attr.info));
}

}
}
Expand Down
5 changes: 3 additions & 2 deletions src/soot/tagkit/GenericAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public class GenericAttribute implements Attribute

public GenericAttribute(String name, byte[] value)
{
mName = name;
mValue = value;
if(value==null) value = new byte[0];
mName = name;
mValue = value;
}
public String getName()
{
Expand Down

0 comments on commit 7715d8f

Please sign in to comment.