This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e14545  Improve on the load check
1e14545 is described below

commit 1e14545fb4403131ffb5d964eb0e6d88561a3674
Author: remm <r...@apache.org>
AuthorDate: Fri Mar 26 11:12:19 2021 +0100

    Improve on the load check
    
    getResource should be a good alternative.
    Also account for generics.
---
 .../java/org/apache/tomcat/jakartaee/ClassConverter.java     | 12 +++++-------
 .../org/apache/tomcat/jakartaee/LocalStrings.properties      |  1 +
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java 
b/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java
index 1ef8993..9b3cbd9 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java
@@ -118,16 +118,14 @@ public class ClassConverter implements Converter, 
ClassFileTransformer {
                     if (newString != str) {
                         // Since this is runtime conversion, the idea is to 
only convert to
                         // Jakarta EE specification classes that exist in the 
container 
-                        String[] split = newString.split(";");
+                        String[] split = newString.split(";|<");
                         for (String current : split) {
                             int pos = current.indexOf("jakarta/");
                             if (pos >= 0) {
-                                boolean found = false;
-                                try {
-                                    
loader.loadClass(current.substring(pos).replace('/', '.'));
-                                    found = true;
-                                } catch (Exception e) {}
-                                if (!found) {
+                                if (loader.getResource(current.substring(pos) 
+ ".class") == null) {
+                                    if (logger.isLoggable(Level.FINE)) {
+                                        logger.log(Level.FINE, 
sm.getString("classConverter.skipName", current.substring(pos)));
+                                    }
                                     // Cancel the replacement as the 
replacement does not exist
                                     String originalFragment = 
current.replace("jakarta/", "javax/");
                                     newString = newString.replace(current, 
originalFragment);
diff --git 
a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties 
b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
index 3614cfc..e46a8d8 100644
--- a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
+++ b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
@@ -15,6 +15,7 @@
 
 classConverter.converted=Migrated class [{0}]
 classConverter.noConversion=No conversion necessary for [{0}] 
+classConverter.skipName=Skip conversion of class [{0}] as it is not accessible 
to the classloader
 
 migration.archive.complete=Migration finished for archive [{0}]
 migration.archive.memory=Migration starting for archive [{0}] using in memory 
copy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to