use of com.sun.tools.classfile.Attribute in project jdk8u_jdk by JetBrains.
the class AnnotationsElementVisitor method readAttributesFor.
protected void readAttributesFor(ClassFile c, Attributes attrs, Element x) {
Element container = new Element();
AttributeVisitor av = new AttributeVisitor(this, c);
for (Attribute a : attrs) {
av.visit(a, container);
}
if (!keepOrder) {
container.sort();
}
x.addAll(container);
}
use of com.sun.tools.classfile.Attribute in project ceylon-compiler by ceylon.
the class SourceWriter method setLineMap.
private void setLineMap(Code_attribute attr) {
SortedMap<Integer, SortedSet<Integer>> map = new TreeMap<Integer, SortedSet<Integer>>();
SortedSet<Integer> allLines = new TreeSet<Integer>();
for (Attribute a : attr.attributes) {
if (a instanceof LineNumberTable_attribute) {
LineNumberTable_attribute t = (LineNumberTable_attribute) a;
for (LineNumberTable_attribute.Entry e : t.line_number_table) {
int start_pc = e.start_pc;
int line = e.line_number;
SortedSet<Integer> pcLines = map.get(start_pc);
if (pcLines == null) {
pcLines = new TreeSet<Integer>();
map.put(start_pc, pcLines);
}
pcLines.add(line);
allLines.add(line);
}
}
}
lineMap = map;
lineList = new ArrayList<Integer>(allLines);
}
use of com.sun.tools.classfile.Attribute in project ceylon-compiler by ceylon.
the class ClassWriter method writeField.
protected void writeField(Field f) {
if (!options.checkAccess(f.access_flags))
return;
AccessFlags flags = f.access_flags;
writeModifiers(flags.getFieldModifiers());
Signature_attribute sigAttr = getSignature(f.attributes);
if (sigAttr == null)
print(getJavaFieldType(f.descriptor));
else {
try {
Type t = sigAttr.getParsedSignature().getType(constant_pool);
print(getJavaName(t.toString()));
} catch (ConstantPoolException e) {
// report error?
// fall back on non-generic descriptor
print(getJavaFieldType(f.descriptor));
}
}
print(" ");
print(getFieldName(f));
if (options.showConstants && !options.compat) {
// BUG 4111861 print static final field contents
Attribute a = f.attributes.get(Attribute.ConstantValue);
if (a instanceof ConstantValue_attribute) {
print(" = ");
ConstantValue_attribute cv = (ConstantValue_attribute) a;
print(getConstantValue(f.descriptor, cv.constantvalue_index));
}
}
print(";");
println();
indent(+1);
if (options.showInternalSignatures)
println("Signature: " + getValue(f.descriptor));
if (options.verbose && !options.compat)
writeList("flags: ", flags.getFieldFlags(), NEWLINE);
if (options.showAllAttrs) {
for (Attribute attr : f.attributes) attrWriter.write(f, attr, constant_pool);
println();
}
indent(-1);
if (options.showDisassembled || options.showLineAndLocalVariableTables)
println();
}
use of com.sun.tools.classfile.Attribute in project ceylon-compiler by ceylon.
the class AttributeWriter method write.
public void write(Object owner, Attributes attrs, ConstantPool constant_pool) {
if (attrs != null) {
// null checks
owner.getClass();
constant_pool.getClass();
this.constant_pool = constant_pool;
this.owner = owner;
for (Attribute attr : attrs) attr.accept(this, null);
}
}
use of com.sun.tools.classfile.Attribute in project jdk8u_jdk by JetBrains.
the class LambdaAsm method checkMethod.
static int checkMethod(ClassFile cf, String mthd) throws Exception {
if (cf.major_version < 52) {
throw new RuntimeException("unexpected class file version, in " + cf.getName() + "expected 52, got " + cf.major_version);
}
int count = 0;
for (Method m : cf.methods) {
String mname = m.getName(cf.constant_pool);
if (mname.equals(mthd)) {
for (Attribute a : m.attributes) {
if ("Code".equals(a.getName(cf.constant_pool))) {
count++;
checkMethod(cf.getName(), mname, cf.constant_pool, (Code_attribute) a);
}
}
}
}
return count;
}
Aggregations