<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Chen Liang <chen.l.liang@oracle.com><br>
<b>Sent:</b> Wednesday, June 12, 2024 10:22 AM<br>
<b>To:</b> Prasad Velagapudi <prasad.velagapudi@servicenow.com><br>
<b>Subject:</b> Re: Lambda Classes reachability from GC roots in JDK11 and JDK17</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hello Prasad,</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I can confirm the first one is accurate for JDK 15 and later (see JEP 371: Hidden Classes). Lambda classes from LambdaMetafactory are strongly linked to the defining class (the lookupClass of the input Lookup) and its class loader, and is intended to stay this
 way. Unfortunately I am not sure about the VM, hope someone can pick up the metaspace part of your question. But I've heard that since lambda classes are bounded to the lookup class loader, they use less memory as they don't need to be tracked separately for
 garbage collection,</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
-Chen</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Prasad Velagapudi <prasad.velagapudi@servicenow.com><br>
<b>Sent:</b> Wednesday, June 12, 2024 9:37 AM<br>
<b>To:</b> core-libs-dev@openjdk.org <core-libs-dev@openjdk.org><br>
<b>Subject:</b> Re: Lambda Classes reachability from GC roots in JDK11 and JDK17</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Aptos}
p.x_x_MsoNormal, li.x_x_MsoNormal, div.x_x_MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Aptos",sans-serif}
p.x_x_MsoListParagraph, li.x_x_MsoListParagraph, div.x_x_MsoListParagraph
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        font-size:11.0pt;
        font-family:"Aptos",sans-serif}
span.x_x_EmailStyle210
        {font-family:"Aptos",sans-serif;
        color:windowtext}
.x_x_MsoChpDefault
        {font-size:11.0pt}
@page WordSection1
        {margin:72.0pt 72.0pt 72.0pt 72.0pt}
ol
        {margin-bottom:0cm}
ul
        {margin-bottom:0cm}
-->
</style>
<div lang="EN-IN" style="word-wrap:break-word">
<div class="x_x_WordSection1">
<p class="x_x_MsoNormal"><span style="">A gentle reminder on these questions… Could you please respond?</span></p>
<p class="x_x_MsoNormal"><span style=""> </span></p>
<p class="x_x_MsoNormal"><span style="">Regards,</span></p>
<p class="x_x_MsoNormal"><span style="">Prasad.</span></p>
<p class="x_x_MsoNormal"><span style=""> </span></p>
<div id="x_x_mail-editor-reference-message-container">
<div>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_x_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">Prasad Velagapudi <prasad.velagapudi@servicenow.com><br>
<b>Date: </b>Thursday, 6 June 2024 at 8:10</span><span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:black"> </span><span style="font-size:12.0pt; color:black">PM<br>
<b>To: </b>core-libs-dev@openjdk.org <core-libs-dev@openjdk.org><br>
<b>Subject: </b>Lambda Classes reachability from GC roots in JDK11 and JDK17</span></p>
</div>
<div>
<p class="x_x_MsoNormal"><span lang="EN-US">Hello Lambda Experts,</span></p>
<p class="x_x_MsoNormal"><span lang="EN-US"> </span></p>
<p class="x_x_MsoNormal"><span lang="EN-US">I am looking for clarifications on the following questions.</span></p>
<p class="x_x_MsoNormal"><span lang="EN-US"> </span></p>
<ol start="1" type="1" style="margin-top:0cm">
<li class="x_x_MsoListParagraph" style="margin-left:0cm"><span lang="EN-US">I observed in my tests that lambda classes generated for inline lambda expressions (ex: LambdaUtil::print), are STRONGLY linked to defining class loader and never gets collected on
 GC. This behaviour is same in both JDK11 and JDK17. Can you please confirm is this accurate?</span></li><li class="x_x_MsoListParagraph" style="margin-left:0cm"><span lang="EN-US">Also, I observed that the lambda classes generated for inline lambda expressions (ex: LambdaUtil::print) not adding additional overhead to Metaspace in JDK17 compared to that of JDK11
 . Can you please confirm is this accurate? </span></li></ol>
<p class="x_x_MsoNormal"><span lang="EN-US"> </span></p>
<p class="x_x_MsoNormal"><span lang="EN-US"> </span></p>
<p class="x_x_MsoNormal"><span lang="EN-US">Regards,</span></p>
<p class="x_x_MsoNormal"><span lang="EN-US">Prasad</span></p>
<p class="x_x_MsoNormal"> </p>
<p class="x_x_MsoNormal"> </p>
<div id="x_x_mail-editor-reference-message-container">
<div>
<div>
<p class="x_x_MsoNormal"> </p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>