<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
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]--></head><body lang=NL link="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Thank you for the confirmation.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>I was actually a bit surprised that directories were accessible as resource, the behavior of the runtime image makes more sense to me.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Currently Micronaut depends on this feature/bug/unclear spec, so before trying to resolve this I just wanted to make sure this is indeed the expected behavior.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Robert<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='mso-fareast-language:NL'>From:</span></b><span lang=EN-US style='mso-fareast-language:NL'> Alan Bateman <Alan.Bateman@oracle.com> <br><b>Sent:</b> woensdag 12 juni 2024 10:31<br><b>To:</b> rfscholte@apache.org; 'jigsaw-dev' <jigsaw-dev@openjdk.org><br><b>Subject:</b> Re: loading regular/directory resources via classloader<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On 12/06/2024 08:18, Robert Scholte wrote:<br><br><span style='mso-fareast-language:NL'><o:p></o:p></span></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><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.</span><o:p></o:p></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.</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US>Is this difference intended behavior?</span><o:p></o:p></p><p class=MsoNormal><span style='mso-fareast-language:NL'><o:p> </o:p></span></p></blockquote><p class=MsoNormal><span style='mso-fareast-language:NL'><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<o:p></o:p></span></p></div></body></html>