Skip to content

Commit

Permalink
Due to a bug in Junit we need to add this flag.
Browse files Browse the repository at this point in the history
It looks like there is no intention to fix this issue.

Details: bazelbuild/bazel#16421
PiperOrigin-RevId: 610239131
  • Loading branch information
jwhpryor authored and copybara-github committed Feb 26, 2024
1 parent 3b791ed commit fbcd0b9
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 24 deletions.
19 changes: 11 additions & 8 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ cc_library(
)

# Intentionally placed at root because of issues in Bazel.
# Note: This target is mangled for 3rd party usage on export.
# In the future, hopefully Google add Android support, although, unlikely.
cc_library(
name = "jni_dep",
srcs = [
"@local_jdk//:jni_header",
"@local_jdk//:jni_md_header-linux",
],
srcs = ["@bazel_tools//tools/jdk:current_java_runtime"],
hdrs = ["jni_dep.h"],
includes = [
"external/local_jdk/include",
"external/local_jdk/include/linux",
],
includes =
select({
"@platforms//os:linux": ["external/local_jdk/include/linux"],
"@platforms//os:macos": ["external/local_jdk/include/darwin"],
"//conditions:default": [],
}) + [
"external/local_jdk/include",
],
visibility = [":__subpackages__"],
)

Expand Down
10 changes: 10 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ http_archive(
strip_prefix = "rules_cc-40548a2974f1aea06215272d9c2b47a14a24e556",
)

# Bazel platform rules (2024-01-08).
http_archive(
name = "platforms",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
],
sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
)

# GUnit.
http_archive(
name = "googletest",
Expand Down
5 changes: 3 additions & 2 deletions javatests/com/jnibind/test/ArrayTestFieldRank1.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.jnibind.test;


import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -26,7 +25,9 @@
@RunWith(JUnit4.class)
public class ArrayTestFieldRank1 {
static {
System.loadLibrary("array_test_field_rank_1_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libarray_test_field_rank_1_jni.so");
}

@AfterClass
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/ArrayTestFieldRank2.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
@RunWith(JUnit4.class)
public class ArrayTestFieldRank2 {
static {
System.loadLibrary("array_test_field_rank_2_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libarray_test_field_rank_2_jni.so");
}

@AfterClass
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/ArrayTestMethodRank1.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
@RunWith(JUnit4.class)
public class ArrayTestMethodRank1 {
static {
System.loadLibrary("array_test_method_rank_1_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libarray_test_method_rank_1_jni.so");
}

@AfterClass
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/ArrayTestMethodRank2.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
@RunWith(JUnit4.class)
public class ArrayTestMethodRank2 {
static {
System.loadLibrary("array_test_method_rank_2_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libarray_test_method_rank_2_jni.so");
}

@AfterClass
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/BuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
@RunWith(JUnit4.class)
public class BuilderTest {
static {
System.loadLibrary("builder_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libbuilder_jni.so");
}

static native void nativeJniTeardown();
Expand Down
7 changes: 5 additions & 2 deletions javatests/com/jnibind/test/ClassLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@
public final class ClassLoaderTest {
private static final String REMOTE_CLASS_PATH_KEY = "remote_class_path";
private static final String JAR_CONTAINING_CLASSES =
System.getProperty("java.library.path") + "/ClassLoaderHelperClass_deploy.jar";
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/ClassLoaderHelperClass_deploy.jar";

private static JarFile jarFile;
private static URL[] urlArray;
private static URLClassLoader urlClassLoader;

static {
System.loadLibrary("class_loader_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libclass_loader_test_jni.so");
}

@BeforeClass
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/ContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public final class ContextTest {
private static final String TAG = "ContextTest";

static {
System.loadLibrary("context_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libcontext_test_jni.so");
}

public ContextTest() {
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/FieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
@RunWith(JUnit4.class)
public class FieldTest {
static {
System.loadLibrary("field_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libfield_test_jni.so");
}

public FieldTestHelper rJniTestHelper = new FieldTestHelper();
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/GlobalObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
@RunWith(JUnit4.class)
public final class GlobalObjectTest {
static {
System.loadLibrary("global_object_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libglobal_object_test_jni.so");
}

static native void jniTearDown();
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/LocalObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
@RunWith(JUnit4.class)
public final class LocalObjectTest {
static {
System.loadLibrary("local_object_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/liblocal_object_test_jni.so");
}

static native ObjectTestHelper jniCreateNewObject();
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/MethodTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
@RunWith(JUnit4.class)
public class MethodTest {
static {
System.loadLibrary("method_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libmethod_test_jni.so");
}

static native void jniTearDown();
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/StaticTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
@RunWith(JUnit4.class)
public final class StaticTest {
static {
System.loadLibrary("static_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libstatic_test_jni.so");
}

static native void jniTearDown();
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/StringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public final class StringTest {
@Mock public StringTestHelper rJniStringTestHelper;

static {
System.loadLibrary("string_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libstring_test_jni.so");
}

static native void jniTearDown();
Expand Down
4 changes: 3 additions & 1 deletion javatests/com/jnibind/test/ThreadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public final class ThreadTest {
@Rule public final MockitoRule mockito = MockitoJUnit.rule();

static {
System.loadLibrary("thread_test_jni");
System.load(
System.getenv("JAVA_RUNFILES")
+ "/__main__/javatests/com/jnibind/test/libthread_test_jni.so");
}

public ThreadTest() {
Expand Down

0 comments on commit fbcd0b9

Please sign in to comment.