openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r484812 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
Date Fri, 08 Dec 2006 21:52:42 GMT
Author: awhite
Date: Fri Dec  8 13:52:41 2006
New Revision: 484812

URL: http://svn.apache.org/viewvc?view=rev&rev=484812
Log:
Don't proxy final classes.


Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java?view=diff&rev=484812&r1=484811&r2=484812
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
Fri Dec  8 13:52:41 2006
@@ -408,6 +408,7 @@
      * Generate the bytecode for a collection proxy for the given type.
      */
     protected BCClass generateProxyCollectionBytecode(Class type) {
+        assertNotFinal(type);
         Project project = new Project(); 
         BCClass bc = project.loadClass(Strings.getPackageName
             (ProxyManagerImpl.class) + "." + type.getName().replace('.', '$')
@@ -426,9 +427,18 @@
     }
 
     /**
+     * Throw appropriate exception if the given type is final.
+     */
+    private static void assertNotFinal(Class type) {
+        if (Modifier.isFinal(type.getModifiers()))
+            throw new UnsupportedException(_loc.get("proxy-final", type));
+    }
+
+    /**
      * Generate the bytecode for a map proxy for the given type.
      */
     protected BCClass generateProxyMapBytecode(Class type) {
+        assertNotFinal(type);
         Project project = new Project(); 
         BCClass bc = project.loadClass(Strings.getPackageName
             (ProxyManagerImpl.class) + "." + type.getName().replace('.', '$')
@@ -449,6 +459,7 @@
      * Generate the bytecode for a date proxy for the given type.
      */
     protected BCClass generateProxyDateBytecode(Class type) {
+        assertNotFinal(type);
         Project project = new Project(); 
         BCClass bc = project.loadClass(Strings.getPackageName
             (ProxyManagerImpl.class) + "." + type.getName().replace('.', '$')
@@ -468,6 +479,7 @@
      * Generate the bytecode for a calendar proxy for the given type.
      */
     protected BCClass generateProxyCalendarBytecode(Class type) {
+        assertNotFinal(type);
         Project project = new Project(); 
         BCClass bc = project.loadClass(Strings.getPackageName
             (ProxyManagerImpl.class) + "." + type.getName().replace('.', '$')
@@ -487,6 +499,9 @@
      * Generate the bytecode for a bean proxy for the given type.
      */
     protected BCClass generateProxyBeanBytecode(Class type) {
+        if (Modifier.isFinal(type.getModifiers()))
+            return null;
+
         // we can only generate a valid proxy if there is a copy constructor
         // or a default constructor
         Constructor cons = findCopyConstructor(type);



Mime
View raw message