<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Robert Scholte" <rfscholte@apache.org><br><b>To: </b>"jigsaw-dev" <jigsaw-dev@openjdk.org><br><b>Sent: </b>Friday, January 26, 2024 11:46:51 AM<br><b>Subject: </b>Custom Classloaders<br></blockquote></div><style><!--
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@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;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
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;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
@list l0
{mso-list-id:540560569;
mso-list-type:hybrid;
mso-list-template-ids:1140471810 68354063 68354073 68354075 68354063 68354073 68354075 68354063 68354073 68354075;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:18.0pt;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:54.0pt;
text-indent:-18.0pt;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:90.0pt;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:126.0pt;
text-indent:-18.0pt;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:162.0pt;
text-indent:-18.0pt;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:198.0pt;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:234.0pt;
text-indent:-18.0pt;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:270.0pt;
text-indent:-18.0pt;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:306.0pt;
text-indent:-9.0pt;}
@list l1
{mso-list-id:1876582519;
mso-list-type:hybrid;
mso-list-template-ids:1978042996 -967021896 68354051 68354053 68354049 68354051 68354053 68354049 68354051 68354053;}
@list l1:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:-;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-font-family:Calibri;}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div class="WordSection1"><p class="MsoNormal">Hi,</p></div></blockquote><div><br></div><div>Hello Robert,</div><div>you were miss at last Devoxx.be,<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div class="WordSection1"><p class="MsoNormal"> </p><p class="MsoNormal"><span lang="EN-US">I’m working on a new application, using jlink to build it.</span></p><p class="MsoNormal"><span lang="EN-US">One challenge is related to the simplelogger of SLF4J (as SLF4J-api is probably the most used logging api, the simplelogger implementation matches my requirements)</span></p><p class="MsoNormal"><span lang="EN-US">There are 2 things that I would like to adjust:</span></p><ol style="margin-top:0cm" start="1" type="1"><li class="MsoListParagraph" style="margin-left:-18.0pt;mso-list:l0 level1 lfo2"><span lang="EN-US">Simplelogger uses the classloader to find the simplelogger.properties ( <a href="https://github.com/qos-ch/slf4j/blob/master/slf4j-simple/src/main/java/org/slf4j/simple/SimpleLoggerConfiguration.java#L107-L130" target="_blank">https://github.com/qos-ch/slf4j/blob/master/slf4j-simple/src/main/java/org/slf4j/simple/SimpleLoggerConfiguration.java#L107-L130</a> ). </span></li></ol><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">However, I want to externalize this file to ${java.home}/conf/simplelogger.properties, so users can adjust it to their preferences. If I could change the classloader I could control where to find this file.</span></p><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">When bundling simplelogger with jlink the jar will end up in the AppClassloader due to the SimpleServiceProvider. </span></p><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">The only option to avoid this, is to move this jar to a separate directory and when making a new ModuleLayer, and use ModuleFinder with this path. </span></p><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">But still, I see no way to change the classloader for this jar.</span></p><ol style="margin-top:0cm" start="2" type="1"><li class="MsoListParagraph" style="margin-left:-18.0pt;mso-list:l0 level1 lfo2"><span lang="EN-US">The simplelogger.properties is the default configuration, and I want to make it possible to override these values. </span></li></ol><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">The simplelogger offers the option to use SystemProperties to override values from simplelogger.properties.</span></p><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">I want to avoid that the System.properties will be polluted with entities just for logging.</span></p><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">As far as I know it is not possible to scope System.properties: they are global, available for every part of the application.</span></p><p class="MsoListParagraph" style="margin-left:18.0pt"><span lang="EN-US">Another idea I had was to extend the simplelogging.properties resources at runtime using the SequenceInputStream, and for this I also need to have control over the classloader, as it requires to override the ClassLoader.getResourceAsStream()</span></p><p class="MsoNormal"><span lang="EN-US">It seems both challenges could be solved if could control the classloader (while still being protected by jdk.internal.loader.Loader).</span></p><p class="MsoNormal"><span lang="EN-US">Am I missing some feature or it there another way to solve these issues?</span></p></div></blockquote><div><br></div><div>yes, </div><div>as you said yourself, you box yourself in a corner by wanting to use Simplelogger which does not provide a great deal of ways to configure it.</div><div>I'm sure they are other loggers that, while heavier, are more capable in term of configuration.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>You are cursed by your own knowledge in this case, as an application developer, you should pretend that ClassLoaders do not exist, like the rest of the application developers do.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Let me try a trick, those are not the classloaders you are looking for :)<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div class="WordSection1"><p class="MsoNormal"><span lang="EN-US">Best,</span></p><p class="MsoNormal"><span lang="EN-US">Robert </span></p></div></blockquote><div><br></div><div>regards,<br data-mce-bogus="1"></div><div>Rémi<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div></div></div></body></html>