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

Finer snaploader implementation #1

Closed
Closed
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
22 changes: 18 additions & 4 deletions src/main/java/com/github/stephengold/snapjolt/HelloWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ 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.file.Path;
import java.nio.file.Paths;

/**
* A straightforward Java translation of the Jolt Physics "hello world" sample
* application.
* <p>
* Derived from HelloWorld/HelloWorld.cpp by Jorrit Rouwe.
*
* @author Stephen Gold [email protected]
* @author pavl_g (support for loading natives)
*/
public class HelloWorld {
// Layer that objects can be in, determines which other objects it can collide with
Expand All @@ -56,9 +61,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.toString());
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),
Expand Down Expand Up @@ -214,4 +228,4 @@ public static void main(String[] argv)
// Destroy the factory
Jolt.destroyFactory();
}
}
}