Validate that sigar.jar is binary compatible with the native library
This commit is contained in:
parent
b62d3c3d3e
commit
5d984e7751
|
@ -1,3 +1,7 @@
|
||||||
|
2006-07-13 Doug MacEachern <dougm@hyperic.com>
|
||||||
|
|
||||||
|
* Validate that sigar.jar is binary compatible with the native library
|
||||||
|
|
||||||
2006-07-11 Doug MacEachern <dougm@hyperic.com>
|
2006-07-11 Doug MacEachern <dougm@hyperic.com>
|
||||||
|
|
||||||
* Port linux impl to ppc64 arch
|
* Port linux impl to ppc64 arch
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.io.InputStreamReader;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.hyperic.jni.ArchLoaderException;
|
import org.hyperic.jni.ArchLoaderException;
|
||||||
import org.hyperic.jni.ArchNotSupportedException;
|
import org.hyperic.jni.ArchNotSupportedException;
|
||||||
|
@ -60,10 +61,14 @@ public class Sigar implements SigarProxy {
|
||||||
private Cpu[] lastCpuList;
|
private Cpu[] lastCpuList;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
boolean loaded = false;
|
String nativeVersion = "unknown";
|
||||||
|
String nativeBuildDate = "unknown";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadLibrary();
|
loadLibrary();
|
||||||
loaded = true;
|
nativeVersion = getNativeVersion();
|
||||||
|
nativeBuildDate = getNativeBuildDate();
|
||||||
|
checkVersion(nativeVersion);
|
||||||
} catch (SigarException e) {
|
} catch (SigarException e) {
|
||||||
loadError = e.getMessage();
|
loadError = e.getMessage();
|
||||||
try {
|
try {
|
||||||
|
@ -74,12 +79,37 @@ public class Sigar implements SigarProxy {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loaded) {
|
|
||||||
NATIVE_VERSION_STRING = getNativeVersion();
|
NATIVE_VERSION_STRING = nativeVersion;
|
||||||
NATIVE_BUILD_DATE = getNativeBuildDate();
|
NATIVE_BUILD_DATE = nativeBuildDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkVersion(String nativeVersionString)
|
||||||
|
throws SigarException {
|
||||||
|
|
||||||
|
StringTokenizer javaVersion =
|
||||||
|
new StringTokenizer(VERSION_STRING, ".");
|
||||||
|
StringTokenizer nativeVersion =
|
||||||
|
new StringTokenizer(nativeVersionString, ".");
|
||||||
|
|
||||||
|
String[] desc = { "major", "minor", "maint" };
|
||||||
|
|
||||||
|
for (int i=0; i<desc.length; i++) {
|
||||||
|
String jv =
|
||||||
|
javaVersion.hasMoreTokens() ?
|
||||||
|
javaVersion.nextToken() : "0";
|
||||||
|
String nv =
|
||||||
|
nativeVersion.hasMoreTokens() ?
|
||||||
|
nativeVersion.nextToken() : "0";
|
||||||
|
|
||||||
|
if (!jv.equals(nv)) {
|
||||||
|
String msg =
|
||||||
|
desc[i] + " version mismatch: (" +
|
||||||
|
jv + "!=" + nv + ") " +
|
||||||
|
"java=" + VERSION_STRING +
|
||||||
|
", native=" + nativeVersionString;
|
||||||
|
throw new SigarException(msg);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
NATIVE_VERSION_STRING = NATIVE_BUILD_DATE = "N/A";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue