"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hsqldb/src/org/hsqldb/lib/java/JavaSystem.java" between
hsqldb-2.6.0.zip and hsqldb-2.6.1.zip

About: HSQLDB (HyperSQL DataBase) is a SQL relational database engine written in Java. It supports nearly full ANSI-92 SQL (BNF format) and full core SQL:2008.

JavaSystem.java  (hsqldb-2.6.0):JavaSystem.java  (hsqldb-2.6.1)
skipping to change at line 45 skipping to change at line 45
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.MappedByteBuffer; import java.nio.MappedByteBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
/** /**
* Handles invariants, runtime and methods * Handles invariants, runtime and methods
* *
* @author Fred Toussi (fredt@users dot sourceforge.net) * @author Fred Toussi (fredt@users dot sourceforge.net)
* @version 2.6.0 * @version 2.6.1
*/ */
public final class JavaSystem { public final class JavaSystem {
public static final Charset CS_ISO_8859_1 = Charset.forName("ISO-8859-1"); public static final Charset CS_ISO_8859_1 = Charset.forName("ISO-8859-1");
public static final Charset CS_US_ASCII = Charset.forName("US-ASCII"); public static final Charset CS_US_ASCII = Charset.forName("US-ASCII");
public static final Charset CS_UTF8 = Charset.forName("UTF-8"); public static final Charset CS_UTF8 = Charset.forName("UTF-8");
private static int javaVersion; private static int javaVersion;
static { static {
try { try {
String version = System.getProperty("java.specification.version", String version = System.getProperty("java.specification.version",
"6"); "6");
if (version.startsWith("1.")) { if (version.startsWith("1.")) {
version = version.substring(2); version = version.substring(2);
} else if (version.startsWith("0.")) {
version = "6";
} }
javaVersion = Integer.parseInt(version); javaVersion = Integer.parseInt(version);
} catch (Throwable t) { } catch (Throwable t) {
// unknow future version - default to last widely used // unknow future version - default to last widely used
javaVersion = 11; javaVersion = 11;
} }
} }
skipping to change at line 103 skipping to change at line 105
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe"); Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
Field unsafeField = unsafeClass.getDeclaredField("theUnsafe"); Field unsafeField = unsafeClass.getDeclaredField("theUnsafe");
unsafeField.setAccessible(true); unsafeField.setAccessible(true);
Object unsafe = unsafeField.get(null); Object unsafe = unsafeField.get(null);
Method invokeCleaner = unsafeClass.getMethod("invokeCleaner", Method invokeCleaner = unsafeClass.getMethod("invokeCleaner",
java.nio.ByteBuffer.class); java.nio.ByteBuffer.class);
invokeCleaner.invoke(unsafe, buffer); invokeCleaner.invoke(unsafe, buffer);
} catch (Throwable t) {
return t;
}
} else {
try {
Method cleanerMethod = buffer.getClass().getMethod("cleaner");
cleanerMethod.setAccessible(true); return null;
} catch (NoSuchMethodException e) {}
Object cleaner = cleanerMethod.invoke(buffer); catch (NoSuchFieldException e) {}
Method cleanMethod = cleaner.getClass().getMethod("clean"); catch (IllegalAccessException e) {}
catch (ClassNotFoundException e) {}
cleanMethod.invoke(cleaner); catch (InvocationTargetException e) {
} catch (NoSuchMethodException e) {
// no cleaner
return e;
} catch (InvocationTargetException e) {
// means we're not dealing with a Sun JVM?
return e; return e;
} catch (Throwable t) { } catch (Throwable t) {
return t; return t;
} }
// on any reflection error we assume that we made a mistake guessing
the java version
// and try the old code instead
} }
return null; try {
} Method cleanerMethod = buffer.getClass().getMethod("cleaner");
public static IOException toIOException(Throwable t) { cleanerMethod.setAccessible(true);
if (t instanceof IOException) { Object cleaner = cleanerMethod.invoke(buffer);
return (IOException) t; Method cleanMethod = cleaner.getClass().getMethod("clean");
}
return new IOException(t); cleanMethod.invoke(cleaner);
} return null;
} catch (NoSuchMethodException e) {}
catch (IllegalAccessException e) {}
catch (InvocationTargetException e) {
static final BigDecimal BD_1 = BigDecimal.valueOf(1L); // means we're not dealing with a Sun JVM?
static final BigDecimal MBD_1 = BigDecimal.valueOf(-1L); return e;
} catch (Throwable t) {
return t;
}
// try another fallback on any reflection error
// this is specific to older Android version 4 or older and works for ja
va.nio.DirectByteBuffer and java.nio.MappedByteBufferAdapter
try {
Method freeMethod = buffer.getClass().getMethod("free");
public static int precision(BigDecimal o) { freeMethod.setAccessible(true);
if (o == null) { freeMethod.invoke(buffer);
return 0; return null;
} catch (Throwable t) {
return t;
} }
}
int precision; public static IOException toIOException(Throwable t) {
if (o.compareTo(BD_1) < 0 && o.compareTo(MBD_1) > 0) { if (t instanceof IOException) {
precision = o.scale(); return (IOException) t;
} else {
precision = o.precision();
} }
return precision; return new IOException(t);
} }
} }
 End of changes. 16 change blocks. 
37 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)