openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject [openjpa] 04/05: OPENJPA-2823 treat jakarta.* like javax.*
Date Thu, 23 Jul 2020 12:07:28 GMT
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit ab6e0ed4b46f7e3ef59c8ab74b3e9de4fdeff8b9
Author: Mark Struberg <struberg@apache.org>
AuthorDate: Thu Jul 23 14:04:44 2020 +0200

    OPENJPA-2823 treat jakarta.* like javax.*
    
    also simplify needsEnhance logic
---
 .../openjpa/enhance/PCClassFileTransformer.java    | 26 ++++++++++------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
index 872d413..d67fb48 100644
--- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
+++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
@@ -64,8 +64,7 @@ public class PCClassFileTransformer
      * @param opts enhancer configuration options
      * @param loader temporary class loader for loading intermediate classes
      */
-    public PCClassFileTransformer(MetaDataRepository repos, Options opts,
-        ClassLoader loader) {
+    public PCClassFileTransformer(MetaDataRepository repos, Options opts, ClassLoader loader)
{
         this(repos, toFlags(opts), loader, opts.removeBooleanProperty
             ("scanDevPath", "ScanDevPath", false));
     }
@@ -93,8 +92,7 @@ public class PCClassFileTransformer
      * @param devscan whether to scan the dev classpath for persistent types
      * if none are configured
      */
-    public PCClassFileTransformer(MetaDataRepository repos,
-        PCEnhancer.Flags flags, ClassLoader tmpLoader, boolean devscan) {
+    public PCClassFileTransformer(MetaDataRepository repos, PCEnhancer.Flags flags, ClassLoader
tmpLoader, boolean devscan) {
         _repos = repos;
         _tmpLoader = tmpLoader;
 
@@ -108,9 +106,9 @@ public class PCClassFileTransformer
     }
 
     @Override
-    public byte[] transform(ClassLoader loader, String className,
-        Class redef, ProtectionDomain domain, byte[] bytes)
+    public byte[] transform(ClassLoader loader, String className, Class redef, ProtectionDomain
domain, byte[] bytes)
         throws IllegalClassFormatException {
+
         if (loader == _tmpLoader)
             return null;
 
@@ -183,12 +181,9 @@ public class PCClassFileTransformer
      * Return whether the given class needs enhancement.
      */
     private Boolean needsEnhance(String clsName, Class redef, byte[] bytes) {
-        if (redef != null) {
-            Class[] intfs = redef.getInterfaces();
-            for (int i = 0; i < intfs.length; i++)
-                if (PersistenceCapable.class.getName().
-                    equals(intfs[i].getName()))
-                    return Boolean.valueOf(!isEnhanced(bytes));
+        if (redef != null && PersistenceCapable.class.isAssignableFrom(redef)) {
+            // if the original class is already enhanced (implements PersistenceCapable)
+            // then we don't need to do any further processing.
             return null;
         }
 
@@ -198,10 +193,13 @@ public class PCClassFileTransformer
             return null;
         }
 
-        if (clsName.startsWith("java/") || clsName.startsWith("javax/"))
+        if (clsName.startsWith("java/") || clsName.startsWith("javax/") || clsName.startsWith("jakarta/"))
{
             return null;
-        if (isEnhanced(bytes))
+        }
+
+        if (isEnhanced(bytes)) {
             return Boolean.FALSE;
+        }
 
         try {
             Class c = Class.forName(clsName.replace('/', '.'), false,


Mime
View raw message