OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [vm/] [reference/] [java/] [lang/] [VMSystem.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* VMSystem.java -- helper for java.lang.system
2
   Copyright (C) 1998, 2002, 2004 Free Software Foundation
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package java.lang;
39
 
40
import java.io.BufferedInputStream;
41
import java.io.BufferedOutputStream;
42
import java.io.FileDescriptor;
43
import java.io.FileInputStream;
44
import java.io.FileOutputStream;
45
import java.io.InputStream;
46
import java.io.PrintStream;
47
 
48
/**
49
 * VMSystem is a package-private helper class for System that the
50
 * VM must implement.
51
 *
52
 * @author John Keiser
53
 */
54
final class VMSystem
55
{
56
  /**
57
   * Copy one array onto another from <code>src[srcStart]</code> ...
58
   * <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ...
59
   * <code>dest[destStart+len-1]</code>. First, the arguments are validated:
60
   * neither array may be null, they must be of compatible types, and the
61
   * start and length must fit within both arrays. Then the copying starts,
62
   * and proceeds through increasing slots.  If src and dest are the same
63
   * array, this will appear to copy the data to a temporary location first.
64
   * An ArrayStoreException in the middle of copying will leave earlier
65
   * elements copied, but later elements unchanged.
66
   *
67
   * @param src the array to copy elements from
68
   * @param srcStart the starting position in src
69
   * @param dest the array to copy elements to
70
   * @param destStart the starting position in dest
71
   * @param len the number of elements to copy
72
   * @throws NullPointerException if src or dest is null
73
   * @throws ArrayStoreException if src or dest is not an array, if they are
74
   *         not compatible array types, or if an incompatible runtime type
75
   *         is stored in dest
76
   * @throws IndexOutOfBoundsException if len is negative, or if the start or
77
   *         end copy position in either array is out of bounds
78
   */
79
  static native void arraycopy(Object src, int srcStart,
80
                               Object dest, int destStart, int len);
81
 
82
  /**
83
   * Get a hash code computed by the VM for the Object. This hash code will
84
   * be the same as Object's hashCode() method.  It is usually some
85
   * convolution of the pointer to the Object internal to the VM.  It
86
   * follows standard hash code rules, in that it will remain the same for a
87
   * given Object for the lifetime of that Object.
88
   *
89
   * @param o the Object to get the hash code for
90
   * @return the VM-dependent hash code for this Object
91
   */
92
  static native int identityHashCode(Object o);
93
 
94
  /**
95
   * Convert a library name to its platform-specific variant.
96
   *
97
   * @param libname the library name, as used in <code>loadLibrary</code>
98
   * @return the platform-specific mangling of the name
99
   * @XXX Add this method
100
  static native String mapLibraryName(String libname);
101
   */
102
 
103
  /**
104
   * Set {@link #in} to a new InputStream.
105
   *
106
   * @param in the new InputStream
107
   * @see #setIn(InputStream)
108
   */
109
  static native void setIn(InputStream in);
110
 
111
  /**
112
   * Set {@link #out} to a new PrintStream.
113
   *
114
   * @param out the new PrintStream
115
   * @see #setOut(PrintStream)
116
   */
117
  static native void setOut(PrintStream out);
118
 
119
  /**
120
   * Set {@link #err} to a new PrintStream.
121
   *
122
   * @param err the new PrintStream
123
   * @see #setErr(PrintStream)
124
   */
125
  static native void setErr(PrintStream err);
126
 
127
  /**
128
   * Get the current time, measured in the number of milliseconds from the
129
   * beginning of Jan. 1, 1970. This is gathered from the system clock, with
130
   * any attendant incorrectness (it may be timezone dependent).
131
   *
132
   * @return the current time
133
   * @see java.util.Date
134
   */
135
   public static native long currentTimeMillis();
136
 
137
  /**
138
   * Helper method which creates the standard input stream.
139
   * VM implementors may choose to construct these streams differently.
140
   * This method can also return null if the stream is created somewhere
141
   * else in the VM startup sequence.
142
   */
143
 
144
    static InputStream makeStandardInputStream()
145
    {
146
        return new BufferedInputStream(new FileInputStream(FileDescriptor.in));
147
    }
148
 
149
  /**
150
   * Helper method which creates the standard output stream.
151
   * VM implementors may choose to construct these streams differently.
152
   * This method can also return null if the stream is created somewhere
153
   * else in the VM startup sequence.
154
   */
155
 
156
    static PrintStream makeStandardOutputStream()
157
    {
158
        return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), true);
159
    }
160
  /**
161
   * Helper method which creates the standard error stream.
162
   * VM implementors may choose to construct these streams differently.
163
   * This method can also return null if the stream is created somewhere
164
   * else in the VM startup sequence.
165
   */
166
 
167
    static PrintStream makeStandardErrorStream()
168
    {
169
        return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err)), true);
170
    }
171
 
172
  /**
173
   * Gets the value of an environment variable.
174
   * Always returning null is a valid (but not very useful) implementation.
175
   *
176
   * @param name The name of the environment variable (will not be null).
177
   * @return The string value of the variable or null when the
178
   *         environment variable is not defined.
179
   */
180
  static native String getenv(String name);
181
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.