Trivial compiler warning from generated code

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Feb 15 15:11:42 UTC 2024


I see - thanks a lot.

There's two issues here:

* since we switched the translation of function pointers from interface 
to class + interface, when a function pointer code is embedded inside a 
struct, we lack the required "static"
* the new function pointer class lacks a package constructor (which we 
have in other classes)

I'll fix that

Maurizio

On 15/02/2024 14:31, Duncan Gittins wrote:
> Two examples attached. This compiles: " new LPHANDLER_FUNCTION_EX();" 
> whereas "new IUnknownVtbl().new QueryInterface();" does not because 
> the IUnknownVtbl constructor is generated.
>
> Note that a compiler warning is only issued because after I generate 5 
> packages with jextract, I build them with a module-info.java
>
> /**
>  * Module definition for JEXTRACT based generated code
>  */
> module jextract.duncan.win
> {
>     // 
> =======================================================================
>     // Exports:
>     exports duncan.win.advapi;
>     exports duncan.win.kernel;
>     exports duncan.win.ole;
>     exports duncan.win.shell;
>     exports duncan.win.user;
>
>     // 
> =======================================================================
> }
>
> Kind regards
>
> Duncan
>
> On Thu, 15 Feb 2024 at 13:38, Maurizio Cimadamore 
> <maurizio.cimadamore at oracle.com> wrote:
>
>     Can you please send one of the source file that is generating
>     these warnings?
>
>     Thanks
>     Maurizio
>
>     On 15/02/2024 12:23, Duncan Gittins wrote:
>>     These are trivial issues I noted when re-building with latest
>>     jextract master (am now using LLVM13).
>>
>>     I put all my generated code into a module definition which
>>     exports each package generated by jextract. The compiler warns
>>     that there are no explicit contructors for each interface class
>>     type, such as the inner or top level interface handlers such as
>>     IUnknownVtbl.QueryInterface and LPHANDLER_FUNCTION_EX:
>>
>>         [javac]
>>     C:\mymoduleproject\generated\some\package\name\IUnknownVtbl.java:48:
>>     warning: [missing-explicit-ctor] class
>>     IUnknownVtbl.QueryInterface in exported package some.package.name
>>     <https://urldefense.com/v3/__http://some.package.name__;!!ACWV5N9M2RV99hQ!JWktJzjV6IXxP1Ztow5Nu8IBHQPBuqRlPe4zP_q2D4bzIgbdQkTuin4byR10rLXhj_RPM78NZuOQgc-EX_lmerZVQ45-ve34$>
>>     declares no explicit constructors, thereby exposing a default
>>     constructor to clients of module mymoduleproject
>>         [javac]     public class QueryInterface {
>>
>>     Also, shouldn't the inner classes for interfaces - like
>>     IUnknownVtbl.QueryInterface - be declared as static? I assume
>>     that means the code generated could be a tiny amount smaller as
>>     no implicit parent$this.
>>
>>     Headers used:  #include <objbase.h> + #include <shlobj_core.h>
>>
>>     Kind regards
>>
>>     Duncan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jextract-dev/attachments/20240215/0ce56eca/attachment.htm>


More information about the jextract-dev mailing list