Skip to content

Commit 22812f7

Browse files
authored
Merge pull request #4 from rssdev10/julia1.7_java17
Julia1.7 java17
2 parents 1afc3e9 + c9c7a78 commit 22812f7

27 files changed

+465
-104
lines changed

build.gradle

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
buildscript {
22
repositories {
3-
jcenter()
3+
mavenCentral()
44
mavenLocal()
55
}
66
}
77

88
plugins {
99
id 'java'
10+
id 'maven-publish'
1011
}
1112

1213
group 'org.julia'
13-
version '0.0.1-SNAPSHOT'
14+
version '0.0.2-SNAPSHOT'
1415

15-
sourceCompatibility = 1.8
16+
sourceCompatibility = 1.11
1617

1718
repositories {
1819
mavenCentral()
1920
}
2021

22+
publishing {
23+
publications {
24+
maven(MavenPublication) {
25+
groupId = group
26+
artifactId = rootProject.name
27+
version = version
2128

29+
from components.java
30+
}
31+
}
32+
}
2233

2334
test {
2435
useJUnitPlatform()
2536
}
2637

2738
dependencies {
28-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
29-
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.2.0")
39+
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.2')
40+
testImplementation('org.junit.jupiter:junit-jupiter-engine:5.8.2')
3041
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/org/julia/jni/NativeUtils.java

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@
2323
*/
2424
package org.julia.jni;
2525

26-
import java.io.*;
26+
import java.io.File;
27+
import java.io.FileNotFoundException;
28+
import java.io.IOException;
29+
import java.io.InputStream;
2730
import java.lang.reflect.Field;
28-
import java.nio.file.FileSystemNotFoundException;
29-
import java.nio.file.FileSystems;
30-
import java.nio.file.Files;
31-
import java.nio.file.ProviderNotFoundException;
32-
import java.nio.file.StandardCopyOption;
31+
import java.nio.file.*;
32+
import java.util.ArrayList;
3333
import java.util.Collections;
3434
import java.util.List;
35+
import java.util.stream.Collectors;
3536

3637
/**
3738
* A simple library class which helps with loading dynamic libraries stored in the
@@ -49,6 +50,7 @@ public class NativeUtils {
4950
*/
5051
private static final int MIN_PREFIX_LENGTH = 3;
5152
public static final String NATIVE_FOLDER_PATH_PREFIX = "nativeutils";
53+
public static final String JAVA_LIBRARY_PATH = "java.library.path";
5254

5355
/**
5456
* Temporary directory which will contain the DLLs.
@@ -75,7 +77,8 @@ private NativeUtils() {
7577
* (restriction of {@link File#createTempFile(java.lang.String, java.lang.String)}).
7678
* @throws FileNotFoundException If the file could not be found inside the JAR.
7779
*/
78-
public static void loadLibraryFromJar(String path) throws IOException {
80+
public static void loadLibraryFromJar(String path, String libraryPaths) throws IOException {
81+
setupJavaLibraryPaths(libraryPaths);
7982

8083
if (null == path || !path.startsWith("/")) {
8184
throw new IllegalArgumentException("The path has to be absolute (start with '/').");
@@ -110,6 +113,10 @@ public static void loadLibraryFromJar(String path) throws IOException {
110113

111114
try {
112115
System.load(temp.getAbsolutePath());
116+
} catch (UnsatisfiedLinkError e) {
117+
throw new UnsatisfiedLinkError(
118+
String.format("%s\njava.library.path=%s\n",
119+
e.getMessage(), System.getProperty(JAVA_LIBRARY_PATH)));
113120
} finally {
114121
if (isPosixCompliant()) {
115122
// Assume POSIX compliant file system, can be deleted after loading
@@ -121,6 +128,10 @@ public static void loadLibraryFromJar(String path) throws IOException {
121128
}
122129
}
123130

131+
public static void loadLibraryFromJar(String path) throws IOException {
132+
loadLibraryFromJar(path, "");
133+
}
134+
124135
private static boolean isPosixCompliant() {
125136
try {
126137
return FileSystems.getDefault()
@@ -175,11 +186,31 @@ public static List<String> loadedLibraryNames() {
175186
final Field lib = ClassLoader.class.getDeclaredField("loadedLibraryNames");
176187
lib.setAccessible(true);
177188
Object list = lib.get(ClassLoader.getSystemClassLoader());
178-
if (list instanceof List)
189+
if (list instanceof List<?>)
179190
return (List<String>) list;
180191
} catch (IllegalAccessException | NoSuchFieldException e) {
181192
e.printStackTrace();
182193
}
183194
return Collections.emptyList();
184195
}
196+
197+
private static void setupJavaLibraryPaths(String externalPaths) {
198+
String javaLibraryPath = System.getProperty(JAVA_LIBRARY_PATH);
199+
String javaHome = System.getProperty("java.home");
200+
// if (!javaLibraryPath.contains(javaHome)) {
201+
String javaLibPath = javaHome + File.separator + "lib";
202+
final List<String> newSysPaths =
203+
new ArrayList<>(List.of(javaLibraryPath.split(File.pathSeparator)));
204+
newSysPaths.add(javaLibPath);
205+
newSysPaths.add(javaLibPath + File.separator + "server");
206+
newSysPaths.addAll(List.of(externalPaths.split(File.pathSeparator)));
207+
208+
System.setProperty(JAVA_LIBRARY_PATH,
209+
newSysPaths.stream()
210+
.filter(s -> !s.isEmpty())
211+
.distinct()
212+
.collect(Collectors.joining(File.pathSeparator))
213+
);
214+
// }
215+
}
185216
}

src/main/java/org/julia/jni/swig/Julia4J.java

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------------
22
* This file was automatically generated by SWIG (http://www.swig.org).
3-
* Version 4.0.1
3+
* Version 4.0.2
44
*
55
* Do not make changes to this file unless you know what you are doing--modify
66
* the SWIG interface file instead.
@@ -45,8 +45,8 @@ public static void jl_set_sysimg_so(SWIGTYPE_p_void handle) {
4545
Julia4JJNI.jl_set_sysimg_so(SWIGTYPE_p_void.getCPtr(handle));
4646
}
4747

48-
public static SWIGTYPE_p_ios_t jl_create_system_image() {
49-
long cPtr = Julia4JJNI.jl_create_system_image();
48+
public static SWIGTYPE_p_ios_t jl_create_system_image(SWIGTYPE_p_void arg0) {
49+
long cPtr = Julia4JJNI.jl_create_system_image(SWIGTYPE_p_void.getCPtr(arg0));
5050
return (cPtr == 0) ? null : new SWIGTYPE_p_ios_t(cPtr, false);
5151
}
5252

@@ -106,6 +106,45 @@ public static SWIGTYPE_p_jl_value_t jl_eval_string(String str) {
106106
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
107107
}
108108

109+
public static SWIGTYPE_p_jl_value_t jl_apply_generic(SWIGTYPE_p_jl_value_t F, SWIGTYPE_p_p_jl_value_t args, long nargs) {
110+
long cPtr = Julia4JJNI.jl_apply_generic(SWIGTYPE_p_jl_value_t.getCPtr(F), SWIGTYPE_p_p_jl_value_t.getCPtr(args), nargs);
111+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
112+
}
113+
114+
public static SWIGTYPE_p_jl_value_t jl_invoke(SWIGTYPE_p_jl_value_t F, SWIGTYPE_p_p_jl_value_t args, long nargs, SWIGTYPE_p_jl_method_instance_t meth) {
115+
long cPtr = Julia4JJNI.jl_invoke(SWIGTYPE_p_jl_value_t.getCPtr(F), SWIGTYPE_p_p_jl_value_t.getCPtr(args), nargs, SWIGTYPE_p_jl_method_instance_t.getCPtr(meth));
116+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
117+
}
118+
119+
public static int jl_invoke_api(SWIGTYPE_p_jl_code_instance_t linfo) {
120+
return Julia4JJNI.jl_invoke_api(SWIGTYPE_p_jl_code_instance_t.getCPtr(linfo));
121+
}
122+
123+
public static SWIGTYPE_p_jl_value_t jl_call(SWIGTYPE_p_jl_function_t f, SWIGTYPE_p_p_jl_value_t args, int nargs) {
124+
long cPtr = Julia4JJNI.jl_call(SWIGTYPE_p_jl_function_t.getCPtr(f), SWIGTYPE_p_p_jl_value_t.getCPtr(args), nargs);
125+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
126+
}
127+
128+
public static SWIGTYPE_p_jl_value_t jl_call0(SWIGTYPE_p_jl_function_t f) {
129+
long cPtr = Julia4JJNI.jl_call0(SWIGTYPE_p_jl_function_t.getCPtr(f));
130+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
131+
}
132+
133+
public static SWIGTYPE_p_jl_value_t jl_call1(SWIGTYPE_p_jl_function_t f, SWIGTYPE_p_jl_value_t a) {
134+
long cPtr = Julia4JJNI.jl_call1(SWIGTYPE_p_jl_function_t.getCPtr(f), SWIGTYPE_p_jl_value_t.getCPtr(a));
135+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
136+
}
137+
138+
public static SWIGTYPE_p_jl_value_t jl_call2(SWIGTYPE_p_jl_function_t f, SWIGTYPE_p_jl_value_t a, SWIGTYPE_p_jl_value_t b) {
139+
long cPtr = Julia4JJNI.jl_call2(SWIGTYPE_p_jl_function_t.getCPtr(f), SWIGTYPE_p_jl_value_t.getCPtr(a), SWIGTYPE_p_jl_value_t.getCPtr(b));
140+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
141+
}
142+
143+
public static SWIGTYPE_p_jl_value_t jl_call3(SWIGTYPE_p_jl_function_t f, SWIGTYPE_p_jl_value_t a, SWIGTYPE_p_jl_value_t b, SWIGTYPE_p_jl_value_t c) {
144+
long cPtr = Julia4JJNI.jl_call3(SWIGTYPE_p_jl_function_t.getCPtr(f), SWIGTYPE_p_jl_value_t.getCPtr(a), SWIGTYPE_p_jl_value_t.getCPtr(b), SWIGTYPE_p_jl_value_t.getCPtr(c));
145+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
146+
}
147+
109148
public static SWIGTYPE_p_jl_value_t jl_new_bits(SWIGTYPE_p_jl_value_t bt, SWIGTYPE_p_void data) {
110149
long cPtr = Julia4JJNI.jl_new_bits(SWIGTYPE_p_jl_value_t.getCPtr(bt), SWIGTYPE_p_void.getCPtr(data));
111150
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
@@ -201,15 +240,6 @@ public static SWIGTYPE_p_jl_sym_t jl_get_root_symbol() {
201240
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_sym_t(cPtr, false);
202241
}
203242

204-
public static SWIGTYPE_p_jl_value_t jl_generic_function_def(SWIGTYPE_p_jl_sym_t name, SWIGTYPE_p_jl_module_t module, SWIGTYPE_p_p_jl_value_t bp, SWIGTYPE_p_jl_value_t bp_owner, SWIGTYPE_p_jl_binding_t bnd) {
205-
long cPtr = Julia4JJNI.jl_generic_function_def(SWIGTYPE_p_jl_sym_t.getCPtr(name), SWIGTYPE_p_jl_module_t.getCPtr(module), SWIGTYPE_p_p_jl_value_t.getCPtr(bp), SWIGTYPE_p_jl_value_t.getCPtr(bp_owner), SWIGTYPE_p_jl_binding_t.getCPtr(bnd));
206-
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
207-
}
208-
209-
public static void jl_method_def(SWIGTYPE_p_jl_svec_t argdata, SWIGTYPE_p_jl_code_info_t f, SWIGTYPE_p_jl_module_t module) {
210-
Julia4JJNI.jl_method_def(SWIGTYPE_p_jl_svec_t.getCPtr(argdata), SWIGTYPE_p_jl_code_info_t.getCPtr(f), SWIGTYPE_p_jl_module_t.getCPtr(module));
211-
}
212-
213243
public static SWIGTYPE_p_jl_code_info_t jl_code_for_staged(SWIGTYPE_p_jl_method_instance_t linfo) {
214244
long cPtr = Julia4JJNI.jl_code_for_staged(SWIGTYPE_p_jl_method_instance_t.getCPtr(linfo));
215245
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_code_info_t(cPtr, false);
@@ -294,6 +324,11 @@ public static SWIGTYPE_p_jl_value_t jl_box_voidpointer(SWIGTYPE_p_void x) {
294324
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
295325
}
296326

327+
public static SWIGTYPE_p_jl_value_t jl_box_uint8pointer(SWIGTYPE_p_unsigned_char x) {
328+
long cPtr = Julia4JJNI.jl_box_uint8pointer(SWIGTYPE_p_unsigned_char.getCPtr(x));
329+
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
330+
}
331+
297332
public static SWIGTYPE_p_jl_value_t jl_box_ssavalue(long x) {
298333
long cPtr = Julia4JJNI.jl_box_ssavalue(x);
299334
return (cPtr == 0) ? null : new SWIGTYPE_p_jl_value_t(cPtr, false);
@@ -353,8 +388,21 @@ public static SWIGTYPE_p_void jl_unbox_voidpointer(SWIGTYPE_p_jl_value_t v) {
353388
return (cPtr == 0) ? null : new SWIGTYPE_p_void(cPtr, false);
354389
}
355390

391+
public static SWIGTYPE_p_unsigned_char jl_unbox_uint8pointer(SWIGTYPE_p_jl_value_t v) {
392+
long cPtr = Julia4JJNI.jl_unbox_uint8pointer(SWIGTYPE_p_jl_value_t.getCPtr(v));
393+
return (cPtr == 0) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
394+
}
395+
356396
public static int jl_get_size(SWIGTYPE_p_jl_value_t val, SWIGTYPE_p_size_t pnt) {
357397
return Julia4JJNI.jl_get_size(SWIGTYPE_p_jl_value_t.getCPtr(val), SWIGTYPE_p_size_t.getCPtr(pnt));
358398
}
359399

400+
public static String jl_unbox_string(SWIGTYPE_p_jl_value_t v) {
401+
return Julia4JJNI.jl_unbox_string(SWIGTYPE_p_jl_value_t.getCPtr(v));
402+
}
403+
404+
public static void jl_show(SWIGTYPE_p_jl_value_t v) {
405+
Julia4JJNI.jl_show(SWIGTYPE_p_jl_value_t.getCPtr(v));
406+
}
407+
360408
}

src/main/java/org/julia/jni/swig/Julia4JJNI.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------------
22
* This file was automatically generated by SWIG (http://www.swig.org).
3-
* Version 4.0.1
3+
* Version 4.0.2
44
*
55
* Do not make changes to this file unless you know what you are doing--modify
66
* the SWIG interface file instead.
@@ -18,7 +18,7 @@ public class Julia4JJNI {
1818
public final static native String jl_pathname_for_handle(long jarg1);
1919
public final static native void jl_preload_sysimg_so(String jarg1);
2020
public final static native void jl_set_sysimg_so(long jarg1);
21-
public final static native long jl_create_system_image();
21+
public final static native long jl_create_system_image(long jarg1);
2222
public final static native void jl_save_system_image(String jarg1);
2323
public final static native void jl_restore_system_image(String jarg1);
2424
public final static native void jl_restore_system_image_data(String jarg1, long jarg2);
@@ -31,6 +31,14 @@ public class Julia4JJNI {
3131
public final static native long jl_expand(long jarg1, long jarg2);
3232
public final static native long jl_expand_stmt(long jarg1, long jarg2);
3333
public final static native long jl_eval_string(String jarg1);
34+
public final static native long jl_apply_generic(long jarg1, long jarg2, long jarg3);
35+
public final static native long jl_invoke(long jarg1, long jarg2, long jarg3, long jarg4);
36+
public final static native int jl_invoke_api(long jarg1);
37+
public final static native long jl_call(long jarg1, long jarg2, int jarg3);
38+
public final static native long jl_call0(long jarg1);
39+
public final static native long jl_call1(long jarg1, long jarg2);
40+
public final static native long jl_call2(long jarg1, long jarg2, long jarg3);
41+
public final static native long jl_call3(long jarg1, long jarg2, long jarg3, long jarg4);
3442
public final static native long jl_new_bits(long jarg1, long jarg2);
3543
public final static native long jl_new_struct(long jarg1);
3644
public final static native long jl_new_structv(long jarg1, long jarg2, long jarg3);
@@ -50,8 +58,6 @@ public class Julia4JJNI {
5058
public final static native long jl_gensym();
5159
public final static native long jl_tagged_gensym(String jarg1, int jarg2);
5260
public final static native long jl_get_root_symbol();
53-
public final static native long jl_generic_function_def(long jarg1, long jarg2, long jarg3, long jarg4, long jarg5);
54-
public final static native void jl_method_def(long jarg1, long jarg2, long jarg3);
5561
public final static native long jl_code_for_staged(long jarg1);
5662
public final static native long jl_copy_code_info(long jarg1);
5763
public final static native long jl_get_world_counter();
@@ -69,6 +75,7 @@ public class Julia4JJNI {
6975
public final static native long jl_box_float32(float jarg1);
7076
public final static native long jl_box_float64(double jarg1);
7177
public final static native long jl_box_voidpointer(long jarg1);
78+
public final static native long jl_box_uint8pointer(long jarg1);
7279
public final static native long jl_box_ssavalue(long jarg1);
7380
public final static native long jl_box_slotnumber(long jarg1);
7481
public final static native byte jl_unbox_bool(long jarg1);
@@ -83,5 +90,8 @@ public class Julia4JJNI {
8390
public final static native float jl_unbox_float32(long jarg1);
8491
public final static native double jl_unbox_float64(long jarg1);
8592
public final static native long jl_unbox_voidpointer(long jarg1);
93+
public final static native long jl_unbox_uint8pointer(long jarg1);
8694
public final static native int jl_get_size(long jarg1, long jarg2);
95+
public final static native String jl_unbox_string(long jarg1);
96+
public final static native void jl_show(long jarg1);
8797
}

src/main/java/org/julia/jni/swig/SWIGTYPE_p_ios_t.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------------
22
* This file was automatically generated by SWIG (http://www.swig.org).
3-
* Version 4.0.1
3+
* Version 4.0.2
44
*
55
* Do not make changes to this file unless you know what you are doing--modify
66
* the SWIG interface file instead.

src/main/java/org/julia/jni/swig/SWIGTYPE_p_jl_array_t.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------------
22
* This file was automatically generated by SWIG (http://www.swig.org).
3-
* Version 4.0.1
3+
* Version 4.0.2
44
*
55
* Do not make changes to this file unless you know what you are doing--modify
66
* the SWIG interface file instead.

src/main/java/org/julia/jni/swig/SWIGTYPE_p_jl_code_info_t.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------------
22
* This file was automatically generated by SWIG (http://www.swig.org).
3-
* Version 4.0.1
3+
* Version 4.0.2
44
*
55
* Do not make changes to this file unless you know what you are doing--modify
66
* the SWIG interface file instead.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* ----------------------------------------------------------------------------
2+
* This file was automatically generated by SWIG (http://www.swig.org).
3+
* Version 4.0.2
4+
*
5+
* Do not make changes to this file unless you know what you are doing--modify
6+
* the SWIG interface file instead.
7+
* ----------------------------------------------------------------------------- */
8+
9+
package org.julia.jni.swig;
10+
11+
public class SWIGTYPE_p_jl_code_instance_t {
12+
private transient long swigCPtr;
13+
14+
protected SWIGTYPE_p_jl_code_instance_t(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
15+
swigCPtr = cPtr;
16+
}
17+
18+
protected SWIGTYPE_p_jl_code_instance_t() {
19+
swigCPtr = 0;
20+
}
21+
22+
protected static long getCPtr(SWIGTYPE_p_jl_code_instance_t obj) {
23+
return (obj == null) ? 0 : obj.swigCPtr;
24+
}
25+
}
26+

src/main/java/org/julia/jni/swig/SWIGTYPE_p_jl_datatype_t.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------------
22
* This file was automatically generated by SWIG (http://www.swig.org).
3-
* Version 4.0.1
3+
* Version 4.0.2
44
*
55
* Do not make changes to this file unless you know what you are doing--modify
66
* the SWIG interface file instead.

0 commit comments

Comments
 (0)