openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r495650 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/
Date Fri, 12 Jan 2007 17:25:27 GMT
Author: awhite
Date: Fri Jan 12 09:25:25 2007
New Revision: 495650

URL: http://svn.apache.org/viewvc?view=rev&rev=495650
Log:
Allow use of reflection to access private id fields of pre-1.5 classes.


Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.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/meta/AbstractCFMetaDataFactory.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java?view=diff&rev=495650&r1=495649&r2=495650
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
Fri Jan 12 09:25:25 2007
@@ -39,7 +39,6 @@
 import org.apache.openjpa.meta.JavaTypes;
 import org.apache.openjpa.meta.MetaDataContext;
 import org.apache.openjpa.util.MetaDataException;
-
 import serp.util.Strings;
 
 /**

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=495650&r1=495649&r2=495650
==============================================================================
--- 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
Fri Jan 12 09:25:25 2007
@@ -1550,7 +1550,7 @@
                 if (reflect) {
                     code.constant().setValue(oidType);
                     code.constant().setValue(name);
-                    setClassConstant(code, type);
+                    setClassConstant(_pc, code, type);
                     code.constant().setValue(true);
                     code.invokestatic().setMethod(Reflection.class, 
                         "findSetter", Method.class, new Class[] { Class.class,
@@ -1601,25 +1601,13 @@
     }
 
     /**
-     * Works around a bug in serp when primitive type constants. 
+     * Works around a bug in serp with primitive type constants, and chooses
+     * Java 5 construct when available (serp will eventually do all this
+     * automatically). 
      */
-    private static void setClassConstant(Code code, Class type) {
-        if (type == boolean.class) 
-            code.getstatic().setField(Boolean.class, "TYPE", Class.class);
-        else if (type == byte.class) 
-            code.getstatic().setField(Byte.class, "TYPE", Class.class);
-        else if (type == char.class) 
-            code.getstatic().setField(Character.class, "TYPE", Class.class);
-        else if (type == double.class) 
-            code.getstatic().setField(Double.class, "TYPE", Class.class);
-        else if (type == float.class) 
-            code.getstatic().setField(Float.class, "TYPE", Class.class);
-        else if (type == int.class) 
-            code.getstatic().setField(Integer.class, "TYPE", Class.class);
-        else if (type == long.class) 
-            code.getstatic().setField(Long.class, "TYPE", Class.class);
-        else if (type == short.class) 
-            code.getstatic().setField(Short.class, "TYPE", Class.class);
+    private static void setClassConstant(BCClass bc, Code code, Class type) {
+        if (type.isPrimitive() || bc.getMajorVersion() < 49) // 49 = Java 5
+            code.classconstant().setClass(type);
         else
             code.constant().setValue(type);
     }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java?view=diff&rev=495650&r1=495649&r2=495650
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
Fri Jan 12 09:25:25 2007
@@ -643,8 +643,7 @@
                 } else {
                     if (log.isTraceEnabled())
                         log.trace(_loc.get("scanning-url", url));
-                    clss = cparser.parseTypeNames(new URLMetaDataIterator
-                        (url));
+                    clss = cparser.parseTypeNames(new URLMetaDataIterator(url));
                     names.addAll(Arrays.asList(clss));
                     mapPersistentTypeNames(url, clss);
                 }



Mime
View raw message