<div dir="auto"><div>(Sorry, forgot to cc classfile api dev)</div><div dir="auto"><br></div><div dir="auto">For your performance impact concerns, I think we can probably keep caching for the system class loader resource parsing CHR. But I think we will still convert the field to a static method.<br></div><div dir="auto"><br></div><div dir="auto">Should I incoporate all 3 changes in my patch?</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 1, 2023, 1:34 AM Adam Sotona <<a href="mailto:adam.sotona@oracle.com" rel="noreferrer noreferrer" target="_blank">adam.sotona@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="en-CZ" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">classfile-api-dev <<a href="mailto:classfile-api-dev-retn@openjdk.org" rel="noreferrer noreferrer noreferrer" target="_blank">classfile-api-dev-retn@openjdk.org</a>> on behalf of <a href="mailto:liangchenblue@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">liangchenblue@gmail.com</a> <<a href="mailto:liangchenblue@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">liangchenblue@gmail.com</a>><br>
<b>Date: </b>Wednesday, 31 May 2023 8:26<br>
<b>To: </b>classfile-api-dev <<a href="mailto:classfile-api-dev@openjdk.org" rel="noreferrer noreferrer noreferrer" target="_blank">classfile-api-dev@openjdk.org</a>><br>
<b>Subject: </b>ClassHierarchyResolver changes for the Classfile object<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt">Hello,<br>
Since we are migrating to the Classfile object (8308899), which was<br>
initiated by our observation that Class hierarchy resolvers shouldn't<br>
always cache their results, I wonder what changes I should adapt to my<br>
current patch (8304425, PR #13082).<br>
<br>
We have already decided a few API changes for the resolver:<br>
1. Remove the default hierarchy resolver (at least change to static<br>
factories), caching is bound to Classfile lifetime<br>
<br>
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Yes, but we need to check performance impact on existing use cases (where to extra hold Classfile instance with cache).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt">2. Two new resolver factories: Bytecode/resource parsing and<br>
classloading/reflection from a given classloader (The goal of this<br>
patch)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Yes.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt"><br>
3. The resolution result ClassHierarchyInfo will be converted into an<br>
interface; record is an implementation detail (TBD)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">This can go even further. To save footprint ClassHierarchyInfo does not need to expose anything, it does not need to carry thisClass and all interface infos can point to a singleton object, something
like this:<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">/**</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:#969696"> *
<b>Information</b></span><span style="font-family:"Courier New",serif;color:black">
</span><b><span style="font-family:"Courier New",serif;color:#969696">about</span></b><span style="font-family:"Courier New",serif;color:black">
</span><b><span style="font-family:"Courier New",serif;color:#969696">a</span></b><span style="font-family:"Courier New",serif;color:black">
</span><b><span style="font-family:"Courier New",serif;color:#969696">resolved</span></b><span style="font-family:"Courier New",serif;color:black">
</span><b><span style="font-family:"Courier New",serif;color:#969696">class</span></b><span style="font-family:"Courier New",serif;color:black">
</span><b><span style="font-family:"Courier New",serif;color:#969696">or</span></b><span style="font-family:"Courier New",serif;color:black">
</span><b><span style="font-family:"Courier New",serif;color:#969696">interface.</span></b><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">*/</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">sealed</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">interface</span><span style="font-family:"Courier New",serif;color:black">
<b><i>ClassHierarchyInfo</i></b><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">permits</span><span style="font-family:"Courier New",serif;color:black"> ClassHierarchyImpl.<i>ClassHierarchyInfoImpl</i> {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">/**</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:#969696"> * {<b>@return</b></span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">the {<b>@link</b></span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">ClassHierarchyInfo} of</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">an</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">interface}</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:#969696"> * no</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">other</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">information</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">about</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">interface</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">is</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">required</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">*/</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">static</span><span style="font-family:"Courier New",serif;color:black">
<i>ClassHierarchyInfo</i> <b><i>ofInterface</i></b>() {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">return</span><span style="font-family:"Courier New",serif;color:black"> ClassHierarchyImpl.</span><i><span style="font-family:"Courier New",serif;color:#ce54b8">INTERFACE_INFO_INSTANCE</span></i><span style="font-family:"Courier New",serif;color:black">;<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black"> }<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">/**</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:#969696"> *
<b>@return</b></span><span style="font-family:"Courier New",serif;color:black"> </span>
<span style="font-family:"Courier New",serif;color:#969696">the {<b>@link</b></span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">ClassHierarchyInfo} of</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">an</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">interface</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:#969696"> *
<b>@param</b></span><span style="font-family:"Courier New",serif;color:black"> superClass
</span><span style="font-family:"Courier New",serif;color:#969696">information</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">about</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">super</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">of</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">the</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">class</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">is</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">required</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#969696">*/</span><span style="font-family:"Courier New",serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">static</span><span style="font-family:"Courier New",serif;color:black">
<i>ClassHierarchyInfo</i> <b><i>ofClass</i></b>(ClassDesc superClass) {<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">return</span><span style="font-family:"Courier New",serif;color:black">
</span><span style="font-family:"Courier New",serif;color:#336bdd">new</span><span style="font-family:"Courier New",serif;color:black"> ClassHierarchyImpl.ClassHierarchyInfoImpl(superClass);<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black"> }<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="font-family:"Courier New",serif;color:black"> }<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt"><br>
<br>
What should I do with my patch? Should I drop the changes to default<br>
resolver (which adds security manager suppression) and move on with<br>
the current content, or should I expand it to address all 3 planned<br>
changes (despite some of them still in drafting phase) and accomodate<br>
to the Classfile object? (We still have to decide about the default<br>
resolver fo a Classfile object, esp. whether to have one or not)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">I’m not sure why the default class hierarchy resolver should call
</span><span style="font-size:11.0pt">AccessController.doPrivileged</span><span lang="EN-US" style="font-size:11.0pt">?<u></u><u></u></span></p>
<p class="MsoNormal"><span><span lang="EN-US" style="font-size:9.0pt;font-family:Menlo"><u></u> <u></u></span></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
</span><span lang="EN-US" style="font-size:11.0pt">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Adam<u></u><u></u></span></p>
</div>
</div>
</div>
</blockquote></div></div>
</blockquote></div></div></div>