Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private JavaProfiler() {
* before linking.
*/
public static JavaProfiler getInstance() throws IOException {
return getInstance(null, null);
return getInstance(null, null, null);
}

/**
Expand All @@ -96,14 +96,19 @@ public static JavaProfiler getInstance(String scratchDir) throws IOException {
return getInstance(null, scratchDir);
}

public static synchronized JavaProfiler getInstance(String libLocation, String scratchDir) throws IOException {
return getInstance(libLocation, scratchDir, null);
}

/**
* Get a {@linkplain JavaProfiler} instance backed by the given native library and using
* the given directory as the scratch where the bundled library will be exploded
* before linking.
* @param libLocation the path to the native library to be used instead of the bundled one
* @param scratchDir directory where the bundled library will be exploded before linking; ignored when 'libLocation' is {@literal null}
* @param isMusl true to load the musl binary, false for glibc, null for unknown (we'll try to figure it out by parsing the java executable)
*/
public static synchronized JavaProfiler getInstance(String libLocation, String scratchDir) throws IOException {
public static synchronized JavaProfiler getInstance(String libLocation, String scratchDir, Boolean isMusl) throws IOException {
if (instance != null) {
return instance;
}
Expand All @@ -112,7 +117,7 @@ public static synchronized JavaProfiler getInstance(String libLocation, String s
Path libraryPath = null;
if (libLocation == null) {
OperatingSystem os = OperatingSystem.current();
String qualifier = (os == OperatingSystem.linux && isMusl()) ? "musl" : null;
String qualifier = (os == OperatingSystem.linux && (isMusl == null ? isMusl() : isMusl)) ? "musl" : null;

libraryPath = libraryFromClasspath(os, Arch.current(), qualifier, Paths.get(scratchDir != null ? scratchDir : System.getProperty("java.io.tmpdir")));
libLocation = libraryPath.toString();
Expand Down