Array of booleans
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Mar 18 15:52:56 UTC 2021
On 18/03/2021 15:43, forax at univ-mlv.fr wrote:
> ----- Mail original -----
>> De: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>
>> À: "Remi Forax" <forax at univ-mlv.fr>
>> Cc: "panama-dev at openjdk.java.net'" <panama-dev at openjdk.java.net>
>> Envoyé: Jeudi 18 Mars 2021 16:31:12
>> Objet: Re: Array of booleans
>> On 18/03/2021 15:28, forax at univ-mlv.fr wrote:
>>> It works with JNI, boolean is mapped into an unsigned 8 bits
>>> https://docs.oracle.com/en/java/javase/16/docs/specs/jni/types.html
>> Yeah - it seems to be a case of different specs pointing to different
>> decisions :-)
>>
>> If the format of booleans is truly unspecified at the JVMS level (which
>> seems to be the case), then it seems like JNI is taking things a step
>> too far?
> I don't think you can practically interact with the C world if you do not fully specify the memory layout of all the primitive types of Java, hence jboolean being defined as an unsigned byte.
True, but note that this is not a problem we have with the linker; the
linker supports the C ABI. The only type related to boolean in e.g. the
SysV ABI is _Bool, which is not a first-class type.
In other words, in Panama we can choose which primitives we wanna
support - and also _how_ we wanna support them. It seems to me that
boolean support is better handled in custom adapter logic at the user
level, if the user really cares about its _Bool to come out as Java
booleans?
Maurizio
>
>> Maurizio
> Rémi
More information about the panama-dev
mailing list