HHH-7747 check if the code attribute is null when building the StackMapTable

This commit is contained in:
Scott Marlow 2012-12-11 14:53:36 -05:00
parent 834bb03c96
commit 8b365d8ef5
1 changed files with 21 additions and 10 deletions

View File

@ -159,8 +159,11 @@ public class FieldTransformer {
code.addOpcode(Opcode.ARETURN); code.addOpcode(Opcode.ARETURN);
minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC); minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(classPool, minfo); CodeAttribute codeAttribute = minfo.getCodeAttribute();
minfo.getCodeAttribute().setAttribute(smt); if (codeAttribute != null) {
StackMapTable smt = MapMaker.make(classPool, minfo);
codeAttribute.setAttribute(smt);
}
classfile.addMethod(minfo); classfile.addMethod(minfo);
} }
@ -185,8 +188,11 @@ public class FieldTransformer {
code.addOpcode(Opcode.RETURN); code.addOpcode(Opcode.RETURN);
minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC); minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(classPool, minfo); CodeAttribute codeAttribute = minfo.getCodeAttribute();
minfo.getCodeAttribute().setAttribute(smt); if (codeAttribute != null) {
StackMapTable smt = MapMaker.make(classPool, minfo);
codeAttribute.setAttribute(smt);
}
classfile.addMethod(minfo); classfile.addMethod(minfo);
} }
@ -269,8 +275,11 @@ public class FieldTransformer {
minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC); minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(classPool, minfo); CodeAttribute codeAttribute = minfo.getCodeAttribute();
minfo.getCodeAttribute().setAttribute(smt); if (codeAttribute != null) {
StackMapTable smt = MapMaker.make(classPool, minfo);
codeAttribute.setAttribute(smt);
}
classfile.addMethod(minfo); classfile.addMethod(minfo);
} }
@ -337,8 +346,11 @@ public class FieldTransformer {
minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC); minfo.setAccessFlags(AccessFlag.PUBLIC);
StackMapTable smt = MapMaker.make(classPool, minfo); CodeAttribute codeAttribute = minfo.getCodeAttribute();
minfo.getCodeAttribute().setAttribute(smt); if (codeAttribute != null) {
StackMapTable smt = MapMaker.make(classPool, minfo);
codeAttribute.setAttribute(smt);
}
classfile.addMethod(minfo); classfile.addMethod(minfo);
} }
@ -364,9 +376,8 @@ public class FieldTransformer {
pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos); pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos); pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
} }
StackMapTable smt = MapMaker.make(classPool, minfo); StackMapTable smt = MapMaker.make(classPool, minfo);
minfo.getCodeAttribute().setAttribute(smt); codeAttr.setAttribute(smt);
} }
} }