Is returning a value != '0' or '1' as jboolean from a JNI function legal? (original) (raw)
Xueming Shen xueming.shen at oracle.com
Fri Aug 17 17:38:48 UTC 2018
- Previous message: Is returning a value != '0' or '1' as jboolean from a JNI function legal?
- Next message: Is returning a value != '0' or '1' as jboolean from a JNI function legal?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 08/17/2018 10:25 AM, Aleksey Shipilev wrote:
On 08/17/2018 05:12 PM, Volker Simonis wrote:
The offending code in Consolemd.c looks as follows:
#define ECHO 8 JNIEXPORT jboolean JNICALL JavajavaioConsoleecho(...) { jboolean old; ... old = (tio.clflag& ECHO); ... return old; } The intention of this code is to return "true" if the ECHO flag was set but it really returns the value of ECHO (which is defined as '8' in a system header). The question now is, if a Java SE compatible VM guarantees that any arbitrary, non-zero valued jboolean will be interpreted as "JNITRUE" and only a zero valued jboolean will be interpreted as "JNIFALSE"? Or, the other way round, is the normalization performed by the HotSpot result handlers necessary (i.e. enforced by the specification) or just a convenience to fix broken code like the above from Console.echo()? I think this is intentional aftermath of boolean value normalization: https://bugs.openjdk.java.net/browse/JDK-8161720 So, JavajavaioConsoleecho looks broken and needs to be fixed, by e.g.: - old = (tio.clflag& ECHO); + old = (tio.clflag& ECHO) != 0; Thanks, -Aleksey
Yes, the code in Console_md.c need/will be updated to fix this issue. We planed and tried in early circle of jdk11 when working on 8194750, at least for the newly added code. But change had been backed out for other reason. Will fix this specific one in 12. But the existing code is about decade old, I would assume you probably still need to fix the s390x part as a "regression".
Thanks! Sherman
- Previous message: Is returning a value != '0' or '1' as jboolean from a JNI function legal?
- Next message: Is returning a value != '0' or '1' as jboolean from a JNI function legal?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]