-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jnipp: Upstream updates, including fixes for crashes.
Fixes issues related to manual attaching/detaching thread from VM.
- Loading branch information
Showing
8 changed files
with
185 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- pr.285.gh.OpenXR-SDK-Source | ||
--- | ||
Android loader: Update vendored jnipp project, including crash/exception fixes if an application manually attached or detached a thread. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021, Collabora, Ltd. | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
cmake_minimum_required(VERSION 3.10.2) | ||
project(jnipp) | ||
|
||
find_package(JNI REQUIRED) | ||
include(CTest) | ||
|
||
add_library(jnipp jnipp.cpp) | ||
target_include_directories( | ||
jnipp | ||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} | ||
PRIVATE ${JNI_INCLUDE_DIRS}) | ||
target_link_libraries(jnipp PUBLIC ${CMAKE_DL_LIBS}) | ||
|
||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021, Collabora, Ltd. | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
add_executable(main_test main.cpp testing.h) | ||
target_link_libraries(main_test PRIVATE jnipp) | ||
add_test(NAME main_test COMMAND main_test) | ||
|
||
add_executable(external_create external_create.cpp testing.h) | ||
target_link_libraries(external_create PUBLIC jnipp ${JNI_LIBRARIES}) | ||
target_include_directories(external_create PUBLIC ${JNI_INCLUDE_DIRS}) | ||
add_test(NAME external_create COMMAND external_create) | ||
|
||
|
||
add_executable(external_detach external_detach.cpp testing.h) | ||
target_link_libraries(external_detach PUBLIC jnipp ${JNI_LIBRARIES}) | ||
target_include_directories(external_detach PUBLIC ${JNI_INCLUDE_DIRS}) | ||
add_test(NAME external_detach COMMAND external_detach) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Project Dependencies | ||
#include <jni.h> | ||
#include <jnipp.h> | ||
|
||
// Standard Dependencies | ||
#include <cmath> | ||
|
||
// Local Dependencies | ||
#include "testing.h" | ||
|
||
/* | ||
jni::Vm Tests | ||
*/ | ||
TEST(Vm_externalCreateAndAttach) { | ||
JNIEnv *env; | ||
JavaVMInitArgs args = {}; | ||
args.version = JNI_VERSION_1_2; | ||
JavaVM *javaVm{}; | ||
auto ret = JNI_CreateJavaVM(&javaVm, (void **)&env, &args); | ||
ASSERT(ret == 0); | ||
|
||
{ | ||
jni::init(env); | ||
jni::Class cls("java/lang/String"); | ||
} | ||
JavaVM *localVmPointer{}; | ||
|
||
ret = env->GetJavaVM(&localVmPointer); | ||
ASSERT(ret == 0); | ||
} | ||
|
||
int main() { | ||
// jni::Vm Tests | ||
RUN_TEST(Vm_externalCreateAndAttach); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Project Dependencies | ||
#include <jni.h> | ||
#include <jnipp.h> | ||
|
||
// Standard Dependencies | ||
#include <cmath> | ||
|
||
// Local Dependencies | ||
#include "testing.h" | ||
|
||
/* | ||
jni::Vm Tests | ||
*/ | ||
TEST(Vm_externalDetach) { | ||
jni::Vm vm; | ||
|
||
jni::Class cls("java/lang/String"); | ||
|
||
JNIEnv *env = (JNIEnv *)jni::env(); | ||
JavaVM *localVmPointer{}; | ||
|
||
auto ret = env->GetJavaVM(&localVmPointer); | ||
ASSERT(ret == 0); | ||
ret = localVmPointer->DetachCurrentThread(); | ||
ASSERT(ret == 0); | ||
|
||
ASSERT(1); | ||
} | ||
|
||
int main() { | ||
// jni::Vm Tests | ||
RUN_TEST(Vm_externalDetach); | ||
return 0; | ||
} |
Oops, something went wrong.