OPENJPA-2911 addGetIDOwningClass in ASM

This commit is contained in:
Mark Struberg 2023-06-22 12:21:43 +02:00
parent 5d781bd6dc
commit ae4964cc45
1 changed files with 13 additions and 10 deletions

View File

@ -1384,14 +1384,16 @@ public class PCEnhancer {
// persistent class inheritance hierarchy // persistent class inheritance hierarchy
if (_meta.getIdentityType() == ClassMetaData.ID_APPLICATION if (_meta.getIdentityType() == ClassMetaData.ID_APPLICATION
&& (_meta.getPCSuperclass() == null || getCreateSubclass() || && (_meta.getPCSuperclass() == null || getCreateSubclass() ||
_meta.getObjectIdType() != _meta.getObjectIdType() != _meta.getPCSuperclassMetaData().getObjectIdType())) {
_meta.getPCSuperclassMetaData().getObjectIdType())) { AsmHelper.readIntoBCClass(pc, _pc);
addCopyKeyFieldsToObjectIdMethod(true); addCopyKeyFieldsToObjectIdMethod(true);
addCopyKeyFieldsToObjectIdMethod(false); addCopyKeyFieldsToObjectIdMethod(false);
addCopyKeyFieldsFromObjectIdMethod(true); addCopyKeyFieldsFromObjectIdMethod(true);
addCopyKeyFieldsFromObjectIdMethod(false); addCopyKeyFieldsFromObjectIdMethod(false);
if (_meta.hasAbstractPKField()) { if (_meta.hasAbstractPKField()) {
pc = AsmHelper.toClassNode(_pc);
addGetIDOwningClass(); addGetIDOwningClass();
AsmHelper.readIntoBCClass(pc, _pc);
} }
if (_meta.isEmbeddable() && _meta.getIdentityType() == ClassMetaData.ID_APPLICATION) { if (_meta.isEmbeddable() && _meta.getIdentityType() == ClassMetaData.ID_APPLICATION) {
@ -1402,7 +1404,9 @@ public class PCEnhancer {
addNewObjectIdInstanceMethod(false); addNewObjectIdInstanceMethod(false);
} }
else if (_meta.hasPKFieldsFromAbstractClass()) { else if (_meta.hasPKFieldsFromAbstractClass()) {
pc = AsmHelper.toClassNode(_pc);
addGetIDOwningClass(); addGetIDOwningClass();
AsmHelper.readIntoBCClass(pc, _pc);
} }
} }
@ -5683,15 +5687,14 @@ public class PCEnhancer {
} }
private void addGetIDOwningClass() { private void addGetIDOwningClass() {
BCMethod method = _pc.declareMethod(PRE + "GetIDOwningClass", MethodNode idOCMeth = new MethodNode(Opcodes.ACC_PUBLIC,
Class.class, null); PRE + "GetIDOwningClass",
Code code = method.getCode(true); Type.getMethodDescriptor(Type.getType(Class.class)),
null, null);
pc.getClassNode().methods.add(idOCMeth);
code.classconstant().setClass(getType(_meta)); idOCMeth.instructions.add(AsmHelper.getLoadConstantInsn(getType(_meta)));
code.areturn(); idOCMeth.instructions.add(new InsnNode(Opcodes.ARETURN));
code.calculateMaxStack();
code.calculateMaxLocals();
} }
/** /**