My sbt plugin is working
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Nov 11 15:39:50 UTC 2019
On 11/11/2019 15:30, Mark Hammons wrote:
> Ah I see,
>
> Is there any chance that this will be put into an early access release anytime
> soon? I've never built openjdk myself before.
If that's something people would find useful we could spin binaries for
memory access + ABI.
>
> I'll probably go ahead and generate a java interface for my scala trait to
> inherit from for now, since I would like my plugin to depend on the latest EA
> build of panama instead of requiring users to build a JDK to use it, but I may
> well add a branch to my code that uses the LibraryLookup API to get pure scala
> bindings so I can switch to that when it becomes available in EA builds.
>
> Thanks a ton for the help Maurizio,
Thanks _you_ for taking the time to play with out stuff!
Maurizio
> Mark
>
>
>
> On Monday, November 11, 2019 4:22:34 PM CET Maurizio Cimadamore wrote:
>> I was referring to SystemABI in foreign-abi - in that branch, the API is
>> public, and there's a LibraryLookup API to lookup the library symbol you
>> are looking for.
>>
>> Maurizio
>>
>> On 11/11/2019 14:24, Mark Hammons wrote:
>>> Hi Maurizio,
>>>
>>> I'm not sure I fully understand. SystemABI resides in
>>> jdk.internal.foreign,
>>> and trying to access it gives me an IllegalAccessError. Is there an API
>>> I'm
>>> missing under java.foreign to do this? And it's not very clear how I'd use
>>> SystemABI to look up the right function and get a method handle. Also, if
>>> it requires poking around in java internals, won't that make my library
>>> fairly difficult to use as the users would probably have to add special
>>> jvm options to override the IllegalAccessError?
>>>
>>> Thanks,
>>> Mark
>>>
>>> On Monday, November 11, 2019 2:26:47 PM CET Maurizio Cimadamore wrote:
>>>> On 11/11/2019 12:40, Mark Hammons wrote:
>>>>> However, I was curious if it would be feasible for java.foreign to be a
>>>>> little more lenient in what it binds to. If I were able to define a
>>>>> method like this in scala:
>>>>> @NativeFunction("(i32*)v")
>>>>> def fn(i: Array[Int]): Unit
>>>>>
>>>>> and have java foreign recognize that as a valid binding
>>>> Uhm - not 100% sure about that. (i32*) means - one i32 parameter,
>>>> followed by a varargs list - e.g. in C
>>>>
>>>> f(int i, ...)
>>>>
>>>> So, how can you prove that an Array[Int] is the right type to hold all
>>>> of the parameters?
>>>>
>>>> One thing you might want to consider actually, would be for you to use
>>>> the SystemABI API directly, to get a MethodHandle that accessed the
>>>> right native function, and maybe add a varargs adaptation on top. In
>>>> other words, I'm not sure how much of what you are doing needs
>>>> panama/foreign an the annotation stuff, and how much of what you could
>>>> do using the low level support in foreign-abi. Since that's lower level
>>>> it will give you many more options on how to surface it at the Scala
>>>> level.
>>>>
>>>> Maurizio
>>>>
>>>>> , that would allow me
>>>>> to have a pure scala binding and make java.foreign 100% compatible with
>>>>> scala. I'm hopefuly that this is a possibility, though I'd understand if
>>>>> it's not something the project panama team wants to do or devote
>>>>> resources to.
>
>
>
More information about the panama-dev
mailing list