You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by aw...@apache.org on 2006/12/08 22:52:42 UTC

svn commit: r484812 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java

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);