Skip to content

GraalVM's native-image substitute for ClassLoader.getResource normalizes resources' names while original doesn't #4326

@zakkak

Description

@zakkak

Describe the issue
GraalVM's native-image substitute for ClassLoader.getResource normalizes resources' names while the original does not.

Running

        URL url = cl.getResource("META-INF/");
        URL url2 = cl.getResource("META-INF/./");
        System.out.println("url = " + url);
        System.out.println("url2 = " + url2);

in JVM results in:

url = jar:file:/home/zakkak/code/tmp/issue-reproducers/target/reproducer-1.0-SNAPSHOT.jar!/META-INF/
url2 = null

while in native-image it results in:

url = resource:META-INF
url2 = resource:META-INF

I would expect it to return:

url = resource:META-INF/
url2 = null

instead.

cc @jovanstevanovic @vjovanov as it relates to #3597

Steps to reproduce the issue

cd /tmp
git clone --branch resources-with-trailing-slash https://github.com/zakkak/issue-reproducers reproducers
cd reproducers
mvn package
export JAVA_HOME=/opt/jvms/graalvm-ce-java11-22.0.0.2
$JAVA_HOME/bin/java \
  -jar target/reproducer-1.0-SNAPSHOT.jar
$JAVA_HOME/bin/native-image \
  -jar target/reproducer-1.0-SNAPSHOT.jar
./reproducer-1.0-SNAPSHOT

Describe GraalVM and your environment:

  • GraalVM version: 9b25754
  • JDK major version: 11
  • OS: Fedora 35
  • Architecture: AMD64

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions