db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r231513 - in /incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer: core/Builder.java generator/ImplHelper.java
Date Thu, 11 Aug 2005 20:54:00 GMT
Author: mbo
Date: Thu Aug 11 13:53:49 2005
New Revision: 231513

URL: http://svn.apache.org/viewcvs?rev=231513&view=rev
Log:
JDO-81: add workaround implementation for the generation of jdoNewObjectIdInstance(Object)
such that fostore20 test case Test_EmpDeptAppId succeeds.

Modified:
    incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/core/Builder.java
    incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/generator/ImplHelper.java

Modified: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/core/Builder.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/core/Builder.java?rev=231513&r1=231512&r2=231513&view=diff
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/core/Builder.java
(original)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/core/Builder.java
Thu Aug 11 13:53:49 2005
@@ -3040,8 +3040,61 @@
         final String methodName = JDO_PC_jdoNewObjectIdInstance_Object_Name;
         final String methodSig = JDO_PC_jdoNewObjectIdInstance_Object_Sig;
         final int accessFlags = JDO_PC_jdoNewObjectIdInstance_Object_Mods;
-        // TODO: generate real method body
-        addNotYetImplementedMethod(methodName, methodSig, accessFlags);
+        final ExceptionsAttribute exceptAttr = null;
+
+        // begin of method body
+        final InsnTarget begin = new InsnTarget();
+        Insn insn = begin;
+
+        // generate empty method in case of datastore identity
+        final String keyClassName = analyzer.getKeyClassName();
+        if (keyClassName == null){
+            // end of method body
+            insn = insn.append(Insn.create(opc_aconst_null));
+            insn = insn.append(Insn.create(opc_areturn));
+
+            final CodeAttribute codeAttr
+                = new CodeAttribute(getCodeAttributeUtf8(),
+                                    1, // maxStack
+                                    2, // maxLocals
+                                    begin,
+                                    new ExceptionTable(),
+                                    new AttributeVector());
+            augmenter.addMethod(methodName, methodSig, accessFlags,
+                                codeAttr, exceptAttr);
+            return;
+        }
+        affirm(keyClassName != null);
+
+        // TODO: support for single field identity
+
+        // push a newly created an instance of this class
+        insn = insn.append(
+            Insn.create(opc_new,
+                        pool.addClass(keyClassName)));
+        insn = insn.append(Insn.create(opc_dup));
+        insn = insn.append(Insn.create(opc_aload_1));
+        insn = insn.append(Insn.create(opc_checkcast, 
+                                       pool.addClass(JAVA_String_Path)));
+        insn = insn.append(
+            Insn.create(opc_invokespecial,
+                        pool.addMethodRef(
+                            keyClassName,
+                            NameHelper.constructorName(),
+                            NameHelper.constructorSig(JAVA_String_Sig))));
+
+        // end of method body
+        insn = insn.append(Insn.create(opc_areturn));
+
+        final CodeAttribute codeAttr
+            = new CodeAttribute(getCodeAttributeUtf8(),
+                                3, // maxStack
+                                2, // maxLocals
+                                begin,
+                                new ExceptionTable(),
+                                new AttributeVector());
+        augmenter.addMethod(methodName, methodSig, accessFlags,
+                            codeAttr, exceptAttr);
     }
 
     // ----------------------------------------------------------------------

Modified: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/generator/ImplHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/generator/ImplHelper.java?rev=231513&r1=231512&r2=231513&view=diff
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/generator/ImplHelper.java
(original)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/generator/ImplHelper.java
Thu Aug 11 13:53:49 2005
@@ -392,9 +392,12 @@
                                          String o)
     {
         final List impl = new ArrayList(5);
-        // TODO: generate real method body
-        String msg = "Method jdoNewObjectIdInstance not yet supported";
-        impl.add("throw new UnsupportedOperationException(\"" + msg + "\");");
+        if (oidclassname == null) {
+            impl.add("return null;");
+        } else {
+            // TODO: support for single field identity
+            impl.add("return new " + oidclassname + "((String)" + o + ");");
+        }
         return impl;
     }
 



Mime
View raw message