18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.lang;
27
28 import java.io.*;
29 import java.math.BigInteger;
30 import java.util.ArrayList;
31 import java.util.regex.Matcher;
32 import java.util.regex.Pattern;
33 import java.util.stream.Collectors;
34 import java.util.Collections;
35 import java.util.List;
36 import java.util.Optional;
37 import java.util.StringTokenizer;
38 import jdk.internal.reflect.CallerSensitive;
39 import jdk.internal.reflect.Reflection;
40
41 /**
42 * Every Java application has a single instance of class
43 * {@code Runtime} that allows the application to interface with
44 * the environment in which the application is running. The current
45 * runtime can be obtained from the {@code getRuntime} method.
46 * <p>
47 * An application cannot create its own instance of this class.
48 *
49 * @author unascribed
50 * @see java.lang.Runtime#getRuntime()
51 * @since 1.0
52 */
53
54 public class Runtime {
55 private static final Runtime currentRuntime = new Runtime();
56
57 private static Version version;
685 public native long maxMemory();
686
687 /**
688 * Runs the garbage collector.
689 * Calling this method suggests that the Java virtual machine expend
690 * effort toward recycling unused objects in order to make the memory
691 * they currently occupy available for quick reuse. When control
692 * returns from the method call, the virtual machine has made
693 * its best effort to recycle all discarded objects.
694 * <p>
695 * The name {@code gc} stands for "garbage
696 * collector". The virtual machine performs this recycling
697 * process automatically as needed, in a separate thread, even if the
698 * {@code gc} method is not invoked explicitly.
699 * <p>
700 * The method {@link System#gc()} is the conventional and convenient
701 * means of invoking this method.
702 */
703 public native void gc();
704
705 /* Wormhole for calling java.lang.ref.Finalizer.runFinalization */
706 private static native void runFinalization0();
707
708 /**
709 * Runs the finalization methods of any objects pending finalization.
710 * Calling this method suggests that the Java virtual machine expend
711 * effort toward running the {@code finalize} methods of objects
712 * that have been found to be discarded but whose {@code finalize}
713 * methods have not yet been run. When control returns from the
714 * method call, the virtual machine has made a best effort to
715 * complete all outstanding finalizations.
716 * <p>
717 * The virtual machine performs the finalization process
718 * automatically as needed, in a separate thread, if the
719 * {@code runFinalization} method is not invoked explicitly.
720 * <p>
721 * The method {@link System#runFinalization()} is the conventional
722 * and convenient means of invoking this method.
723 *
724 * @see java.lang.Object#finalize()
725 */
726 public void runFinalization() {
727 runFinalization0();
728 }
729
730 /**
731 * Not implemented, does nothing.
732 *
733 * @deprecated
734 * This method was intended to control instruction tracing.
735 * It has been superseded by JVM-specific tracing mechanisms.
736 * This method is subject to removal in a future version of Java SE.
737 *
738 * @param on ignored
739 */
740 @Deprecated(since="9", forRemoval=true)
741 public void traceInstructions(boolean on) { }
742
743 /**
744 * Not implemented, does nothing.
745 *
746 * @deprecated
747 * This method was intended to control method call tracing.
|
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.lang;
27
28 import java.io.*;
29 import java.math.BigInteger;
30 import java.util.ArrayList;
31 import java.util.regex.Matcher;
32 import java.util.regex.Pattern;
33 import java.util.stream.Collectors;
34 import java.util.Collections;
35 import java.util.List;
36 import java.util.Optional;
37 import java.util.StringTokenizer;
38
39 import jdk.internal.misc.SharedSecrets;
40 import jdk.internal.reflect.CallerSensitive;
41 import jdk.internal.reflect.Reflection;
42
43 /**
44 * Every Java application has a single instance of class
45 * {@code Runtime} that allows the application to interface with
46 * the environment in which the application is running. The current
47 * runtime can be obtained from the {@code getRuntime} method.
48 * <p>
49 * An application cannot create its own instance of this class.
50 *
51 * @author unascribed
52 * @see java.lang.Runtime#getRuntime()
53 * @since 1.0
54 */
55
56 public class Runtime {
57 private static final Runtime currentRuntime = new Runtime();
58
59 private static Version version;
687 public native long maxMemory();
688
689 /**
690 * Runs the garbage collector.
691 * Calling this method suggests that the Java virtual machine expend
692 * effort toward recycling unused objects in order to make the memory
693 * they currently occupy available for quick reuse. When control
694 * returns from the method call, the virtual machine has made
695 * its best effort to recycle all discarded objects.
696 * <p>
697 * The name {@code gc} stands for "garbage
698 * collector". The virtual machine performs this recycling
699 * process automatically as needed, in a separate thread, even if the
700 * {@code gc} method is not invoked explicitly.
701 * <p>
702 * The method {@link System#gc()} is the conventional and convenient
703 * means of invoking this method.
704 */
705 public native void gc();
706
707 /**
708 * Runs the finalization methods of any objects pending finalization.
709 * Calling this method suggests that the Java virtual machine expend
710 * effort toward running the {@code finalize} methods of objects
711 * that have been found to be discarded but whose {@code finalize}
712 * methods have not yet been run. When control returns from the
713 * method call, the virtual machine has made a best effort to
714 * complete all outstanding finalizations.
715 * <p>
716 * The virtual machine performs the finalization process
717 * automatically as needed, in a separate thread, if the
718 * {@code runFinalization} method is not invoked explicitly.
719 * <p>
720 * The method {@link System#runFinalization()} is the conventional
721 * and convenient means of invoking this method.
722 *
723 * @see java.lang.Object#finalize()
724 */
725 public void runFinalization() {
726 SharedSecrets.getJavaLangRefAccess().runFinalization();
727 }
728
729 /**
730 * Not implemented, does nothing.
731 *
732 * @deprecated
733 * This method was intended to control instruction tracing.
734 * It has been superseded by JVM-specific tracing mechanisms.
735 * This method is subject to removal in a future version of Java SE.
736 *
737 * @param on ignored
738 */
739 @Deprecated(since="9", forRemoval=true)
740 public void traceInstructions(boolean on) { }
741
742 /**
743 * Not implemented, does nothing.
744 *
745 * @deprecated
746 * This method was intended to control method call tracing.
|