jamvm

view lib/java/lang/VMRuntime.java @ 398:6476eceedae8

Comment out Java code that won't compile with OpenJDK's class library.

2008-08-04 Andrew John Hughes <gnu_andrew@member.fsf.org>

* lib/java/lang/VMClassLoader.java,
* lib/java/lang/VMRuntime.java,
* lib/java/lang/VMThread.java,
* lib/java/security/VMAccessController.java:
Remove GNU Classpath specific code through commenting.
author andrew
date Tue Aug 05 04:04:18 2008 +0100 (2008-08-05)
parents 71bcb27dba05
children
line source
1 /* VMRuntime.java -- VM interface to Runtime
2 Copyright (C) 2003 Free Software Foundation
4 This file is part of GNU Classpath.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
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.
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. */
38 package java.lang;
40 import java.io.File;
41 import java.io.IOException;
43 /**
44 * VMRuntime represents the interface to the Virtual Machine.
45 *
46 * @author Jeroen Frijters
47 */
48 final class VMRuntime
49 {
50 /**
51 * No instance is ever created.
52 */
54 /**
55 * Returns the number of available processors currently available to the
56 * virtual machine. This number may change over time; so a multi-processor
57 * program want to poll this to determine maximal resource usage.
58 *
59 * @return the number of processors available, at least 1
60 */
61 static native int availableProcessors();
63 /**
64 * Find out how much memory is still free for allocating Objects on the heap.
65 *
66 * @return the number of bytes of free memory for more Objects
67 */
68 static native long freeMemory();
70 /**
71 * Find out how much memory total is available on the heap for allocating
72 * Objects.
73 *
74 * @return the total number of bytes of memory for Objects
75 */
76 static native long totalMemory();
78 /**
79 * Returns the maximum amount of memory the virtual machine can attempt to
80 * use. This may be <code>Long.MAX_VALUE</code> if there is no inherent
81 * limit (or if you really do have a 8 exabyte memory!).
82 *
83 * @return the maximum number of bytes the virtual machine will attempt
84 * to allocate
85 */
86 static native long maxMemory();
88 /**
89 * Run the garbage collector. This method is more of a suggestion than
90 * anything. All this method guarantees is that the garbage collector will
91 * have "done its best" by the time it returns. Notice that garbage
92 * collection takes place even without calling this method.
93 */
94 static native void gc();
96 /**
97 * Run finalization on all Objects that are waiting to be finalized. Again,
98 * a suggestion, though a stronger one than {@link #gc()}. This calls the
99 * <code>finalize</code> method of all objects waiting to be collected.
100 *
101 * @see #finalize()
102 */
103 static native void runFinalization();
105 /**
106 * Run finalization on all finalizable Objects (even live ones). This
107 * should only be called immediately prior to VM termination.
108 *
109 * @see #finalize()
110 */
111 static void runFinalizationForExit() {}
113 /**
114 * Tell the VM to trace every bytecode instruction that executes (print out
115 * a trace of it). No guarantees are made as to where it will be printed,
116 * and the VM is allowed to ignore this request.
117 *
118 * @param on whether to turn instruction tracing on
119 */
120 static void traceInstructions(boolean on) {}
122 /**
123 * Tell the VM to trace every method call that executes (print out a trace
124 * of it). No guarantees are made as to where it will be printed, and the
125 * VM is allowed to ignore this request.
126 *
127 * @param on whether to turn method tracing on
128 */
129 static void traceMethodCalls(boolean on) {}
131 /**
132 * Native method that actually sets the finalizer setting.
133 *
134 * @param value whether to run finalizers on exit
135 */
136 static void runFinalizersOnExit(boolean value) {}
138 /**
139 * Native method that actually shuts down the virtual machine.
140 *
141 * @param status the status to end the process with
142 */
143 static native void exit(int status);
145 /**
146 * Load a file. If it has already been loaded, do nothing. The name has
147 * already been mapped to a true filename.
148 *
149 * @param filename the file to load
150 * @param loader class loader, or <code>null</code> for the boot loader
151 * @return 0 on failure, nonzero on success
152 */
153 static native int nativeLoad(String filename, ClassLoader loader);
155 /**
156 * Map a system-independent "short name" to the full file name, and append
157 * it to the path.
158 * XXX This method is being replaced by System.mapLibraryName.
159 *
160 * @param pathname the path
161 * @param libname the short version of the library name
162 * @return the full filename
163 */
164 static native String mapLibraryName(String libname);
166 /**
167 * Execute a process. The command line has already been tokenized, and
168 * the environment should contain name=value mappings. If directory is null,
169 * use the current working directory; otherwise start the process in that
170 * directory. If env is null, then the new process should inherit
171 * the environment of this process.
172 *
173 * @param cmd the non-null command tokens
174 * @param env the environment setup
175 * @param dir the directory to use, may be null
176 * @return the newly created process
177 * @throws NullPointerException if cmd or env have null elements
178 */
179 static Process exec(String[] cmd, String[] env, File dir)
180 throws IOException {
181 throw new InternalError("Process execution not implemented.");
182 /*
183 Removed to allow building against OpenJDK
184 Andrew John Hughes - July 2008
185 return VMProcess.exec(cmd, env, dir);
186 */
187 }
189 /**
190 * This method is called by Runtime.addShutdownHook() when it is
191 * called for the first time. It enables the VM to lazily setup
192 * an exit handler, should it so desire.
193 */
194 static void enableShutdownHooks() {}
195 } // class VMRuntime