Created
April 13, 2009 13:38
-
-
Save ArtemGr/94447 to your computer and use it in GitHub Desktop.
NUCENHANCER-34 patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/java/org/datanucleus/enhancer/asm/JdoMethodAdapter.java | |
=================================================================== | |
--- src/java/org/datanucleus/enhancer/asm/JdoMethodAdapter.java (revision 5997) | |
+++ src/java/org/datanucleus/enhancer/asm/JdoMethodAdapter.java (working copy) | |
@@ -80,20 +80,28 @@ | |
if (enhancer.isPersistenceCapable(ownerName)) | |
{ | |
AbstractClassMetaData cmd = null; | |
+ boolean fieldInThisClass; | |
if (enhancer.getClassMetaData().getFullClassName().equals(ownerName)) | |
{ | |
// Same class so use the input MetaData | |
cmd = enhancer.getClassMetaData(); | |
+ fieldInThisClass = true; | |
} | |
else | |
{ | |
cmd = enhancer.getClassMetaData().getMetaDataManager().getMetaDataForClass( | |
ownerName, enhancer.getClassLoaderResolver()); | |
+ fieldInThisClass = false; | |
} | |
AbstractMemberMetaData fmd = cmd.getMetaDataForMember(name); | |
if (fmd != null && !fmd.isStatic() && !fmd.isFinal() && | |
fmd.getPersistenceModifier() != FieldPersistenceModifier.NONE && | |
- fmd.getJdoFieldFlag() != 0 && fmd instanceof FieldMetaData) | |
+ fmd.getJdoFieldFlag() != 0 && fmd instanceof FieldMetaData && | |
+ // If the field access is in this class and this is the constructor then don't enhance it. | |
+ // This is because this object is not connected to a StateManager nor is it detached. | |
+ // Also languages like Scala don't necessarily initialise superclasses first and so | |
+ // enhancing here would cause issues. | |
+ (!fieldInThisClass || !(methodName.equals("<init>")))) | |
{ | |
// Field being accessed has its access mediated by the enhancer, so intercept it | |
// Make sure we address the field being in the class it is actually in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment