use of org.datanucleus.metadata.AbstractClassMetaData in project datanucleus-core by datanucleus.
the class EnhancerPropertyGetterAdapter method generateGetXXXMethod.
/**
* Convenience method to use the MethodVisitor to generate the code for the method getXXX() for the property with the specified MetaData.
* @param mv MethodVisitor
* @param mmd MetaData for the property
* @param asmClassName ASM class name for the owning class
* @param asmClassDesc ASM descriptor for the owning class
* @param detachListener true if the generate code must support DetachListener
* @param namer Namer for methods etc
*/
public static void generateGetXXXMethod(MethodVisitor mv, AbstractMemberMetaData mmd, String asmClassName, String asmClassDesc, boolean detachListener, EnhancementNamer namer) {
String[] argNames = new String[] { "this" };
String fieldTypeDesc = Type.getDescriptor(mmd.getType());
mv.visitCode();
AbstractClassMetaData cmd = mmd.getAbstractClassMetaData();
if ((mmd.getPersistenceFlags() & Persistable.MEDIATE_READ) == Persistable.MEDIATE_READ) {
// MEDIATE_READ - see method GetViaMediate
Label startLabel = new Label();
mv.visitLabel(startLabel);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
Label l1 = new Label();
mv.visitJumpInsn(Opcodes.IFNULL, l1);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, namer.getStateManagerAsmClassName(), "isLoaded", "(L" + namer.getPersistableAsmClassName() + ";I)Z");
mv.visitJumpInsn(Opcodes.IFNE, l1);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getGetMethodPrefixMethodName() + mmd.getName(), "()" + fieldTypeDesc);
String methodName = "get" + EnhanceUtils.getTypeNameForPersistableMethod(mmd.getType()) + "Field";
String argTypeDesc = fieldTypeDesc;
if (methodName.equals("getObjectField")) {
argTypeDesc = EnhanceUtils.CD_Object;
}
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, namer.getStateManagerAsmClassName(), methodName, "(L" + namer.getPersistableAsmClassName() + ";I" + argTypeDesc + ")" + argTypeDesc);
if (methodName.equals("getObjectField")) {
// Cast any object fields to the correct type
mv.visitTypeInsn(Opcodes.CHECKCAST, mmd.getTypeName().replace('.', '/'));
}
EnhanceUtils.addReturnForType(mv, mmd.getType());
mv.visitLabel(l1);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
if (cmd.isDetachable()) {
// "if (objPC.dnIsDetached() != false && ((BitSet) objPC.dnDetachedState[2]).get(5) != true)"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getIsDetachedMethodName(), "()Z");
Label l4 = new Label();
mv.visitJumpInsn(Opcodes.IFEQ, l4);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getDetachedStateFieldName(), "[Ljava/lang/Object;");
mv.visitInsn(Opcodes.ICONST_2);
mv.visitInsn(Opcodes.AALOAD);
mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/BitSet");
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/BitSet", "get", "(I)Z");
mv.visitJumpInsn(Opcodes.IFNE, l4);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getDetachedStateFieldName(), "[Ljava/lang/Object;");
mv.visitInsn(Opcodes.ICONST_3);
mv.visitInsn(Opcodes.AALOAD);
mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/BitSet");
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/BitSet", "get", "(I)Z");
mv.visitJumpInsn(Opcodes.IFNE, l4);
if (detachListener) {
mv.visitMethodInsn(Opcodes.INVOKESTATIC, namer.getDetachListenerAsmClassName(), "getInstance", "()L" + namer.getDetachListenerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitLdcInsn(mmd.getName());
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, namer.getDetachListenerAsmClassName(), "undetachedFieldAccess", "(Ljava/lang/Object;Ljava/lang/String;)V");
} else {
// "throw new JDODetachedFieldAccessException(...)"
mv.visitTypeInsn(Opcodes.NEW, namer.getDetachedFieldAccessExceptionAsmClassName());
mv.visitInsn(Opcodes.DUP);
mv.visitLdcInsn(Localiser.msg("005026", mmd.getName()));
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, namer.getDetachedFieldAccessExceptionAsmClassName(), "<init>", "(Ljava/lang/String;)V");
mv.visitInsn(Opcodes.ATHROW);
}
mv.visitLabel(l4);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
}
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getGetMethodPrefixMethodName() + mmd.getName(), "()" + fieldTypeDesc);
EnhanceUtils.addReturnForType(mv, mmd.getType());
Label endLabel = new Label();
mv.visitLabel(endLabel);
mv.visitLocalVariable(argNames[0], asmClassDesc, null, startLabel, endLabel, 0);
mv.visitMaxs(4, 1);
} else if ((mmd.getPersistenceFlags() & Persistable.CHECK_READ) == Persistable.CHECK_READ) {
// CHECK_READ - see method GetViaCheck
Label startLabel = new Label();
mv.visitLabel(startLabel);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getFlagsFieldName(), "B");
Label l1 = new Label();
mv.visitJumpInsn(Opcodes.IFLE, l1);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitJumpInsn(Opcodes.IFNULL, l1);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, namer.getStateManagerAsmClassName(), "isLoaded", "(L" + namer.getPersistableAsmClassName() + ";I)Z");
mv.visitJumpInsn(Opcodes.IFNE, l1);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getGetMethodPrefixMethodName() + mmd.getName(), "()" + fieldTypeDesc);
String methodName = "get" + EnhanceUtils.getTypeNameForPersistableMethod(mmd.getType()) + "Field";
String argTypeDesc = fieldTypeDesc;
if (methodName.equals("getObjectField")) {
argTypeDesc = EnhanceUtils.CD_Object;
}
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, namer.getStateManagerAsmClassName(), methodName, "(L" + namer.getPersistableAsmClassName() + ";I" + argTypeDesc + ")" + argTypeDesc);
if (methodName.equals("getObjectField")) {
// Cast any object fields to the correct type
mv.visitTypeInsn(Opcodes.CHECKCAST, mmd.getTypeName().replace('.', '/'));
}
EnhanceUtils.addReturnForType(mv, mmd.getType());
mv.visitLabel(l1);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
if (cmd.isDetachable()) {
// "if (objPC.dnIsDetached() != false && ((BitSet) objPC.dnDetachedState[2]).get(5) != true)"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getIsDetachedMethodName(), "()Z");
Label l4 = new Label();
mv.visitJumpInsn(Opcodes.IFEQ, l4);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getDetachedStateFieldName(), "[Ljava/lang/Object;");
mv.visitInsn(Opcodes.ICONST_2);
mv.visitInsn(Opcodes.AALOAD);
mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/BitSet");
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/BitSet", "get", "(I)Z");
mv.visitJumpInsn(Opcodes.IFNE, l4);
if (detachListener) {
mv.visitMethodInsn(Opcodes.INVOKESTATIC, namer.getDetachListenerAsmClassName(), "getInstance", "()L" + namer.getDetachListenerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitLdcInsn(mmd.getName());
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, namer.getDetachListenerAsmClassName(), "undetachedFieldAccess", "(Ljava/lang/Object;Ljava/lang/String;)V");
} else {
// "throw new JDODetachedFieldAccessException(...)"
mv.visitTypeInsn(Opcodes.NEW, namer.getDetachedFieldAccessExceptionAsmClassName());
mv.visitInsn(Opcodes.DUP);
mv.visitLdcInsn(Localiser.msg("005026", mmd.getName()));
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, namer.getDetachedFieldAccessExceptionAsmClassName(), "<init>", "(Ljava/lang/String;)V");
mv.visitInsn(Opcodes.ATHROW);
}
mv.visitLabel(l4);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
}
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getGetMethodPrefixMethodName() + mmd.getName(), "()" + fieldTypeDesc);
EnhanceUtils.addReturnForType(mv, mmd.getType());
Label endLabel = new Label();
mv.visitLabel(endLabel);
mv.visitLocalVariable(argNames[0], asmClassDesc, null, startLabel, endLabel, 0);
mv.visitMaxs(4, 1);
} else {
// NORMAL - see method GetNormal
Label startLabel = new Label();
mv.visitLabel(startLabel);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getGetMethodPrefixMethodName() + mmd.getName(), "()" + fieldTypeDesc);
EnhanceUtils.addReturnForType(mv, mmd.getType());
Label endLabel = new Label();
mv.visitLabel(endLabel);
mv.visitLocalVariable(argNames[0], asmClassDesc, null, startLabel, endLabel, 0);
mv.visitMaxs(1, 1);
}
mv.visitEnd();
}
use of org.datanucleus.metadata.AbstractClassMetaData in project datanucleus-core by datanucleus.
the class EnhancerPropertyGetterAdapter method visitMethodInsn.
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (mmd instanceof PropertyMetaData) {
// Check for any calls to getters/setters of properties that are from superclass(es)
String ownerClassName = owner.replace('/', '.');
AbstractClassMetaData cmd = enhancer.getClassMetaData();
if (!enhancer.getASMClassName().equals(owner)) {
String propName = ClassUtils.getFieldNameForJavaBeanGetter(name);
if (propName != null) {
boolean callingOverriddenSuperclassMethod = false;
while (cmd.getSuperAbstractClassMetaData() != null) {
cmd = cmd.getSuperAbstractClassMetaData();
if (cmd.getFullClassName().equals(ownerClassName)) {
AbstractMemberMetaData theMmd = cmd.getMetaDataForMember(mmd.getName());
if (theMmd != null) {
callingOverriddenSuperclassMethod = true;
break;
}
}
}
if (callingOverriddenSuperclassMethod) {
// Call dnGet{propName} in owner instead of "get{propName}"
String redirectMethodName = enhancer.getNamer().getGetMethodPrefixMethodName() + propName;
visitor.visitMethodInsn(opcode, owner, redirectMethodName, desc, itf);
return;
}
}
}
}
visitor.visitMethodInsn(opcode, owner, name, desc, itf);
}
use of org.datanucleus.metadata.AbstractClassMetaData in project datanucleus-core by datanucleus.
the class EnhancerPropertySetterAdapter method generateSetXXXMethod.
/**
* Convenience method to use the MethodVisitor to generate the code for the method setXXX() for the property with the specified MetaData.
* @param mv MethodVisitor
* @param mmd MetaData for the property
* @param asmClassName ASM class name for the owning class
* @param asmClassDesc ASM descriptor for the owning class
* @param namer Namer for methods etc
*/
public static void generateSetXXXMethod(MethodVisitor mv, AbstractMemberMetaData mmd, String asmClassName, String asmClassDesc, EnhancementNamer namer) {
String[] argNames = new String[] { "this", "val" };
String fieldTypeDesc = Type.getDescriptor(mmd.getType());
mv.visitCode();
AbstractClassMetaData cmd = mmd.getAbstractClassMetaData();
if ((mmd.getPersistenceFlags() & Persistable.MEDIATE_WRITE) == Persistable.MEDIATE_WRITE) {
// MEDIATE_WRITE - see method SetViaMediate
Label startLabel = new Label();
mv.visitLabel(startLabel);
// "if (objPC.dnStateManager == null) objPC.ZZZ = zzz;"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
Label l1 = new Label();
mv.visitJumpInsn(Opcodes.IFNONNULL, l1);
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addLoadForType(mv, mmd.getType(), 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getSetMethodPrefixMethodName() + mmd.getName(), "(" + fieldTypeDesc + ")V");
Label l3 = new Label();
mv.visitJumpInsn(Opcodes.GOTO, l3);
mv.visitLabel(l1);
// "else objPC.dnStateManager.setYYYField(objPC, 0, objPC.ZZZ, zzz);"
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getGetMethodPrefixMethodName() + mmd.getName(), "()" + fieldTypeDesc);
EnhanceUtils.addLoadForType(mv, mmd.getType(), 1);
String methodName = "set" + EnhanceUtils.getTypeNameForPersistableMethod(mmd.getType()) + "Field";
String argTypeDesc = fieldTypeDesc;
if (methodName.equals("setObjectField")) {
argTypeDesc = EnhanceUtils.CD_Object;
}
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, namer.getStateManagerAsmClassName(), methodName, "(L" + namer.getPersistableAsmClassName() + ";I" + argTypeDesc + argTypeDesc + ")V");
mv.visitLabel(l3);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
if (cmd.isDetachable()) {
// "if (objPC.dnIsDetached() == true)"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getIsDetachedMethodName(), "()Z");
Label l6 = new Label();
mv.visitJumpInsn(Opcodes.IFEQ, l6);
// "((BitSet) objPC.dnDetachedState[3]).set(0);"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getDetachedStateFieldName(), "[Ljava/lang/Object;");
mv.visitInsn(Opcodes.ICONST_3);
mv.visitInsn(Opcodes.AALOAD);
mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/BitSet");
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/BitSet", "set", "(I)V");
mv.visitLabel(l6);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
}
mv.visitInsn(Opcodes.RETURN);
Label endLabel = new Label();
mv.visitLabel(endLabel);
mv.visitLocalVariable(argNames[0], asmClassDesc, null, startLabel, endLabel, 0);
mv.visitLocalVariable(argNames[1], fieldTypeDesc, null, startLabel, endLabel, 1);
mv.visitMaxs(5, 2);
} else if ((mmd.getPersistenceFlags() & Persistable.CHECK_WRITE) == Persistable.CHECK_WRITE) {
// CHECK_WRITE - see method SetViaCheck
Label startLabel = new Label();
mv.visitLabel(startLabel);
// "if (objPC.dnFlags != 0 && objPC.dnStateManager != null)"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getFlagsFieldName(), "B");
Label l1 = new Label();
mv.visitJumpInsn(Opcodes.IFEQ, l1);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitJumpInsn(Opcodes.IFNULL, l1);
// "objPC.dnStateManager.setYYYField(objPC, 8, objPC.ZZZ, val);"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getStateManagerFieldName(), "L" + namer.getStateManagerAsmClassName() + ";");
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getGetMethodPrefixMethodName() + mmd.getName(), "()" + fieldTypeDesc);
EnhanceUtils.addLoadForType(mv, mmd.getType(), 1);
String methodName = "set" + EnhanceUtils.getTypeNameForPersistableMethod(mmd.getType()) + "Field";
String argTypeDesc = fieldTypeDesc;
if (methodName.equals("setObjectField")) {
argTypeDesc = EnhanceUtils.CD_Object;
}
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, namer.getStateManagerAsmClassName(), methodName, "(L" + namer.getPersistableAsmClassName() + ";I" + argTypeDesc + argTypeDesc + ")V");
Label l3 = new Label();
mv.visitJumpInsn(Opcodes.GOTO, l3);
mv.visitLabel(l1);
// "objPC.text = val;"
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addLoadForType(mv, mmd.getType(), 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getSetMethodPrefixMethodName() + mmd.getName(), "(" + fieldTypeDesc + ")V");
if (cmd.isDetachable()) {
// "if (objPC.dnIsDetached() == true) ((BitSet) objPC.dnDetachedState[3]).set(8);"
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getIsDetachedMethodName(), "()Z");
mv.visitJumpInsn(Opcodes.IFEQ, l3);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(Opcodes.GETFIELD, asmClassName, namer.getDetachedStateFieldName(), "[Ljava/lang/Object;");
mv.visitInsn(Opcodes.ICONST_3);
mv.visitInsn(Opcodes.AALOAD);
mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/BitSet");
EnhanceUtils.addBIPUSHToMethod(mv, mmd.getFieldId());
if (cmd.getPersistableSuperclass() != null) {
mv.visitFieldInsn(Opcodes.GETSTATIC, asmClassName, namer.getInheritedFieldCountFieldName(), "I");
mv.visitInsn(Opcodes.IADD);
}
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/BitSet", "set", "(I)V");
}
mv.visitLabel(l3);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitInsn(Opcodes.RETURN);
Label endLabel = new Label();
mv.visitLabel(endLabel);
mv.visitLocalVariable(argNames[0], asmClassDesc, null, startLabel, endLabel, 0);
mv.visitLocalVariable(argNames[1], fieldTypeDesc, null, startLabel, endLabel, 1);
mv.visitMaxs(5, 2);
} else {
// NORMAL - see method SetNormal
Label startLabel = new Label();
mv.visitLabel(startLabel);
mv.visitVarInsn(Opcodes.ALOAD, 0);
EnhanceUtils.addLoadForType(mv, mmd.getType(), 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, asmClassName, namer.getSetMethodPrefixMethodName() + mmd.getName(), "(" + fieldTypeDesc + ")V");
mv.visitInsn(Opcodes.RETURN);
Label endLabel = new Label();
mv.visitLabel(endLabel);
mv.visitLocalVariable(argNames[0], asmClassDesc, null, startLabel, endLabel, 0);
mv.visitLocalVariable(argNames[1], fieldTypeDesc, null, startLabel, endLabel, 1);
mv.visitMaxs(2, 2);
}
mv.visitEnd();
}
use of org.datanucleus.metadata.AbstractClassMetaData in project datanucleus-core by datanucleus.
the class ImplementationGenerator method createPropertyFields.
/**
* Creates fields for the properties of this class and super classes.
*/
protected void createPropertyFields() {
AbstractClassMetaData acmd = inputCmd;
do {
createPropertyFields(acmd);
acmd = acmd.getSuperAbstractClassMetaData();
} while (acmd != null);
}
use of org.datanucleus.metadata.AbstractClassMetaData in project datanucleus-core by datanucleus.
the class ImplementationGenerator method createPropertyMethods.
/**
* Create getters and setters methods for this class and super classes
*/
protected void createPropertyMethods() {
AbstractClassMetaData acmd = inputCmd;
do {
createPropertyMethods(acmd);
acmd = acmd.getSuperAbstractClassMetaData();
} while (acmd != null);
}
Aggregations