JDK-8217735: Q: Should jint be jboolean ?

David Holmes david.holmes at oracle.com
Mon Mar 4 12:50:48 UTC 2019


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://bugs.openjdk.java.net/browse/JDK-8217735

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
> 


More information about the core-libs-dev mailing list