Author: allee8285
Date: Mon Apr 15 22:01:24 2013
New Revision: 1468245

URL: http://svn.apache.org/r1468245
Log:
OPENJPA-2368 Revert accidental inclusions to the last commit

Removed:
    
openjpa/branches/2.2.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestCacheRefresh.java
Modified:
    
openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java

Modified: 
openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=1468245&r1=1468244&r2=1468245&view=diff
==============================================================================
--- 
openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
 (original)
+++ 
openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
 Mon Apr 15 22:01:24 2013
@@ -115,7 +115,7 @@ import serp.util.Strings;
  *
  * @author Abe White
  */
-public class PCEnhancer {
+public class PCEnhancer { 
     // Designates a version for maintaining compatbility when PCEnhancer
     // modifies enhancement that can break serialization or other contracts
     // Each enhanced class will return the value of this field via
@@ -215,7 +215,7 @@ public class PCEnhancer {
     private boolean _bcsConfigured = false;
 
     private boolean _optimizeIdCopy = false; // whether to attempt optimizing 
id copy
-
+    
     /**
      * Constructor. Supply configuration and type to enhance. This will look
      * up the metadata for <code>type</code> from <code>conf</code>'s
@@ -284,7 +284,7 @@ public class PCEnhancer {
         } else
             _repos = repos;
         _meta = _repos.getMetaData(type.getType(), loader, false);
-
+        
         configureOptimizeIdCopy();
     }
 
@@ -1441,7 +1441,7 @@ public class PCEnhancer {
                         // pcVersionInit = true;
                         loadManagedInstance(code, false);
                         code.constant().setValue(1);
-                        putfield(code, null, VERSION_INIT_STR, boolean.class, 
fmds[i]);
+                        putfield(code, null, VERSION_INIT_STR, boolean.class);
                     }
                 }
                 code.vreturn();
@@ -1519,9 +1519,7 @@ public class PCEnhancer {
      */
     private int beginSwitchMethod(String name, Code code) {
         boolean copy = (PRE + "CopyField").equals(name);
-        boolean setField = (PRE + "ReadExternalSetField").equals(name);
-        boolean returnObject = (PRE + "WriteExternalGetField").equals(name);
-        int fieldNumber = (copy || setField) ? 1 : 0;
+        int fieldNumber = (copy) ? 1 : 0;
 
         int relLocal = code.getNextLocalsIndex();
         if (getCreateSubclass()) {
@@ -1543,23 +1541,17 @@ public class PCEnhancer {
         if (_meta.getPCSuperclass() != null) {
             loadManagedInstance(code, false);
             String[] args;
-            if (copy || setField) {
-                args = new String[]{
-                    copy ? getType(_meta.getPCSuperclassMetaData()).getName() 
: Object.class.getName(),
-                    int.class.getName() };
+            if (copy) {
+                args = new String[]{ getType(_meta.getPCSuperclassMetaData()).
+                    getName(), int.class.getName() };
                 code.aload().setParam(0);
-            } else {
+            } else
                 args = new String[]{ int.class.getName() };
-            }
             code.iload().setParam(fieldNumber);
             code.invokespecial().setMethod(getType(_meta.
                 getPCSuperclassMetaData()).getName(), name, 
-                (returnObject ? Object.class : void.class).getName(), args);
-            if( returnObject ) {
-                code.areturn();
-            } else {
-                code.vreturn();
-            }
+                void.class.getName(), args);
+            code.vreturn();
         } else
             throwException(code, IllegalArgumentException.class);
 
@@ -2026,7 +2018,7 @@ public class PCEnhancer {
         // id.<field> = pc.<field>;
         FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields()
             : _meta.getDeclaredFields();
-        Class<?> type;
+        Class<?> type; 
         String name;
         Field field;
         Method setter;
@@ -3185,15 +3177,14 @@ public class PCEnhancer {
         // ##### limiting to JPA @Transient limitations
         FieldMetaData[] fmds = _meta.getFields();
         for (int i = 0; i < fmds.length; i++) {
-            FieldMetaData fmd = fmds[i];
-            if (fmd.isTransient())
+            if (fmds[i].isTransient())
                 continue;
             // o.<field> = this.<field> (or reflective analog)
             code.dup(); // for putfield
             code.aload().setThis(); // for getfield
-            getfield(code, _managedType, fmd.getName(), fmd);
-            putfield(code, _managedType, fmd.getName(),
-                fmd.getDeclaredType(), fmd);
+            getfield(code, _managedType, fmds[i].getName());
+            putfield(code, _managedType, fmds[i].getName(),
+                fmds[i].getDeclaredType());
         }
 
         code.areturn().setType(Object.class);
@@ -3414,7 +3405,7 @@ public class PCEnhancer {
                 // return true
                 // else return null; //  (returning null because we don't know 
the correct answer)
                 loadManagedInstance(code, false);
-                getfield(code, null, VERSION_INIT_STR, null);
+                getfield(code, null, VERSION_INIT_STR);
                 ifins = code.ifeq();
                 code.getstatic().setField(Boolean.class, "TRUE", 
Boolean.class);
                 code.areturn();
@@ -3887,7 +3878,7 @@ public class PCEnhancer {
             loadManagedInstance(code, true);
             code.constant().setValue(1);
             // pcVersionInit = true;
-            putfield(code, null, VERSION_INIT_STR, boolean.class, fmd);   
+            putfield(code, null, VERSION_INIT_STR, boolean.class);   
         }
         code.vreturn();
 
@@ -3980,7 +3971,7 @@ public class PCEnhancer {
             // return pcDetachedState;
             loadManagedInstance(code, false);
             getfield(code, _managedType.getProject().loadClass(declarer),
-                name, null);
+                name);
         } else
             code.constant().setNull();
         code.areturn();
@@ -3997,31 +3988,13 @@ public class PCEnhancer {
             loadManagedInstance(code, false);
             code.aload().setParam(0);
             putfield(code, _managedType.getProject().loadClass(declarer),
-                name, Object.class, null);
+                name, Object.class);
         }
         code.vreturn();
         code.calculateMaxStack();
         code.calculateMaxLocals();
     }
 
-    private BCField findFieldInManagedTypeHierarchy(BCClass declarer, String 
fieldName) {
-        // next, find the field in the managed type hierarchy
-        BCField field = null;
-        outer: for (BCClass bc = _pc; bc != null; bc = bc.getSuperclassBC()) {
-            BCField[] fields = AccessController
-                .doPrivileged(J2DoPrivHelper.getBCClassFieldsAction(bc, 
fieldName));
-            for (int i = 0; i < fields.length; i++) {
-                field = fields[i];
-                // if we reach a field declared in this type, then this is the
-                // most-masking field, and is the one that we want.
-                if (fields[i].getDeclarer() == declarer) {
-                    break outer;
-                }
-            }
-        }
-        return field;
-    }
-
     /**
      * Adds to <code>code</code> the instructions to get field
      * <code>attrName</code> declared in type <code>declarer</code>
@@ -4030,7 +4003,7 @@ public class PCEnhancer {
      * The instance to access must already be on the top of the
      * stack when this is invoked.
      */
-    private void getfield(Code code, BCClass declarer, String attrName, 
FieldMetaData fmd) {
+    private void getfield(Code code, BCClass declarer, String attrName) {
         if (declarer == null)
             declarer = _managedType;
 
@@ -4038,7 +4011,20 @@ public class PCEnhancer {
         String fieldName = toBackingFieldName(attrName);
 
         // next, find the field in the managed type hierarchy
-        BCField field = findFieldInManagedTypeHierarchy(declarer, fieldName);
+        BCField field = null;
+        outer: for (BCClass bc = _pc; bc != null; bc = bc.getSuperclassBC()) {
+            BCField[] fields = AccessController
+                .doPrivileged(J2DoPrivHelper.getBCClassFieldsAction(bc,
+                    fieldName));
+            for (int i = 0; i < fields.length; i++) {
+                field = fields[i];
+                // if we reach a field declared in this type, then this is the
+                // most-masking field, and is the one that we want.
+                if (fields[i].getDeclarer() == declarer) {
+                    break outer;
+                }
+            }
+        }
 
         if (getCreateSubclass() && code.getMethod().getDeclarer() == _pc
             && (field == null || !field.isPublic())) {
@@ -4051,7 +4037,7 @@ public class PCEnhancer {
             code.invokestatic().setMethod(Reflection.class,
                 "findField", Field.class, new Class[] {
                 Class.class, String.class, boolean.class });
-            Class<?> type = _meta.getField(attrName).getDeclaredType();
+            Class type = _meta.getField(attrName).getDeclaredType();
             try {
                 code.invokestatic().setMethod(
                     getReflectionGetterMethod(type, Field.class));
@@ -4062,23 +4048,8 @@ public class PCEnhancer {
             if (!type.isPrimitive() && type != Object.class)
                 code.checkcast().setType(type);
         } else {
-            if (!getRedefine() &&
-                    (field.getAccessFlags() & Constants.ACCESS_PRIVATE) != 0 
&& _pc != field.getDeclarer()
-                    && fmd != null) {
-                // private field in declaring super class
-                int fieldIndex = fmd.getIndex();
-                code.constant().setValue(fieldIndex);
-                code.invokevirtual().setMethod(PRE + "WriteExternalGetField", 
Object.class, 
-                    new Class[] {int.class});
-                if (fmd.getDeclaredType().isPrimitive()) {
-                    code.checkcast().setType(toPrimitiveWrapper(fmd));
-                    Class<?> typeClass = unwrapSingleFieldIdentity(fmd);
-                    code.invokevirtual().setMethod(typeClass.getName() + 
"Value", typeClass, null);
-                }
-            } else {
-                code.getfield().setField(declarer.getName(), fieldName,
-                    field.getType().getName());
-            }
+            code.getfield().setField(declarer.getName(), fieldName,
+                field.getType().getName());
         }
     }
 
@@ -4092,7 +4063,7 @@ public class PCEnhancer {
      * and the instance to load into must be second.
      */
     private void putfield(Code code, BCClass declarer, String attrName,
-        Class<?> fieldType, FieldMetaData fmd) {
+        Class fieldType) {
         if (declarer == null)
             declarer = _managedType;
 
@@ -4113,127 +4084,9 @@ public class PCEnhancer {
                     fieldType.isPrimitive() ? fieldType : Object.class, 
                     Field.class });
         } else {
-            BCField field = findFieldInManagedTypeHierarchy(declarer, 
fieldName);
-            if ((field.getAccessFlags() & Constants.ACCESS_PRIVATE) != 0 && 
_pc != field.getDeclarer()
-                    && fmd != null) {
-                // private field in declaring super class
-                if (fmd.getDeclaredType().isPrimitive()) {
-                    Class<?> typeClass = toPrimitiveWrapper(fmd);
-                    code.invokestatic().setMethod(typeClass, "valueOf", 
typeClass,
-                            new Class[] { unwrapSingleFieldIdentity(fmd) });
-                }
-                int fieldIndex = fmd.getIndex();
-                code.constant().setValue(fieldIndex);
-                code.invokevirtual().setMethod(PRE + "ReadExternalSetField", 
void.class, 
-                    new Class[] {
-                        Object.class,
-                        int.class});
-            } else {
-                code.putfield()
-                    .setField(declarer.getName(), fieldName, 
fieldType.getName());
-            }
-        }
-    }
-
-    /**
-     * Adds the {@link PersistenceCapable#pcReadExternalSetField} methods to 
the bytecode.
-     */
-    private void addReadExternalSetField()
-        throws NoSuchMethodException {
-        // protected void pcReadExternalSetField (int fieldNumber, Object 
value)
-        BCMethod method = _pc.declareMethod(PRE + "ReadExternalSetField", 
void.class,
-            new Class[]{ Object.class, int.class });
-        method.makeProtected();
-        Code code = method.getCode(true);
-
-        // adds everything through the switch ()
-        int relLocal = beginSwitchMethod(PRE + "ReadExternalSetField", code);
-
-        // if no fields in this inst, just throw exception
-        FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields()
-            : _meta.getDeclaredFields();
-        if (fmds.length == 0)
-            throwException(code, IllegalArgumentException.class);
-        else {
-            // switch (val)
-            code.iload().setLocal(relLocal);
-            TableSwitchInstruction tabins = code.tableswitch();
-            tabins.setLow(0);
-            tabins.setHigh(fmds.length - 1);
-
-            // <field> = ((fieldType)value);
-            for (int i = 0; i < fmds.length; i++) {
-                FieldMetaData fmd = fmds[i];
-                // for the putfield call below.
-                tabins.addTarget(loadManagedInstance(code, false, fmd));
-                code.aload().setParam(0);
-
-                code.checkcast().setType(toPrimitiveWrapper(fmd));
-                if (fmd.getDeclaredType().isPrimitive()) {
-                    Class<?> typeClass = unwrapSingleFieldIdentity(fmd);
-                    code.invokevirtual().setMethod(toPrimitiveWrapper(fmd),
-                            typeClass.getName() + "Value", typeClass, null );
-                }
-                putfield(code, null, fmd.getName(), fmd.getDeclaredType(), 
fmd);
-
-                code.vreturn();
-            }
-            // default: throw new IllegalArgumentException ()
-            tabins.setDefaultTarget(throwException
-                (code, IllegalArgumentException.class));
-        }
-        code.calculateMaxStack();
-        code.calculateMaxLocals();
-    }
-
-    /**
-     * Adds the {@link PersistenceCapable#pcWriteExternalGetField} methods to 
the bytecode.
-     */
-    private void addWriteExternalGetField()
-        throws NoSuchMethodException {
-        // protected void pcWriteExternalGetField (int fieldNumber)
-        BCMethod method = _pc.declareMethod(PRE + "WriteExternalGetField", 
Object.class,
-            new Class[]{ int.class });
-        method.makeProtected();
-        Code code = method.getCode(true);
-
-        // adds everything through the switch ()
-        int relLocal = beginSwitchMethod(PRE + "WriteExternalGetField", code);
-
-        // if no fields in this inst, just throw exception
-        FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields()
-            : _meta.getDeclaredFields();
-        if (fmds.length == 0)
-            throwException(code, IllegalArgumentException.class);
-        else {
-            // switch (val)
-            code.iload().setLocal(relLocal);
-            TableSwitchInstruction tabins = code.tableswitch();
-            tabins.setLow(0);
-            tabins.setHigh(fmds.length - 1);
-
-            // <field> = ((fieldType)value);
-            for (int i = 0; i < fmds.length; i++) {
-                FieldMetaData fmd = fmds[i];
-                Class<?> type = fmd.getDeclaredType();
-                // for the putfield call below.
-                tabins.addTarget(loadManagedInstance(code, false, fmd));
-
-                code.getfield().setField(fmd.getName(), type);
-                // we only have special signatures for primitives and Strings
-                if (type.isPrimitive()) {
-                    Class<?> typeClass = toPrimitiveWrapper(fmd);
-                    code.invokestatic().setMethod(typeClass, "valueOf", 
typeClass,
-                            new Class[] { unwrapSingleFieldIdentity(fmd) });
-                }
-                code.areturn();
-            }
-            // default: throw new IllegalArgumentException ()
-            tabins.setDefaultTarget(throwException
-                (code, IllegalArgumentException.class));
+            code.putfield()
+                .setField(declarer.getName(), fieldName, fieldType.getName());
         }
-        code.calculateMaxStack();
-        code.calculateMaxLocals();
     }
 
     /**
@@ -4306,10 +4159,8 @@ public class PCEnhancer {
                 unmgd.add(fields[i]);
         }
 
-        addReadExternalSetField();
         addReadExternal(parentDetachable, detachedState);
         addReadUnmanaged(unmgd, parentDetachable);
-        addWriteExternalGetField();
         addWriteExternal(parentDetachable, detachedState);
         addWriteUnmanaged(unmgd, parentDetachable);
     }
@@ -4466,7 +4317,7 @@ public class PCEnhancer {
         if (!type.isPrimitive() && type != Object.class)
             code.checkcast().setType(type);
         if (fmd == null)
-            putfield(code, null, fieldName, type, fmd);
+            putfield(code, null, fieldName, type);
         else {
             addSetManagedValueCode(code, fmd);
             switch (fmd.getDeclaredTypeCode()) {
@@ -4650,7 +4501,7 @@ public class PCEnhancer {
         code.aload().setParam(0);
         loadManagedInstance(code, false);
         if (fmd == null)
-            getfield(code, null, fieldName, fmd);
+            getfield(code, null, fieldName);
         else
             addGetManagedValueCode(code, fmd);
         Class[] args = new Class[]{ type };
@@ -4688,7 +4539,7 @@ public class PCEnhancer {
         // since it would sacrifice lazy loading and efficient dirty tracking.
 
         if (getRedefine() || isFieldAccess(fmd)) {
-            getfield(code, null, fmd.getName(), fmd);
+            getfield(code, null, fmd.getName());
         } else if (getCreateSubclass()) {
             // property access, and we're not redefining. If we're operating
             // on an instance that is definitely the same type as 'this', then
@@ -4698,7 +4549,7 @@ public class PCEnhancer {
                 Method meth = (Method) fmd.getBackingMember();
                 code.invokespecial().setMethod(meth);
             } else {
-                getfield(code, null, fmd.getName(), fmd);
+                getfield(code, null, fmd.getName());
             }
         } else {
             // regular enhancement + property access
@@ -4724,7 +4575,7 @@ public class PCEnhancer {
         // since it would sacrifice lazy loading and efficient dirty tracking.
 
         if (getRedefine() || isFieldAccess(fmd)) {
-            putfield(code, null, fmd.getName(), fmd.getDeclaredType(), fmd);
+            putfield(code, null, fmd.getName(), fmd.getDeclaredType());
         } else if (getCreateSubclass()) {
             // property access, and we're not redefining. invoke the
             // superclass method to bypass tracking.
@@ -5020,7 +4871,7 @@ public class PCEnhancer {
         BCClass bc;
         PCEnhancer enhancer;
         Collection persAwareClasses = new HashSet();
-
+        
         int status;
         for (Iterator itr = classes.iterator(); itr.hasNext();) {
             Object o = itr.next();


Reply via email to