<html 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=us-ascii">
<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;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {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:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="en-CZ" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Hi Rafael,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Could you, please, add tests cases where classfile-api-dev-branch javap output differs from standard javap?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">These cases should be added into javap tests to cover backward compatibility of the output.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Adam <o:p>
</o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></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 <classfile-api-dev-retn@openjdk.org> on behalf of Rafael Winterhalter <rafael.wth@gmail.com><br>
<b>Date: </b>Tuesday, 12 July 2022 0:09<br>
<b>To: </b>classfile-api-dev@openjdk.org <classfile-api-dev@openjdk.org><br>
<b>Subject: </b>javap with classfile API<o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal">Hello,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I completed a full round of comparing byte code output with ASM and OpenJDK's APIs and doing so, I was using the sandboxes version of javap. I found some errors in the tool doing so which I fixed for my own convenience on the way (if you
 wanted to adapt those fixes, <a href="https://github.com/openjdk/jdk-sandbox/pull/21">
https://github.com/openjdk/jdk-sandbox/pull/21</a>, basically it makes the javap output identical to the ASM-based version).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I was however wondering about printing dynamic constants:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">1. For invokedynamic instructions, <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">    printConstantPoolRefAndValue(instr.invokedynamic(), 0)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> is used. I would not know why the 0 is printed here, but it was printed previously. Possibly, it was meant to yield an equivalent output for the "count" (JVMS 6.5) value of interface calls, but I do not see its value. Maybe this should
 be changed in javap.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">2. I changed the print of DynamicConstantPoolEntrys to <o:p>
</o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">    print("#" + info.bootstrap().bsmIndex() + ":#" + info.nameAndType().index());<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">, the same that is used in the string representation. Previously, the index was read via info.bootstrap().bootstrapMethod().index() - I do not quite understand why those two would be different, and bsmIndex seems to return 0 for lambda
 meta factory values, but it is indeed the old behavior. Maybe printing the reference to lambda meta factory would however be the better option. In this case, the string representation should however also be adjusted.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">3. For handle types, the internal constant names were printed. Those are not part of the spec, so I changed it to print the documented REF_abc values. Those do however not indicate if a reference addresses an interface invocation; maybe
 this information should be included in javap.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">4. I thought I found a row of issues with printing in-code type annotation type references, but it seems that javac has a row of issues with adding them to class files. So it's javac who gets those wrong, not javap. I validated that this
 has been an issue previously and is not related to the change in class file emitter. I reported these issues here (<a href="https://bugs.openjdk.org/browse/JDK-8290125">https://bugs.openjdk.org/browse/JDK-8290125</a>) but wanted to mention it if anybody ran
 into the same issue.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best regards, Rafael<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>