下面是摘自netty的源码,由于判断运行的java 版本。
private static int javaVersion0() {
try {
// Check if its android, if so handle it the same way as java6.
//
// See https://github.com/netty/netty/issues/282
Class.forName("android.app.Application");
return 6;
} catch (ClassNotFoundException e) {
//Ignore
}
try {
Deflater.class.getDeclaredField("SYNC_FLUSH");
return 7;
} catch (Exception e) {
// Ignore
}
try {
Double.class.getDeclaredField("MIN_NORMAL");
return 6;
} catch (Exception e) {
// Ignore
}
return 5;
}
private static int javaVersion0() {
try {
// Check if its android, if so handle it the same way as java6.
//
// See https://github.com/netty/netty/issues/282
Class.forName("android.app.Application");
return 6;
} catch (ClassNotFoundException e) {
//Ignore
}
try {
Deflater.class.getDeclaredField("SYNC_FLUSH");
return 7;
} catch (Exception e) {
// Ignore
}
try {
Double.class.getDeclaredField("MIN_NORMAL");
return 6;
} catch (Exception e) {
// Ignore
}
return 5;
}