Commit 424a6244 authored by ebruneton's avatar ebruneton
Browse files

backport of a bug fix in ASM 2.0

parent ca6939cb
...@@ -182,13 +182,12 @@ public class Attribute { ...@@ -182,13 +182,12 @@ public class Attribute {
final int maxStack, final int maxStack,
final int maxLocals) final int maxLocals)
{ {
int size = 0;
Attribute attr = this; Attribute attr = this;
int size = 0;
while (attr != null) { while (attr != null) {
ByteVector b = attr.write(cw, code, len, maxStack, maxLocals); if (!attr.isUnknown()) {
if (b.length > 0) {
cw.newUTF8(attr.type); cw.newUTF8(attr.type);
size += b.length + 6; size += attr.write(cw, code, len, maxStack, maxLocals).length + 6;
} }
attr = attr.next; attr = attr.next;
} }
...@@ -225,12 +224,12 @@ public class Attribute { ...@@ -225,12 +224,12 @@ public class Attribute {
if (next != null) { if (next != null) {
next.put(cw, code, len, maxStack, maxLocals, out); next.put(cw, code, len, maxStack, maxLocals, out);
} }
ByteVector b = write(cw, code, len, maxStack, maxLocals); if (isUnknown()) {
if (b.length == 0) {
if (cw.checkAttributes) { if (cw.checkAttributes) {
throw new IllegalArgumentException("Unknown attribute type " + type); throw new IllegalArgumentException("Unknown attribute type " + type);
} }
} else { } else {
ByteVector b = write(cw, code, len, maxStack, maxLocals);
out.putShort(cw.newUTF8(type)).putInt(b.length); out.putShort(cw.newUTF8(type)).putInt(b.length);
out.putByteArray(b.data, 0, b.length); out.putByteArray(b.data, 0, b.length);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment