View Javadoc

1   // System.java, created Thu Jul  4  4:50:03 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.ClassLib.Common.java.lang;
5   
6   import java.io.InputStream;
7   import java.io.PrintStream;
8   import joeq.Class.PrimordialClassLoader;
9   import joeq.Class.jq_Class;
10  import joeq.Class.jq_CompiledCode;
11  import joeq.Class.jq_StaticField;
12  import joeq.Memory.StackAddress;
13  import joeq.Runtime.ArrayCopy;
14  import joeq.Runtime.HashCode;
15  import joeq.Runtime.Reflection;
16  import joeq.Runtime.StackCodeWalker;
17  import joeq.Runtime.SystemInterface;
18  
19  /***
20   * System
21   *
22   * @author  John Whaley <jwhaley@alum.mit.edu>
23   * @version $Id: System.java 1941 2004-09-30 03:37:06Z joewhaley $
24   */
25  public abstract class System {
26  
27      private static void registerNatives() { }
28      private static void setIn0(InputStream in) {
29          Reflection.putstatic_A(_in, in);
30      }
31      private static void setOut0(PrintStream out) {
32          Reflection.putstatic_A(_out, out);
33      }
34      private static void setErr0(PrintStream err) {
35          Reflection.putstatic_A(_err, err);
36      }
37      public static long currentTimeMillis() {
38          return SystemInterface.currentTimeMillis();
39      }
40      public static void arraycopy(java.lang.Object src, int src_position,
41                                   java.lang.Object dst, int dst_position,
42                                   int length) {
43          ArrayCopy.arraycopy(src, src_position, dst, dst_position, length);
44      }
45      public static int identityHashCode(java.lang.Object x) {
46          return HashCode.identityHashCode(x);
47      }
48      public static native void initializeSystemClass();
49      static java.lang.Class getCallerClass() {
50          StackCodeWalker sw = new StackCodeWalker(null, StackAddress.getBasePointer());
51          sw.gotoNext(); sw.gotoNext(); sw.gotoNext();
52          jq_CompiledCode cc = sw.getCode();
53          if (cc == null) return null;
54          return Reflection.getJDKType(cc.getMethod().getDeclaringClass());
55      }
56      public static final jq_Class _class = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljava/lang/System;");
57      public static final jq_StaticField _in = _class.getOrCreateStaticField("in", "Ljava/io/InputStream;");
58      public static final jq_StaticField _out = _class.getOrCreateStaticField("out", "Ljava/io/PrintStream;");
59      public static final jq_StaticField _err = _class.getOrCreateStaticField("err", "Ljava/io/PrintStream;");
60      //public static final jq_StaticField _props = _class.getOrCreateStaticField("props", "Ljava/util/Properties;");
61      //public static final jq_StaticMethod _initializeSystemClass = _class.getOrCreateStaticMethod("initializeSystemClass", "()V");
62  
63  }