Skip to content
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
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
</ciManagement>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/org/scijava/nativelib/BaseJniExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@
import java.io.OutputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Richard van der Hoff <richardv@mxtelecom.com>
*/
public abstract class BaseJniExtractor implements JniExtractor {

private static final Logger LOGGER = Logger
.getLogger("org.scijava.nativelib.BaseJniExtractor");
private static final Logger LOGGER = LoggerFactory.getLogger(
"org.scijava.nativelib.BaseJniExtractor");
private static final String JAVA_TMPDIR = "java.io.tmpdir";
private Class<?> libraryJarClass;

Expand Down Expand Up @@ -109,7 +109,7 @@ public File extractJni(final String libPath, final String libname)
throws IOException
{
String mappedlibName = System.mapLibraryName(libname);
LOGGER.log(Level.FINE, "mappedLib is " + mappedlibName);
LOGGER.debug("mappedLib is " + mappedlibName);
/*
* On Darwin, the default mapping is to .jnilib; but we use .dylibs so that library interdependencies are
* handled correctly. if we don't find a .jnilib, try .dylib instead.
Expand Down Expand Up @@ -149,19 +149,19 @@ else if (mappedlibName.endsWith(".dylib")) {
}

if (null != lib) {
LOGGER.log(Level.FINE, "URL is " + lib.toString());
LOGGER.log(Level.FINE, "URL path is " + lib.getPath());
LOGGER.debug("URL is " + lib.toString());
LOGGER.debug("URL path is " + lib.getPath());
return extractResource(getJniDir(), lib, mappedlibName);
}
LOGGER.log(Level.INFO, "Couldn't find resource " + libPath + " " +
LOGGER.info("Couldn't find resource " + libPath + " " +
mappedlibName);
throw new IOException("Couldn't find resource " + libPath + " " +
mappedlibName);
}

/** {@inheritDoc} */
public void extractRegistered() throws IOException {
LOGGER.log(Level.FINE, "Extracting libraries registered in classloader " +
LOGGER.debug("Extracting libraries registered in classloader " +
this.getClass().getClassLoader());
for (final String nativeResourcePath : nativeResourcePaths) {
final Enumeration<URL> resources =
Expand All @@ -177,7 +177,7 @@ public void extractRegistered() throws IOException {
private void extractLibrariesFromResource(final URL resource)
throws IOException
{
LOGGER.log(Level.FINE, "Extracting libraries listed in " + resource);
LOGGER.debug("Extracting libraries listed in " + resource);
BufferedReader reader = null;
try {
reader =
Expand Down Expand Up @@ -242,7 +242,7 @@ File extractResource(final File dir, final URL resource,
// to 8.3 filename legacy issues]. Theoretically a problem for ".dylib",
// but not in practice.)
final File outfile = File.createTempFile(prefix, suffix);
LOGGER.log(Level.FINE, "Extracting '" + resource + "' to '" +
LOGGER.debug("Extracting '" + resource + "' to '" +
outfile.getAbsolutePath() + "'");

// copy resource stream to temporary file
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/org/scijava/nativelib/NativeLibraryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class is a utility for loading native libraries.
Expand Down Expand Up @@ -80,8 +80,8 @@ private static enum Processor {
private static Architecture architecture = Architecture.UNKNOWN;
private static final String DELIM = "/";
private static final String JAVA_TMPDIR = "java.io.tmpdir";
private static final Logger LOGGER = Logger
.getLogger("org.scijava.nativelib.NativeLibraryUtil");
private static final Logger LOGGER = LoggerFactory.getLogger(
"org.scijava.nativelib.NativeLibraryUtil");

/**
* Determines the underlying hardware platform and architecture.
Expand Down Expand Up @@ -125,7 +125,7 @@ else if (Processor.PPC == processor) {
}
}
}
LOGGER.log(Level.FINE, "architecture is " + architecture + " os.name is " +
LOGGER.debug("architecture is " + architecture + " os.name is " +
System.getProperty("os.name").toLowerCase());
return architecture;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ else if (arch.contains("86") || arch.contains("amd")) {
}
processor = (32 == bits) ? Processor.INTEL_32 : Processor.INTEL_64;
}
LOGGER.log(Level.FINE, "processor is " + processor + " os.arch is " +
LOGGER.debug("processor is " + processor + " os.arch is " +
System.getProperty("os.arch").toLowerCase());
return processor;
}
Expand All @@ -168,7 +168,7 @@ else if (arch.contains("86") || arch.contains("amd")) {
public static String getPlatformLibraryPath() {
String path = "META-INF" + DELIM + "lib" + DELIM;
path += getArchitecture().name().toLowerCase() + DELIM;
LOGGER.log(Level.FINE, "platform specific path is " + path);
LOGGER.debug("platform specific path is " + path);
return path;
}

Expand All @@ -195,7 +195,7 @@ public static String getPlatformLibraryName(final String libName) {
name = "lib" + libName + ".dylib";
break;
}
LOGGER.log(Level.FINE, "native library name " + name);
LOGGER.debug("native library name " + name);
return name;
}

Expand Down Expand Up @@ -273,8 +273,7 @@ public static boolean loadNativeLibrary(final Class<?> libraryJarClass,
boolean success = false;

if (Architecture.UNKNOWN == getArchitecture()) {
LOGGER.log(Level.WARNING,
"No native library available for this platform.");
LOGGER.warn("No native library available for this platform.");
}
else {
try {
Expand All @@ -293,14 +292,13 @@ public static boolean loadNativeLibrary(final Class<?> libraryJarClass,
success = true;
}
catch (final IOException e) {
LOGGER
.log(Level.WARNING, "IOException creating DefaultJniExtractor", e);
LOGGER.warn("IOException creating DefaultJniExtractor", e);
}
catch (final SecurityException e) {
LOGGER.log(Level.WARNING, "Can't load dynamic library", e);
LOGGER.warn("Can't load dynamic library", e);
}
catch (final UnsatisfiedLinkError e) {
LOGGER.log(Level.WARNING, "Problem with library", e);
LOGGER.warn("Problem with library", e);
}
}
return success;
Expand Down