<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">I think having an instance
method on Classfile that produces a modified context:<br>
<br>
Classfile withOptions(Option...)<br>
<br>
would let you "refine" the options while keeping the base
options / cache config / etc. <br>
<br>
I agree with Adam that moving all the "make me a class" stuff in
one place is a benefit.<br>
</font></font><br>
<div class="moz-cite-prefix">On 5/29/2023 3:52 AM, Adam Sotona
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CY4PR1001MB215062A082AC814E8B196E908C4A9@CY4PR1001MB2150.namprd10.prod.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@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:10.0pt;
font-family:"Calibri",sans-serif;}span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}div.WordSection1
{page:WordSection1;}</style>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;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"><a class="moz-txt-link-abbreviated" href="mailto:liangchenblue@gmail.com">liangchenblue@gmail.com</a>
<a class="moz-txt-link-rfc2396E" href="mailto:liangchenblue@gmail.com"><liangchenblue@gmail.com></a><br>
<b>Date: </b>Friday, 26 May 2023 23:53<br>
<b>To: </b>Brian Goetz <a class="moz-txt-link-rfc2396E" href="mailto:brian.goetz@oracle.com"><brian.goetz@oracle.com></a><br>
<b>Cc: </b>Adam Sotona <a class="moz-txt-link-rfc2396E" href="mailto:adam.sotona@oracle.com"><adam.sotona@oracle.com></a>,
classfile-api-dev <a class="moz-txt-link-rfc2396E" href="mailto:classfile-api-dev@openjdk.org"><classfile-api-dev@openjdk.org></a><br>
<b>Subject: </b>[External] : Re: Planned features of a
classfile context object<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><i><span style="font-size:11.0pt">The
Classfile context in the patch looks somewhat like a
Classfile<br>
element to me :) With that in mind, I wish we can allow
users to<br>
transform/fork these immutable contexts, such as
skipping line numbers<br>
for particular files, skip constantpool sharing for
select<br>
transformations, etc. with the same code pattern in
Classfile<br>
Transformers. Of course, a transformation will always
read the default<br>
values of options if not explicitly set, and the
transformed context<br>
will have dropped options replaced with their default
values.<o:p></o:p></span></i></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">I can imagine use for context factory method:<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-size:11.0pt" lang="EN-US">Classfile.Context.of(Classfile.Context
parentContext, Option… optionsOverride)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">or after merge of Classfile.Context to
Classfile:
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-size:11.0pt" lang="EN-US">Classfile.of(Classfile
parentContext, Option… optionsOverride)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Is it what you think about?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
<br>
<i>In addition, ClassModel.transform can probably be kept,
which means<br>
using the creation context of the ClassModel to
transform this model,<br>
if we make it clear that all models have their lifetime
bound to a<br>
Classfile object.<br>
<br>
<o:p></o:p></i></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">I found the rule of all new classes created
from the context only as positive move.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Active class creation directly from
ClassModel is very confusing with respect to all the
options that must be defined before the model is created.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Explicit call of cc.transform(classModel,
transform) is more clear about what build/transform/write
options are applied.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Adam<o:p></o:p></span></p>
</div>
</div>
</blockquote>
<br>
</body>
</html>