11/*
2- * Copyright 2019 Volker Berlin (i-net software)
2+ * Copyright 2019 - 2020 Volker Berlin (i-net software)
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -30,9 +30,7 @@ class ReplacementForSystem {
3030 */
3131 @ Replace ( "java/lang/System.currentTimeMillis()J" )
3232 @ Import ( module = "System" , name = "currentTimeMillis" , js = "() => BigInt(Date.now())" )
33- static long currentTimeMillis () {
34- return 0 ; // for Java compiler
35- }
33+ static native long currentTimeMillis ();
3634
3735 /**
3836 * Replacement for {@link System#arraycopy(Object, int, Object, int, int)}
@@ -45,7 +43,17 @@ static long currentTimeMillis() {
4543 "}" + //
4644 "}" )
4745 @ Replace ( "java/lang/System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V" )
48- static void arraycopy () {
49- // nothing
50- }
46+ static native void arraycopy ();
47+
48+ /**
49+ * Replacement for {@link System#identityHashCode(Object)}
50+ */
51+ @ Import ( module = "NonGC" , name = "identityHashCode" , js = "(o) => {" //
52+ + "var h=o[1];" //
53+ + "while(h==0){" //
54+ + "o[1]=h=Math.round((Math.random()-0.5)*0xffff);" //
55+ + "}" //
56+ + "return h}" )
57+ @ Replace ( "java/lang/System.identityHashCode(Ljava/lang/Object;)I" )
58+ static native int identityHashCode (Object x );
5159}
0 commit comments