[graalvm-dev] Keeping tailored jar files as resources while getResource

林子熠(层风) cengfeng.lzy at alibaba-inc.com
Mon Nov 25 01:12:15 PST 2019


Dear all.

We have submitted a PR(https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_oracle_graal_pull_1881&d=DwIDaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=P1aEbpQqX18a0ssutGCeizsWEVvvJcWvSeSxdI9X3-o&m=FXCDwCjeXfrva-XX8Dw9BecnFiVi92z7thtkOspf-Pk&s=xhcRBZoMYR5bQurl9t7ud6xfezaJGzekrikTNXb1FvE&e= ) for 2
things:

1.	When getResource methods(java.lang.ClassLoader.getResource,
java.lang.ClassLoader.getSystemResource,
java.lang.ClassLoader.getResourceAsStream,
java.lang.ClassLoader.getSystemResourceAsStream,
java.lang.ClassLoader.getResources,
java.lang.ClassLoader.getSystemResources, java.lang.System.getResource,
java.lang.System.getResourceAsStream) get resources from a jar file, reserve
a tailored jar file in file system and ship it together with the executable
native image file. It keeps compatible with tradational Java behavior.
-Dsvm.resources.jarLocation= gives the preserve location, and the default
value is resources/jars.
-Dsvm.resource.preserveJarRes=true to enable this patch, by default its
false.

The URL protocols returned by getResource methods in Java, SVM and this
patch are listed in the following table:


Resource locations

Protocol in Java

Protocol in SVM

Protocol in this patch


In directory

file:

resource:

resource:


In Jar

jar:file:

resource:

jar:file:

We developed this patch because we use the result of getResource as an index
to search the containing jar file for other configuration files. It's too
expensive to modify all of such usage.

2.	Fixes a bug: no inner class is matched using resource config file
generated by native agent.
The agent generates resource config file with resource's actual name, but
that name is used as a regular expression during build time. So the "$" in
inner class is taken as an end of line.

Thank you 

Ziyi Lin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/graalvm-dev/attachments/20191125/044bd583/attachment.html 


More information about the GraalVM-Dev mailing list