Throw ExceptionInInitializerError rather than just printing stacktrace
to stderr if the native libraries cannot be loaded. Because Errors are not checked exceptions, added to the javadoc to point out that static initialization of Snappy can throw this Error.
This commit is contained in:
parent
cd469e1138
commit
c2260cf38d
|
@ -26,6 +26,7 @@ package org.xerial.snappy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.lang.ExceptionInInitializerError;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
@ -33,6 +34,9 @@ import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Snappy API for data compression/decompression
|
* Snappy API for data compression/decompression
|
||||||
|
*
|
||||||
|
* Note: if the native libraries cannot be loaded, then an ExceptionInInitializerError
|
||||||
|
* will be thrown at first use of this class.
|
||||||
*
|
*
|
||||||
* @author leo
|
* @author leo
|
||||||
*
|
*
|
||||||
|
@ -44,7 +48,7 @@ public class Snappy
|
||||||
impl = SnappyLoader.load();
|
impl = SnappyLoader.load();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new ExceptionInInitializerError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue