<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Binary download of jextract does not include org.openjdk.jextract.jmod file (although that is part of jextract build folder).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
For now, you can workaround using the following:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0">$ cat Main.java<span class="Apple-converted-space ContentPasted0"> </span></span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0">import org.openjdk.jextract.*;</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0">import java.awt.*;</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000;min-height:16.0px">
<span style="font-variant-ligatures:no-common-ligatures"></span><br class="ContentPasted0">
</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0">class Main {</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"><span class="Apple-converted-space ContentPasted0"> 
</span>public static void main(String[] a) {</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"><span class="Apple-converted-space ContentPasted0">   
</span>System.out.println(Frame.class);</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"><span class="Apple-converted-space ContentPasted0">   
</span>System.out.println(JextractTool.class);</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"><span class="Apple-converted-space ContentPasted0"> 
</span>}</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0">}</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"><br>
</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"># assume that the current directory is "bin" dir of </span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"># jextract tool. </span>It has a javac executable in it.</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"># We use jextract's javac but pass module-path for the </p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"># other jdk modules not included in jextract jdk image.</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0"><br>
</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:14.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures" class="ContentPasted0">$ ./javac --module-path /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/jmods --add-modules
 java.desktop --enable-preview --source 19<span class="Apple-converted-space ContentPasted0"> 
</span>Main.java</span></p>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
If you're okay with building jextract from the sources, then you use JDK 19's javac with the following option:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
--module-path $JEXTRACT_REPO/build/jmods</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
[That directory <span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important" class="ContentPasted1">$JEXTRACT_REPO/build/jmods contains org.openjdk.jextract.jmod module file]</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important" class="ContentPasted1"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important" class="ContentPasted1"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important" class="ContentPasted1">-Sundar</span></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> jextract-dev <jextract-dev-retn@openjdk.org> on behalf of Nir Lisker <nlisker@gmail.com><br>
<b>Sent:</b> 06 October 2022 07:51<br>
<b>To:</b> Maurizio Cimadamore <maurizio.cimadamore@oracle.com><br>
<b>Cc:</b> jextract-dev@openjdk.org <jextract-dev@openjdk.org><br>
<b>Subject:</b> Re: GUI wrapper for jextract</font>
<div> </div>
</div>
<div>
<div dir="ltr">Yes, if I can interface with the tool directly it would be ideal.
<div><br>
</div>
<div>How can I add jextract as an external dependency for this? The jextract build is not a full jdk, and I'm running on jdk-19.</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Tue, Oct 4, 2022 at 12:19 PM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" target="_blank">maurizio.cimadamore@oracle.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<p>Hi Nir,<br>
</p>
<div>On 02/10/2022 22:31, Nir Lisker wrote:<br>
</div>
<blockquote type="cite">
<div>5. When analyzing the symbols of a header using the dump option, I need to read the file that jextract creates from disk and then delete it. Is there a way to read the jextract output directly? Either through the output stream, or writing to a file in
 memory? Dealing with disk I/O is cumbersome, comes with permission restrictions, and might be slow if done for many files in a batch.</div>
</blockquote>
<p>I think ultimately, working with files might be not ideal for your use case.</p>
<p>There is a pseudo-stable API to parse jextract files, in the JextractTool class (in the org.openjdk.jextract package, which should be exported by the jextract module):</p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline">`public
 static Declaration.Scoped parse(List<Path> headers, String... parserOptions) {`</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline">We
 do not make any promise (at this stage at least) on the stability of the API. That said, it has not changed much (at all?) in the last couple of years.</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline">What
 you get back is a "Declaration", which is used to model vars, structs, unions, typedefs, functions<br>
</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline">Then,
 attached to declarations, there are "Type"s, which are used... well, to model types. Since some type can be structured (e.g. a struct type), they can point back to their declaration (e.g. Type.Declared).</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline">Jextract
 does all it does by defining visitors on this basic declaration tree, which is obtained by wrapping the results of parsing a C header using the clang API (e.g. clang Cursors).<br>
</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline">We
 did this to "sanitize" the output of clang, as well as to make our implementation more robust and less dependent from clang internals.</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline">One
 option for you would be to invoke the parsing process this way, then get the tree and look at the results (e.g. with a visitor), which sounds better than parsing an option file.</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline"><br>
Cheers<br>
Maurizio<br>
</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline"><br>
</span></p>
<p><span style="color:rgb(29,28,29); font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:common-ligatures; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:left; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration-style:initial; text-decoration-color:initial; float:none; display:inline"><br>
</span></p>
</div>
</blockquote>
</div>
</div>
</body>
</html>