OPENJPA-2823 treat jakarta.* like javax.*

also simplify needsEnhance logic
This commit is contained in:
Mark Struberg 2020-07-23 14:04:44 +02:00
parent bf03bdb314
commit ab6e0ed4b4
1 changed files with 12 additions and 14 deletions

View File

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