JDK-8217735: Q: Should jint be jboolean ?

Andrew Leonard andrew_m_leonard at uk.ibm.com
Mon Mar 4 13:22:01 UTC 2019


Thanks David, that's a good thought, so yes jboolean looks right form 
that.
Cheers
Andrew Leonard
Java Runtimes Development
IBM Hursley
IBM United Kingdom Ltd
Phone internal: 245913, external: 01962 815913
internet email: andrew_m_leonard at uk.ibm.com 




From:   David Holmes <david.holmes at oracle.com>
To:     Andrew Leonard <andrew_m_leonard at uk.ibm.com>, core-libs-dev 
<core-libs-dev at openjdk.java.net>
Date:   04/03/2019 12:52
Subject:        Re: JDK-8217735: Q: Should jint be jboolean ?



On 4/03/2019 9:30 pm, Andrew Leonard wrote:
> Hi,
> 
> This bug raised a missmatch between the Java and JNI definition for a
> native method, where Java specifies "boolean" and the JNI jint. Which is
> right, should they match?
> 
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.openjdk.java.net_browse_JDK-2D8217735&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=NaV8Iy8Ld-vjpXZFDdTbgGlRTghGHnwM75wUPd5_NUQ&m=KoeDVOc0vzvP0wizDDykj53gxMU5Zcop2nu4FsOonUQ&s=H_SBb8AJvNppMzFArFxWqfF-ss0W3le6MVndHorE7qU&e=


Old javah generates jboolean

  > cat Native.java
public class Native {
   public native boolean isTrue(boolean b);
}

  > cat Native.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Native */

#ifndef _Included_Native
#define _Included_Native
#ifdef __cplusplus
extern "C" {
#endif
/*
  * Class:     Native
  * Method:    isTrue
  * Signature: (Z)Z
  */
JNIEXPORT jboolean JNICALL Java_Native_isTrue
   (JNIEnv *, jobject, jboolean);

#ifdef __cplusplus
}
#endif
#endif

David
-----

> One part of the JVM spec that confuses me a bit is:
> 2.3.4 The boolean Type
> Although the Java Virtual Machine defines a boolean type,
> it only provides very limited support for it.
> There are no Java Virtual Machine instructions solely dedicated
> to operations on boolean values. Instead, expressions in the Java
> programming language that operate on boolean values are
> compiled to use values of the Java Virtual Machine int data type.
> 
> Thanks
> Andrew
> 
> Andrew Leonard
> Java Runtimes Development
> IBM Hursley
> IBM United Kingdom Ltd
> Phone internal: 245913, external: 01962 815913
> internet email: andrew_m_leonard at uk.ibm.com
> 
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 
3AU
> 




Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


More information about the core-libs-dev mailing list