[jdk11u-dev] RFR: 8308184: Launching java with large number of jars in classpath with java.protocol.handler.pkgs system property set can lead to StackOverflowError

Sruthy Jayan duke at openjdk.org
Mon Jun 10 06:54:22 UTC 2024


On Fri, 7 Jun 2024 18:06:56 GMT, Amit Kumar <amitkumar at openjdk.org> wrote:

>> This is the backport of the issue : [JDK-8308184](https://bugs.openjdk.org/browse/JDK-8308184)
>> 
>> Launching java with large number of jars in classpath with java.protocol.handler.pkgs system property set can lead to StackOverflowError
>
> src/java.base/share/classes/jdk/internal/loader/URLClassPath.java line 211:
> 
>> 209:         this.unopenedUrls = unopenedUrls;
>> 210:         this.path = path;
>> 211:         // the application class loader uses the built-in protocol handler to avoid protocol
> 
> It should have been a clean backport. Please remove these two imports from this file: 
> 
> 
> import java.util.HashSet;
> import java.util.Set;
> 
> 
> Also please mention about testing you have done for this patch !!

@offamitkumar 

The imports are necessary and cannot be removed because they are utilized in the code at lines 952 and 964.

Regarding the testing :
I have a sample Java program that prints "Hello, world." After compiling the code, I created two JAR files from the .class file. When I run the Java command with the created JARs in the classpath and the -Djava.protocol.handler.pkgs system property set to a package name,  when I use the -verbose option along , the second JAR in the classpath gets loaded first.

-------------

PR Review Comment: https://git.openjdk.org/jdk11u-dev/pull/2749#discussion_r1632668912


More information about the jdk-updates-dev mailing list