From 32badb0199ca16d150d6dc8a71bd9d991955891f Mon Sep 17 00:00:00 2001 From: pavl_g <60224159+Scrappers-glitch@users.noreply.github.com> Date: Sat, 27 Jul 2024 07:02:38 -0400 Subject: [PATCH 1/4] Update HelloWorld.java --- .../stephengold/snapjolt/HelloWorld.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java index 3699685..98b9969 100644 --- a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java +++ b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java @@ -34,6 +34,7 @@ of this software and associated documentation files (the "Software"), to deal * Derived from HelloWorld/HelloWorld.cpp by Jorrit Rouwe. * * @author Stephen Gold sgold@sonic.net + * @author pavl_g (support for loading natives) */ public class HelloWorld { // Layer that objects can be in, determines which other objects it can collide with @@ -56,9 +57,18 @@ public class HelloWorld { // Program entry point public static void main(String[] argv) { - LibraryInfo info = new LibraryInfo(null, null, "joltjni", null); - NativeBinaryLoader loader = new NativeBinaryLoader(info); - NativeDynamicLibrary[] libraries = new NativeDynamicLibrary[] { + // compatible with Java 8, Since 1.7 + // activate for external compressions + // final Path compression = Paths.get(PropertiesProvider.USER_DIR.getSystemProperty(), "libs", "jolt-jni.jar"); + // formulate a platform-dependent extraction path + // final Path extractionPath = Paths.get(PropertiesProvider.USER_DIR.getSystemProperty(), "libs", NativeVariant.OS_NAME.getProperty(), + // NativeVariant.OS_ARCH.getProperty()); + + final Path extractionPath = Paths.get(PropertiesProvider.USER_DIR.getSystemProperty()); + + final LibraryInfo info = new LibraryInfo(null, "lib/independent-placeholder", "joltjni", extractionPath); + final NativeBinaryLoader loader = new NativeBinaryLoader(info); + final NativeDynamicLibrary[] libraries = new NativeDynamicLibrary[] { new NativeDynamicLibrary("linux/x86-64/com/github/stephengold", PlatformPredicate.LINUX_X86_64), new NativeDynamicLibrary("osx/aarch64/com/github/stephengold", PlatformPredicate.MACOS_ARM_64), new NativeDynamicLibrary("osx/x86-64/com/github/stephengold", PlatformPredicate.MACOS_X86_64), @@ -214,4 +224,4 @@ public static void main(String[] argv) // Destroy the factory Jolt.destroyFactory(); } -} \ No newline at end of file +} From aa7f60275a22f5989251029a6c9777dd77c187a9 Mon Sep 17 00:00:00 2001 From: pavl_g <60224159+Scrappers-glitch@users.noreply.github.com> Date: Sat, 27 Jul 2024 16:05:49 +0300 Subject: [PATCH 2/4] HelloWorld: import statements for the Path and Paths APIs --- src/main/java/com/github/stephengold/snapjolt/HelloWorld.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java index 98b9969..3529ebd 100644 --- a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java +++ b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java @@ -27,6 +27,9 @@ of this software and associated documentation files (the "Software"), to deal import electrostatic.snaploader.platform.NativeDynamicLibrary; import electrostatic.snaploader.platform.util.PlatformPredicate; import java.io.IOException; +import java.nio.Path; +import java.nio.Paths; + /** * A straightforward Java translation of the Jolt Physics "hello world" sample * application. From 990bc31f2c937df94472e0d0c2a0014bf9d90c06 Mon Sep 17 00:00:00 2001 From: pavl_g <60224159+Scrappers-glitch@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:21:32 -0400 Subject: [PATCH 3/4] HelloWorld: fixed the faulty import statements --- .../java/com/github/stephengold/snapjolt/HelloWorld.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java index 3529ebd..929b4ef 100644 --- a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java +++ b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java @@ -26,9 +26,10 @@ of this software and associated documentation files (the "Software"), to deal import electrostatic.snaploader.NativeBinaryLoader; import electrostatic.snaploader.platform.NativeDynamicLibrary; import electrostatic.snaploader.platform.util.PlatformPredicate; +import electrostatic.snaploader.platform.util.PropertiesProvider; import java.io.IOException; -import java.nio.Path; -import java.nio.Paths; +import java.nio.file.Path; +import java.nio.file.Paths; /** * A straightforward Java translation of the Jolt Physics "hello world" sample From 3861244df4bed7a7236743c398ba3f2f199928b9 Mon Sep 17 00:00:00 2001 From: pavl_g <60224159+Scrappers-glitch@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:58:58 -0400 Subject: [PATCH 4/4] HelloWorld: LibraryInfo. correction of the last argument type --- src/main/java/com/github/stephengold/snapjolt/HelloWorld.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java index 929b4ef..a3cd0f6 100644 --- a/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java +++ b/src/main/java/com/github/stephengold/snapjolt/HelloWorld.java @@ -70,7 +70,7 @@ public static void main(String[] argv) final Path extractionPath = Paths.get(PropertiesProvider.USER_DIR.getSystemProperty()); - final LibraryInfo info = new LibraryInfo(null, "lib/independent-placeholder", "joltjni", extractionPath); + final LibraryInfo info = new LibraryInfo(null, "lib/independent-placeholder", "joltjni", extractionPath.toString()); final NativeBinaryLoader loader = new NativeBinaryLoader(info); final NativeDynamicLibrary[] libraries = new NativeDynamicLibrary[] { new NativeDynamicLibrary("linux/x86-64/com/github/stephengold", PlatformPredicate.LINUX_X86_64),