mirror of
https://github.com/corda/corda.git
synced 2025-06-14 13:18:18 +00:00
avoid calling unrelated JNI methods during class initialization
The main goal here is to avoid making JNI calls from code that really shouldn't need JNI (e.g. before this patch, ArrayList.add called Math.max, which called Math.<clinit>, which called Random.<init>, which called System.currentTimeMillis). Besides following the "pay for only what you need" principle, this change ensures we can call LambdaMetaFactory methods during AOT compilation with a minimal VM (i.e. without compiling in JNI methods we don't need).
This commit is contained in:
@ -22,7 +22,9 @@ import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class System {
|
||||
private static final long NanoTimeBaseInMillis = currentTimeMillis();
|
||||
private static class NanoTime {
|
||||
public static final long BaseInMillis = currentTimeMillis();
|
||||
}
|
||||
|
||||
private static class Static {
|
||||
public static Properties properties = makeProperties();
|
||||
@ -94,7 +96,7 @@ public abstract class System {
|
||||
public static native int identityHashCode(Object o);
|
||||
|
||||
public static long nanoTime() {
|
||||
return (currentTimeMillis() - NanoTimeBaseInMillis) * 1000000;
|
||||
return (currentTimeMillis() - NanoTime.BaseInMillis) * 1000000;
|
||||
}
|
||||
|
||||
public static String mapLibraryName(String name) {
|
||||
|
Reference in New Issue
Block a user