From 8b365d8ef5e2b693cc425ffb1eb3aff2d48fe2c8 Mon Sep 17 00:00:00 2001 From: Scott Marlow Date: Tue, 11 Dec 2012 14:53:36 -0500 Subject: [PATCH] HHH-7747 check if the code attribute is null when building the StackMapTable --- .../internal/javassist/FieldTransformer.java | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java index 8c8732fc1b..eb586fde0c 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java @@ -159,8 +159,11 @@ public class FieldTransformer { code.addOpcode(Opcode.ARETURN); minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); - StackMapTable smt = MapMaker.make(classPool, minfo); - minfo.getCodeAttribute().setAttribute(smt); + CodeAttribute codeAttribute = minfo.getCodeAttribute(); + if (codeAttribute != null) { + StackMapTable smt = MapMaker.make(classPool, minfo); + codeAttribute.setAttribute(smt); + } classfile.addMethod(minfo); } @@ -185,8 +188,11 @@ public class FieldTransformer { code.addOpcode(Opcode.RETURN); minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); - StackMapTable smt = MapMaker.make(classPool, minfo); - minfo.getCodeAttribute().setAttribute(smt); + CodeAttribute codeAttribute = minfo.getCodeAttribute(); + if (codeAttribute != null) { + StackMapTable smt = MapMaker.make(classPool, minfo); + codeAttribute.setAttribute(smt); + } classfile.addMethod(minfo); } @@ -269,8 +275,11 @@ public class FieldTransformer { minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); - StackMapTable smt = MapMaker.make(classPool, minfo); - minfo.getCodeAttribute().setAttribute(smt); + CodeAttribute codeAttribute = minfo.getCodeAttribute(); + if (codeAttribute != null) { + StackMapTable smt = MapMaker.make(classPool, minfo); + codeAttribute.setAttribute(smt); + } classfile.addMethod(minfo); } @@ -337,8 +346,11 @@ public class FieldTransformer { minfo.setCodeAttribute(code.toCodeAttribute()); minfo.setAccessFlags(AccessFlag.PUBLIC); - StackMapTable smt = MapMaker.make(classPool, minfo); - minfo.getCodeAttribute().setAttribute(smt); + CodeAttribute codeAttribute = minfo.getCodeAttribute(); + if (codeAttribute != null) { + StackMapTable smt = MapMaker.make(classPool, minfo); + codeAttribute.setAttribute(smt); + } classfile.addMethod(minfo); } @@ -364,9 +376,8 @@ public class FieldTransformer { pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos); pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos); } - StackMapTable smt = MapMaker.make(classPool, minfo); - minfo.getCodeAttribute().setAttribute(smt); + codeAttr.setAttribute(smt); } }