Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
8286176: Add JNI_VERSION_19 to jni.h and JNI spec
Browse files Browse the repository at this point in the history
Reviewed-by: dcubed, iris, mchung, dholmes
  • Loading branch information
Alan Bateman committed Jun 17, 2022
1 parent c254c9d commit 53bf1bf
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/jni.cpp
Expand Up @@ -99,7 +99,7 @@
#include "jvmci/jvmciCompiler.hpp"
#endif

static jint CurrentVersion = JNI_VERSION_10;
static jint CurrentVersion = JNI_VERSION_19;

#if defined(_WIN32) && !defined(USE_VECTORED_EXCEPTION_HANDLING)
extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/runtime/thread.cpp
Expand Up @@ -3549,6 +3549,7 @@ jboolean Threads::is_supported_jni_version(jint version) {
if (version == JNI_VERSION_1_8) return JNI_TRUE;
if (version == JNI_VERSION_9) return JNI_TRUE;
if (version == JNI_VERSION_10) return JNI_TRUE;
if (version == JNI_VERSION_19) return JNI_TRUE;
return JNI_FALSE;
}

Expand Down
1 change: 1 addition & 0 deletions src/java.base/share/native/include/jni.h
Expand Up @@ -1990,6 +1990,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved);
#define JNI_VERSION_1_8 0x00010008
#define JNI_VERSION_9 0x00090000
#define JNI_VERSION_10 0x000a0000
#define JNI_VERSION_19 0x00130000

#ifdef __cplusplus
} /* extern "C" */
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -45,7 +45,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_EVERSION; /* JNI version not supported */
}

return JNI_VERSION_10;
return JNI_VERSION_19;
}

/*
Expand Down
Expand Up @@ -39,7 +39,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_EVERSION; /* JNI version not supported */
}

return JNI_VERSION_10;
return JNI_VERSION_19;
}


Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/native_sanity/JniVersion.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,12 +27,12 @@
*/
public class JniVersion {

public static final int JNI_VERSION_10 = 0x000a0000;
public static final int JNI_VERSION_19 = 0x00130000;

public static void main(String... args) throws Exception {
System.loadLibrary("JniVersion");
int res = getJniVersion();
if (res != JNI_VERSION_10) {
if (res != JNI_VERSION_19) {
throw new Exception("Unexpected value returned from getJniVersion(): 0x" + Integer.toHexString(res));
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,7 +28,7 @@

static jint count = 0;
static jclass test_class;
static jint current_jni_version = JNI_VERSION_10;
static jint current_jni_version = JNI_VERSION_19;

JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved) {
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/lang/StackWalker/libnativeMethod.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,7 +28,7 @@

static jclass test_class;
static jmethodID mid;
static jint current_jni_version = JNI_VERSION_10;
static jint current_jni_version = JNI_VERSION_19;

JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,7 +27,7 @@
#include "jni.h"

static jclass test_class;
static jint current_jni_version = JNI_VERSION_10;
static jint current_jni_version = JNI_VERSION_19;

JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved) {
Expand Down
Expand Up @@ -68,7 +68,7 @@ int java_cmp(const void *a, const void *b) {
int v2 = *((int*)b);

JNIEnv* env;
(*VM)->GetEnv(VM, (void**) &env, JNI_VERSION_10);
(*VM)->GetEnv(VM, (void**) &env, JNI_VERSION_19);

jclass qsortClass = (*env)->FindClass(env, "org/openjdk/bench/java/lang/foreign/QSort");
jmethodID methodId = (*env)->GetStaticMethodID(env, qsortClass, "jni_upcall_compar", "(II)I");
Expand Down

1 comment on commit 53bf1bf

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.