<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
On 12/06/2024 08:18, Robert Scholte wrote:<br>
<blockquote type="cite" cite="mid:003701dabc98$a86ede60$f94c9b20$@apache.org">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1"><span style="font-size:8.0pt;font-family:"Courier New";color:black"><o:p></o:p></span>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">When running this using
the classpath or modulepath I’ll get true for every line.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">However, when creating
the application with jlink, only regular resources return
true(i.e. the second and fourth log statement), the
“directories” return false.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is this difference
intended behavior?<o:p></o:p></span></p>
<br>
</div>
</blockquote>
<br>
The parameter provided to getResource is a resource name. The
getResource/getResourceAsStream methods don't specify if
"directories" are located as resources with that method.
ModuleReader is the only class (that I can think of) that set
expectations on this.<br>
<br>
When exploded on the file system then there is a sensible mapping.
This means using the resource name
"META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference" and
"META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference/"
will return a file URL to the directory. Whether getResourceAsStream
returns a useful InputStream is another question as it's highly
platform specific if you can open a directory as a regular file.<br>
<br>
For JAR files then it depends on whether the JAR file has entries
for directories. JAR files are based on the ZIP format and some
tooling will create JAR files that don't have entries for
directories (they aren't needed). So depending on what created the
JAR file then getResource method may return a jar URL to a
"directory entry" or it may return null.<br>
<br>
For modules in a a run-time image then there isn't the equivalent of
directories so #2 and #4 returning null is expected. It would be
technically feasible to synthesize entries to have this work in many
more cases, but not clear if it's worth doing. We should at least
surface expectations in the Class/ClassLoader.getResourceXXX API
docs as the notion of "resource" has never been clearly specified.<br>
<br>
-Alan<br>
</body>
</html>