Skip to content

Commit

Permalink
Merge branch 'main' into ffigen-compiler-opt
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharkes committed Apr 9, 2024
2 parents 09f581c + 03c16a0 commit 3b21f67
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/jnigen.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
name: "package:jnigen"
about: "Create a bug or file a feature request against package:jnigen or its support library package:jni."
labels: ["package:jnigen", "package:jni"]
projects: ["dart-lang/69"]
---
1 change: 0 additions & 1 deletion pkgs/ffigen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ Jump to [FAQ](#faq).
#### MacOS
1. Install Xcode.
2. Install Xcode command line tools - `xcode-select --install`.
3. Install LLVM - `brew install llvm`.

## Configurations
Configurations can be provided in 2 ways-
Expand Down
6 changes: 6 additions & 0 deletions pkgs/jni/src/dartjni.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ JniExceptionDetails getExceptionDetails(jthrowable exception) {
JniExceptionDetails details;
details.message = (*jniEnv)->CallObjectMethod(
jniEnv, exception, exceptionMethods.toStringMethod);
// No exception is thrown from toString.
(*jniEnv)->ExceptionClear(jniEnv);
jobject buffer =
(*jniEnv)->NewObject(jniEnv, exceptionMethods.byteArrayOutputStreamClass,
exceptionMethods.byteArrayOutputStreamCtor);
Expand All @@ -529,8 +531,12 @@ JniExceptionDetails getExceptionDetails(jthrowable exception) {
exceptionMethods.printStreamCtor, buffer);
(*jniEnv)->CallVoidMethod(
jniEnv, exception, exceptionMethods.printStackTraceMethod, printStream);
// No exception is thrown from printStackTrace.
(*jniEnv)->ExceptionClear(jniEnv);
details.stacktrace = (*jniEnv)->CallObjectMethod(
jniEnv, buffer, exceptionMethods.toStringMethod);
// No exception is thrown from toString.
(*jniEnv)->ExceptionClear(jniEnv);
details.message = to_global_ref(details.message);
details.stacktrace = to_global_ref(details.stacktrace);
return details;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/boxed_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
3 changes: 1 addition & 2 deletions pkgs/jni/test/exception_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ void main() {
Jni.spawn(dylibDir: "wrong_dir");
} on HelperNotFoundError catch (_) {
// stderr.write("\n$_\n");
Jni.spawnIfNotExists(
dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
caught = true;
} on JniVmExistsError {
stderr.writeln('cannot verify: HelperNotFoundError thrown');
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/global_env_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {

if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/isolate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/jarray_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/jbyte_buffer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/jlist_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/jmap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'test_util/test_util.dart';
void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/jobject_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/jset_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/jstring_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
// Don't forget to initialize JNI.
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/test/load_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void doGC() {
void main() {
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
6 changes: 6 additions & 0 deletions pkgs/jni/test/test_util/test_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:io';

import 'package:jni/jni.dart';
import 'package:jni/src/build_util/build_util.dart';

typedef TestCaseCallback = void Function();
Expand Down Expand Up @@ -34,3 +35,8 @@ void checkDylibIsUpToDate() {
exit(1);
}
}

void spawnJvm() {
Jni.spawnIfNotExists(
dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m", "-Xcheck:jni"]);
}
2 changes: 1 addition & 1 deletion pkgs/jni/test/type_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ final class $FType extends JObjType<F> {
void main() {
if (!Platform.isAndroid) {
checkDylibIsUpToDate();
Jni.spawnIfNotExists(dylibDir: "build/jni_libs", jvmOptions: ["-Xmx128m"]);
spawnJvm();
}
run(testRunner: test);
}
Expand Down
2 changes: 2 additions & 0 deletions pkgs/jnigen/test/test_util/bindings_test_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Future<void> bindingsTestSetup() async {
tempClassDir.path,
...jacksonJars,
kotlinTestJar,
], jvmOptions: [
"-Xcheck:jni",
]);
}
}
Expand Down

0 comments on commit 3b21f67

Please sign in to comment.