mbien commented on code in PR #3860:
URL: https://github.com/apache/netbeans/pull/3860#discussion_r929820198


##########
platform/o.n.bootstrap/src/org/netbeans/JarClassLoader.java:
##########
@@ -574,6 +606,17 @@ protected URL doGetResource(String name) throws 
IOException  {
         @Override
         protected byte[] readClass(String path) throws IOException {
             try {
+                if (isMultiRelease() && RUNTIME_VERSION != BASE_VERSION)
+                {
+                    int ver = RUNTIME_VERSION;
+                    while (ver > BASE_VERSION) {
+                        byte[] data = archive.getData(this, 
"META-INF/versions/" + ver + "/" + path);
+                        if (data != null) {
+                            return data;
+                        }
+                        ver--;
+                    }
+                }

Review Comment:
   This might scale badly. Lets say we load lucene which has a 8 and a 9 
version and run on JDK 19.
   
   This will call `getData()` (which isn't trivial) 10 times for each class 
before it finds something. I would put all versions contained in 
`META-INF/versions/` into an array during init and go through the array 
backwards (I don't actually know the spec, maybe its sufficient to only check 
the latest one which is ` <= runtime_version`?). 
   
   This would produce hits with fewer attempts on average. (ideally one single 
lookup, depends on the spec)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to