Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-16566: [Java] Initialize JNI components on use instead of statically #13146

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class JniWrapper {
private static final JniWrapper INSTANCE = new JniWrapper();

public static JniWrapper get() {
JniLoader.get().ensureLoaded();
return INSTANCE;
}

Expand All @@ -34,7 +35,6 @@ private JniWrapper() {
throw new UnsupportedOperationException(
"The Java C Data Interface implementation is currently only supported on 64-bit systems");
}
JniLoader.get().ensureLoaded();
}

public native void releaseSchema(long memoryAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class JniWrapper {
private static final JniWrapper INSTANCE = new JniWrapper();

public static JniWrapper get() {
JniLoader.get().ensureLoaded();
return INSTANCE;
}

private JniWrapper() {
JniLoader.get().ensureLoaded();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class JniWrapper {
private static final JniWrapper INSTANCE = new JniWrapper();

public static JniWrapper get() {
JniLoader.get().ensureLoaded();
return INSTANCE;
}

private JniWrapper() {
JniLoader.get().ensureLoaded();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
public class NativeMemoryPool implements AutoCloseable {
private final long nativeInstanceId;

static {
JniLoader.get().ensureLoaded();
}

private NativeMemoryPool(long nativeInstanceId) {
this.nativeInstanceId = nativeInstanceId;
}
Expand All @@ -35,6 +31,7 @@ private NativeMemoryPool(long nativeInstanceId) {
* Get the default memory pool. This will return arrow::default_memory_pool() directly.
*/
public static NativeMemoryPool getDefault() {
JniLoader.get().ensureLoaded();
return new NativeMemoryPool(getDefaultMemoryPool());
}

Expand All @@ -44,6 +41,7 @@ public static NativeMemoryPool getDefault() {
* from the listener in advance.
*/
public static NativeMemoryPool createListenable(ReservationListener listener) {
JniLoader.get().ensureLoaded();
return new NativeMemoryPool(createListenableMemoryPool(listener));
}

Expand Down