<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>It's a question to the ClassHierarchyResolver interaction with
      the security manager.   Although it's deprecated for removal, we
      still need to consider when it's installed and whether the API
      would throw SecurityException due to the security permission check
      or the implementation is safe to use the system class loader
      loading resources with privilege.<br>
    </p>
    <p>Mandy<br>
    </p>
    <div class="moz-cite-prefix">On 5/31/23 5:32 PM, - wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CABe8uE3yyPNqNPtu3j6Vf9Fd53+7Xi5QhpECt0-b5KqhDq8-mA@mail.gmail.com">
      
      <div dir="auto">The doPrivileged is from Mandy Chung's
        modification to my patch of reimplementation of
        MethodHandleProxies.asInterfaceInstance. It allows system code
        to fetch from system classloader with security manager, but I
        can just leave this change to be part of that patch instead.</div>
      <br>
      <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" moz-do-not-send="true" class="moz-txt-link-freetext">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 link="#0563C1" vlink="#954F72" style="word-wrap:break-word" lang="en-CZ">
            <div class="m_-6906457239650474240WordSection1">
              <p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
              <p class="MsoNormal"><span style="font-size:11.0pt"> </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" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">classfile-api-dev-retn@openjdk.org</a>>
                    on behalf of <a href="mailto:liangchenblue@gmail.com" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">liangchenblue@gmail.com</a>
                    <<a href="mailto:liangchenblue@gmail.com" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">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" target="_blank" rel="noreferrer" moz-do-not-send="true" class="moz-txt-link-freetext">classfile-api-dev@openjdk.org</a>><br>
                    <b>Subject: </b>ClassHierarchyResolver changes for
                    the Classfile object</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>
                  </span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Yes, but we need to check performance
                    impact on existing use cases (where to extra hold
                    Classfile instance with cache).</span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt"> </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)</span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Yes.</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)</span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">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:</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"></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"></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"></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></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>
                    {</span></p>
                <p class="MsoNormal" style="background:white"><span style="font-family:"Courier
                    New",serif;color:black"> </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"></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"></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"></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"></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>()
                    {</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">;</span></p>
                <p class="MsoNormal" style="background:white"><span style="font-family:"Courier
                    New",serif;color:black">        }</span></p>
                <p class="MsoNormal" style="background:white"><span style="font-family:"Courier
                    New",serif;color:black"> </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"></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"></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"></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"></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) {</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);</span></p>
                <p class="MsoNormal" style="background:white"><span style="font-family:"Courier
                    New",serif;color:black">        }</span></p>
                <p class="MsoNormal" style="background:white"><span style="font-family:"Courier
                    New",serif;color:black">    }</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)</span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">I’m not sure why the default class
                    hierarchy resolver should call
                  </span><span style="font-size:11.0pt">AccessController.doPrivileged</span><span style="font-size:11.0pt" lang="EN-US">?</span></p>
                <p class="MsoNormal"><span class="m_-6906457239650474240pl-en"><span style="font-size:9.0pt;font-family:Menlo" lang="EN-US"> </span></span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt"><br>
                  </span><span style="font-size:11.0pt" lang="EN-US">Thanks,</span></p>
                <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Adam</span></p>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>