From c2260cf38d0e4155f7241863b73ec1f54fa0a8e2 Mon Sep 17 00:00:00 2001 From: Bradford Powell Date: Thu, 6 Sep 2012 21:01:56 -0500 Subject: [PATCH] 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. --- src/main/java/org/xerial/snappy/Snappy.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/xerial/snappy/Snappy.java b/src/main/java/org/xerial/snappy/Snappy.java index dac227f..e44ded2 100755 --- a/src/main/java/org/xerial/snappy/Snappy.java +++ b/src/main/java/org/xerial/snappy/Snappy.java @@ -26,6 +26,7 @@ package org.xerial.snappy; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.lang.ExceptionInInitializerError; import java.net.URL; import java.nio.ByteBuffer; import java.nio.charset.Charset; @@ -33,6 +34,9 @@ import java.util.Properties; /** * 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 * @@ -44,7 +48,7 @@ public class Snappy impl = SnappyLoader.load(); } catch (Exception e) { - e.printStackTrace(); + throw new ExceptionInInitializerError(e); } }