Skip to content

Commit b4e78a9

Browse files
committed
HHH-7747 check if the code attribute is null when building the StackMapTable
1 parent d26730f commit b4e78a9

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ private void addGetFieldHandlerMethod(ClassFile classfile)
159159
code.addOpcode(Opcode.ARETURN);
160160
minfo.setCodeAttribute(code.toCodeAttribute());
161161
minfo.setAccessFlags(AccessFlag.PUBLIC);
162-
StackMapTable smt = MapMaker.make(classPool, minfo);
163-
minfo.getCodeAttribute().setAttribute(smt);
162+
CodeAttribute codeAttribute = minfo.getCodeAttribute();
163+
if (codeAttribute != null) {
164+
StackMapTable smt = MapMaker.make(classPool, minfo);
165+
codeAttribute.setAttribute(smt);
166+
}
164167
classfile.addMethod(minfo);
165168
}
166169

@@ -185,8 +188,11 @@ private void addSetFieldHandlerMethod(ClassFile classfile)
185188
code.addOpcode(Opcode.RETURN);
186189
minfo.setCodeAttribute(code.toCodeAttribute());
187190
minfo.setAccessFlags(AccessFlag.PUBLIC);
188-
StackMapTable smt = MapMaker.make(classPool, minfo);
189-
minfo.getCodeAttribute().setAttribute(smt);
191+
CodeAttribute codeAttribute = minfo.getCodeAttribute();
192+
if (codeAttribute != null) {
193+
StackMapTable smt = MapMaker.make(classPool, minfo);
194+
codeAttribute.setAttribute(smt);
195+
}
190196
classfile.addMethod(minfo);
191197
}
192198

@@ -269,8 +275,11 @@ private void addReadMethod(ClassFile classfile, FieldInfo finfo)
269275

270276
minfo.setCodeAttribute(code.toCodeAttribute());
271277
minfo.setAccessFlags(AccessFlag.PUBLIC);
272-
StackMapTable smt = MapMaker.make(classPool, minfo);
273-
minfo.getCodeAttribute().setAttribute(smt);
278+
CodeAttribute codeAttribute = minfo.getCodeAttribute();
279+
if (codeAttribute != null) {
280+
StackMapTable smt = MapMaker.make(classPool, minfo);
281+
codeAttribute.setAttribute(smt);
282+
}
274283
classfile.addMethod(minfo);
275284
}
276285

@@ -337,8 +346,11 @@ private void addWriteMethod(ClassFile classfile, FieldInfo finfo)
337346

338347
minfo.setCodeAttribute(code.toCodeAttribute());
339348
minfo.setAccessFlags(AccessFlag.PUBLIC);
340-
StackMapTable smt = MapMaker.make(classPool, minfo);
341-
minfo.getCodeAttribute().setAttribute(smt);
349+
CodeAttribute codeAttribute = minfo.getCodeAttribute();
350+
if (codeAttribute != null) {
351+
StackMapTable smt = MapMaker.make(classPool, minfo);
352+
codeAttribute.setAttribute(smt);
353+
}
342354
classfile.addMethod(minfo);
343355
}
344356

@@ -364,9 +376,8 @@ private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile)
364376
pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
365377
pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
366378
}
367-
368379
StackMapTable smt = MapMaker.make(classPool, minfo);
369-
minfo.getCodeAttribute().setAttribute(smt);
380+
codeAttr.setAttribute(smt);
370381
}
371382
}
372383

0 commit comments

Comments
 (0)