Pointer/Scope API questions

Ty Young youngty1997 at gmail.com
Wed Jan 8 12:12:30 UTC 2020


On 1/8/20 5:53 AM, Maurizio Cimadamore wrote:
>
> On 08/01/2020 11:48, Ty Young wrote:
>>
>> On 1/8/20 5:43 AM, Maurizio Cimadamore wrote:
>>>
>>> On 08/01/2020 11:38, Ty Young wrote:
>>>>
>>>> On 1/8/20 5:09 AM, sundararajan.athijegannathan at oracle.com wrote:
>>>>> [...]
>>>>>>>>
>>>>>>> Are you also adding `--add-modules 
>>>>>>> jdk.incubator.foreign,jdk.incubator.jextract` when running? I 
>>>>>>> was seeing a similar error when I forgot to do that.
>>>>>>
>>>>>>
>>>>>> Ah, no. Works now.
>>>>>>
>>>>>>
>>>>>> Is it supposed to throw an exception there though? The modules 
>>>>>> are apart of the JDK and preview features are enabled so I don't 
>>>>>> understand why the extra step of adding the modules at runtime is 
>>>>>> being required here. Is it a bug?
>>>>>
>>>>> No. It is not a bug. You've to explicitly add "incubator" modules 
>>>>> for compilation as well as for runtime.
>>>>
>>>>
>>>> TIL.
>>>>
>>>>
>>>> Just noticed though that while the Memory Access API works, the 
>>>> jextract API fails because of javax.tools's JaveFileObject from the 
>>>> java.compiler module.
>>>>
>>>>
>>>> My compiler/runtime --add-modules argument looks like:
>>>>
>>>>
>>>> --add-modules 
>>>> jdk.incubator.foreign,jdk.incubator.jextract,java.compiler
>>>>
>>>>
>>>> It is also required in module-info.java. Am I missing something here?
>>>
>>> Uhm - java.compiler should be available w/o extra flags... what code 
>>> are you trying to run?
>>
>>
>> Code:
>>
>>
>> Path header = Path.of("/opt/cuda/targets/x86_64-linux/include/nvml.h");
>>
>> JextractTask task = JextractTask.newTask(true, header);
>>
>>  task.write(Path.of("./", args), new JavaFileObjectTest()); <---- ERROR
>
> Do you have a module info?


Yep:


module PanamaMemTest
{
     requires java.compiler;
     requires jdk.incubator.foreign;
     requires jdk.incubator.jextract;

     exports org.goliath.panamamemtest;
}


I'm using Netbeans 11.2, if that matters.


> Or are you just running off the classpath?
>
> (btw, for now the jextract API doesn't really generate any bindings - 
> but it can be used to 'parse' an header and inspect the structure of 
> the declarations in it).


I'm a bit confused here, your clang code that you linked is commented 
saying that it was generated by jextract. Is it internal still then?


>
> Maurizio
>
>>
>>
>> Exception:
>>
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError: 
>> javax/tools/JavaFileObject
>>     at 
>> jdk.incubator.jextract/jdk.internal.jextract.impl.Writer.resources(Writer.java:108)
>>     at 
>> jdk.incubator.jextract/jdk.internal.jextract.impl.Writer.writeAll(Writer.java:57)
>>     at 
>> jdk.incubator.jextract/jdk.internal.jextract.impl.JextractTaskImpl.write(JextractTaskImpl.java:65)
>>     at 
>> org.goliath.panamamemtest.PanamaMemTest.main(PanamaMemTest.java:37)
>>
>>
>>>
>>> Maurizio
>>>
>>>>
>>>>
>>>>>
>>>>> -Sundar
>>>>>


More information about the panama-dev mailing list