openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ss...@apache.org
Subject svn commit: r511998 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/...
Date Mon, 26 Feb 2007 20:46:05 GMT
Author: ssegu
Date: Mon Feb 26 12:46:03 2007
New Revision: 511998

URL: http://svn.apache.org/viewvc?view=rev&rev=511998
Log:
OPENJPA-151.

Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PersistenceCapable.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/StateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ProxySetupStateManager.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
Mon Feb 26 12:46:03 2007
@@ -945,10 +945,6 @@
         // StateManager implementation
         ///////////////////////////////
 
-        public byte replaceFlags() {
-            throw new InternalException();
-        }
-
         public Object getPCPrimaryKey(Object oid, int field) {
             throw new InternalException();
         }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
Mon Feb 26 12:46:03 2007
@@ -95,6 +95,11 @@
  * @author Abe White
  */
 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
+    // public int getEnhancementContractVersion()
+    public static final int ENHANCER_VERSION = 2;
 
     public static final int ENHANCE_NONE = 0;
     public static final int ENHANCE_AWARE = 2 << 0;
@@ -716,7 +721,6 @@
         if (_meta.getPCSuperclass() == null) {
             addStockMethods();
             addGetVersionMethod();
-            addReplaceFlagsMethod();
             addReplaceStateManagerMethod();
 
             if (_meta.getIdentityType() != ClassMetaData.ID_APPLICATION)
@@ -841,11 +845,6 @@
         code.aload().setParam(0);
         code.putfield().setField(SM, SMTYPE);
 
-        // pc.pcFlags = LOAD_REQUIRED
-        code.aload().setLocal(inst);
-        code.constant().setValue(PersistenceCapable.LOAD_REQUIRED);
-        code.putfield().setField(PRE + "Flags", byte.class);
-
         // copy key fields from oid
         if (oid) {
             code.aload().setLocal(inst);
@@ -1330,35 +1329,6 @@
     }
 
     /**
-     * Adds the {@link PersistenceCapable#pcReplaceFlags}
-     * method to the bytecode.
-     */
-    private void addReplaceFlagsMethod() {
-        // public final void pcReplaceFlags ()
-        BCMethod method = _pc.declareMethod(PRE + "ReplaceFlags",
-            void.class, null);
-        Code code = method.getCode(true);
-
-        // if (pcStateManager != null)
-        loadManagedInstance(code, false);
-        code.getfield().setField(SM, SMTYPE);
-        JumpInstruction ifins = code.ifnonnull();
-        code.vreturn();
-
-        // pcFlags = pcStateManager.replaceFlags ();
-        ifins.setTarget(loadManagedInstance(code, false));
-        loadManagedInstance(code, false);
-        code.getfield().setField(SM, SMTYPE);
-        code.invokeinterface().setMethod(SMTYPE, "replaceFlags",
-            byte.class, null);
-        code.putfield().setField(PRE + "Flags", byte.class);
-        code.vreturn();
-
-        code.calculateMaxStack();
-        code.calculateMaxLocals();
-    }
-
-    /**
      * Adds the {@link PersistenceCapable#pcReplaceStateManager}
      * method to the bytecode.
      */
@@ -2157,6 +2127,9 @@
         // make the class implement PersistenceCapable
         _pc.declareInterface(PCTYPE);
 
+        // add a version stamp
+        addGetEnhancementContractVersionMethod();
+
         // find the default constructor
         BCMethod method = _pc.getDeclaredMethod("<init>", (String[]) null);
 
@@ -2197,8 +2170,6 @@
      * <li><code>private static byte[] pcFieldFlags</code></li>
      * <li><code>protected transient StateManager pcStateManager</code>
      * if no PersistenceCapable superclass present)</li>
-     * <li><code>protected transient byte pcFlags</code>
-     * if no PersistenceCapable superclass present)</li>
      * </ul>
      */
     private void addFields() {
@@ -2212,10 +2183,6 @@
             BCField field = _pc.declareField(SM, SMTYPE);
             field.makeProtected();
             field.setTransient(true);
-
-            field = _pc.declareField(PRE + "Flags", byte.class);
-            field.makeProtected();
-            field.setTransient(true);
         }
     }
 
@@ -2724,10 +2691,10 @@
 
     /**
      * Adds bytecode modifying the cloning behavior of the class being
-     * enhanced to correctly replace the <code>pcFlags</code> and
-     * <code>pcStateManager</code> instance fields of any clone created with
-     * their default values. Also, if this class is the base PC type
-     * and does not declared a clone method, one will be added.
+     * enhanced to correctly replace the <code>pcStateManager</code> 
+     * instance fields of any clone created with their default values. 
+     * Also, if this class is the base PC type and does not declared 
+     * a clone method, one will be added.
      */
     private void addCloningCode() {
         if (_meta.getPCSuperclass() != null)
@@ -2781,12 +2748,6 @@
             code.constant().setNull();
             code.putfield().setField(SM, SMTYPE);
 
-            // ((<type>) clone).pcFlags = 0;
-            code.dup();
-            code.checkcast().setType(_pc);
-            code.constant().setValue(PersistenceCapable.READ_WRITE_OK);
-            code.putfield().setField(PRE + "Flags", byte.class);
-
             // if modified, increase stack
             code.calculateMaxStack();
             code.calculateMaxLocals();
@@ -2860,23 +2821,10 @@
             return;
         }
 
-        // dfg: if (inst.pcFlags <= 0) return inst.<field>;
-        JumpInstruction ifins = null;
-        if ((fieldFlag & PersistenceCapable.CHECK_READ) > 0) {
-            loadManagedInstance(code, true);
-            code.getfield().setField(PRE + "Flags", byte.class);
-            ifins = code.ifgt();
-            loadManagedInstance(code, true);
-            addGetManagedValueCode(code, fmd);
-            code.xreturn().setType(fmd.getDeclaredType());
-        }
-
         // if (inst.pcStateManager == null) return inst.<field>;
         Instruction ins = loadManagedInstance(code, true);
-        if (ifins != null)
-            ifins.setTarget(ins);
         code.getfield().setField(SM, SMTYPE);
-        ifins = code.ifnonnull();
+        JumpInstruction ifins = code.ifnonnull();
         loadManagedInstance(code, true);
         addGetManagedValueCode(code, fmd);
         code.xreturn().setType(fmd.getDeclaredType());
@@ -2919,25 +2867,10 @@
         // PCEnhancer uses static methods; PCSubclasser does not.
         int firstParamOffset = getAccessorParameterOffset();
 
-        // dfg: if (inst.pcFlags == 0) inst.<field> = value;
-        JumpInstruction ifins = null;
-        byte fieldFlag = getFieldFlag(fmd);
-        if ((fieldFlag & PersistenceCapable.CHECK_WRITE) > 0) {
-            loadManagedInstance(code, true);
-            code.getfield().setField(PRE + "Flags", byte.class);
-            ifins = code.ifne();
-            loadManagedInstance(code, true);
-            code.xload().setParam(firstParamOffset);
-            addSetManagedValueCode(code, fmd);
-            code.vreturn();
-        }
-
         // if (inst.pcStateManager == null) inst.<field> = value;
         Instruction ins = loadManagedInstance(code, true);
-        if (ifins != null)
-            ifins.setTarget(ins);
         code.getfield().setField(SM, SMTYPE);
-        ifins = code.ifnonnull();
+        JumpInstruction ifins = code.ifnonnull();
         loadManagedInstance(code, true);
         code.xload().setParam(firstParamOffset);
         addSetManagedValueCode(code, fmd);
@@ -3505,6 +3438,19 @@
         newsetter.makePrivate();
         transferCodeAttributes(setter, newsetter);
         return setter;
+    }
+
+    private void addGetEnhancementContractVersionMethod() {
+        // public int getEnhancementContractVersion()
+        BCMethod method = _pc.declareMethod(PRE + 
+                "GetEnhancementContractVersion", int.class, null);
+        method.makePublic();
+        Code code = method.getCode(true);
+        code.constant().setValue(ENHANCER_VERSION);
+        code.ireturn();
+        code.calculateMaxStack();
+        code.calculateMaxLocals();
+        return;
     }
 
     /**

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PersistenceCapable.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PersistenceCapable.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PersistenceCapable.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PersistenceCapable.java
Mon Feb 26 12:46:03 2007
@@ -34,6 +34,8 @@
 
     public static final Object DESERIALIZED = new Object();
 
+    int pcGetEnhancementContractVersion();
+
     Object pcGetGenericContext();
 
     StateManager pcGetStateManager();
@@ -47,8 +49,6 @@
     void pcReplaceField(int fieldIndex);
 
     void pcReplaceFields(int[] fieldIndex);
-
-    void pcReplaceFlags();
 
     void pcCopyFields(Object fromObject, int[] fields);
 

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/StateManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/StateManager.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/StateManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/StateManager.java
Mon Feb 26 12:46:03 2007
@@ -41,11 +41,6 @@
     public Object getPCPrimaryKey(Object oid, int field);
 
     /**
-     * Change internal flags.
-     */
-    public byte replaceFlags();
-
-    /**
      * Change state manager.
      */
     public StateManager replaceStateManager(StateManager sm);

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
Mon Feb 26 12:46:03 2007
@@ -334,10 +334,6 @@
         return null;
     }
 
-    public byte replaceFlags() {
-        return PersistenceCapable.MEDIATE_WRITE;
-    }
-
     public Object getPCPrimaryKey(Object oid, int field) {
         throw new UnsupportedOperationException();
     }
@@ -939,5 +935,5 @@
     public void unlock() {
         if (_lock != null)
             _lock.unlock();
-	}
+    }
 }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java
Mon Feb 26 12:46:03 2007
@@ -403,10 +403,6 @@
         throw new UnsupportedOperationException();
     }
 
-    public byte replaceFlags() {
-        throw new UnsupportedOperationException();
-    }
-
     public StateManager replaceStateManager(StateManager sm) {
         return sm;
     }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java
Mon Feb 26 12:46:03 2007
@@ -71,10 +71,6 @@
         throw new UnsupportedOperationException();
     }
 
-    public byte replaceFlags() {
-        throw new UnsupportedOperationException();
-    }
-
     public StateManager replaceStateManager(StateManager sm) {
         throw new UnsupportedOperationException();
     }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Mon Feb 26 12:46:03 2007
@@ -287,7 +287,6 @@
         }
 
         pc.pcSetDetachedState(null);
-        pc.pcReplaceFlags();
         _pc = pc;
 
         if (_oid instanceof OpenJPAId)

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ProxySetupStateManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ProxySetupStateManager.java?view=diff&rev=511998&r1=511997&r2=511998
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ProxySetupStateManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ProxySetupStateManager.java
Mon Feb 26 12:46:03 2007
@@ -85,10 +85,6 @@
         throw new UnsupportedOperationException();
     }
 
-    public byte replaceFlags() {
-        throw new InternalException();
-    }
-
     public StateManager replaceStateManager(StateManager sm) {
         throw new InternalException();
     }



Mime
View raw message