Skip to content

Commit b52eb70

Browse files
author
David Holmes
committedAug 5, 2022
8287132: Retire Runtime.runFinalizersOnExit so that it always throws UOE
Reviewed-by: hseigel, iris, andrew Backport-of: 0d4cfc090c651786535529acfe5acb0209cb1d3d
1 parent deae94f commit b52eb70

File tree

24 files changed

+185
-452
lines changed

24 files changed

+185
-452
lines changed
 

‎hotspot/make/aix/makefiles/mapfile-vers-debug

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
1919
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2020
# or visit www.oracle.com if you need additional information or have any
2121
# questions.
22-
#
22+
#
2323
#
2424

2525
# Define public interface.
@@ -84,7 +84,6 @@ SUNWprivate_1.1 {
8484
JVM_DumpAllStacks;
8585
JVM_DumpThreads;
8686
JVM_EnableCompiler;
87-
JVM_Exit;
8887
JVM_FillInStackTrace;
8988
JVM_FindClassFromClass;
9089
JVM_FindClassFromClassLoader;
@@ -274,4 +273,3 @@ SUNWprivate_1.1 {
274273
local:
275274
*;
276275
};
277-

‎hotspot/make/aix/makefiles/mapfile-vers-product

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
1919
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2020
# or visit www.oracle.com if you need additional information or have any
2121
# questions.
22-
#
22+
#
2323
#
2424

2525
# Define public interface.
@@ -84,7 +84,6 @@ SUNWprivate_1.1 {
8484
JVM_DumpAllStacks;
8585
JVM_DumpThreads;
8686
JVM_EnableCompiler;
87-
JVM_Exit;
8887
JVM_FillInStackTrace;
8988
JVM_FindClassFromClass;
9089
JVM_FindClassFromClassLoader;
@@ -267,4 +266,3 @@ SUNWprivate_1.1 {
267266
local:
268267
*;
269268
};
270-

‎hotspot/make/bsd/makefiles/mapfile-vers-debug

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,6 @@
8282
_JVM_DumpAllStacks
8383
_JVM_DumpThreads
8484
_JVM_EnableCompiler
85-
_JVM_Exit
8685
_JVM_FillInStackTrace
8786
_JVM_FindClassFromCaller
8887
_JVM_FindClassFromClass
@@ -265,4 +264,3 @@
265264
_AsyncGetCallTrace
266265

267266
# INSERT VTABLE SYMBOLS HERE
268-

‎hotspot/make/bsd/makefiles/mapfile-vers-product

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,6 @@
8282
_JVM_DumpAllStacks
8383
_JVM_DumpThreads
8484
_JVM_EnableCompiler
85-
_JVM_Exit
8685
_JVM_FillInStackTrace
8786
_JVM_FindClassFromCaller
8887
_JVM_FindClassFromClass
@@ -260,4 +259,3 @@
260259
_AsyncGetCallTrace
261260

262261
# INSERT VTABLE SYMBOLS HERE
263-

‎hotspot/make/linux/makefiles/mapfile-vers-debug

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
1919
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2020
# or visit www.oracle.com if you need additional information or have any
2121
# questions.
22-
#
22+
#
2323
#
2424

2525
# Define public interface.
@@ -84,7 +84,6 @@ SUNWprivate_1.1 {
8484
JVM_DumpAllStacks;
8585
JVM_DumpThreads;
8686
JVM_EnableCompiler;
87-
JVM_Exit;
8887
JVM_FillInStackTrace;
8988
JVM_FindClassFromCaller;
9089
JVM_FindClassFromClass;
@@ -278,4 +277,3 @@ SUNWprivate_1.1 {
278277
local:
279278
*;
280279
};
281-

‎hotspot/make/linux/makefiles/mapfile-vers-product

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
1919
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2020
# or visit www.oracle.com if you need additional information or have any
2121
# questions.
22-
#
22+
#
2323
#
2424

2525
# Define public interface.
@@ -84,7 +84,6 @@ SUNWprivate_1.1 {
8484
JVM_DumpAllStacks;
8585
JVM_DumpThreads;
8686
JVM_EnableCompiler;
87-
JVM_Exit;
8887
JVM_FillInStackTrace;
8988
JVM_FindClassFromCaller;
9089
JVM_FindClassFromClass;
@@ -273,4 +272,3 @@ SUNWprivate_1.1 {
273272
local:
274273
*;
275274
};
276-

‎hotspot/make/solaris/makefiles/mapfile-vers

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
1919
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2020
# or visit www.oracle.com if you need additional information or have any
2121
# questions.
22-
#
22+
#
2323
#
2424

2525
# Define public interface.
@@ -30,7 +30,7 @@ SUNWprivate_1.1 {
3030
JNI_CreateJavaVM;
3131
JNI_GetCreatedJavaVMs;
3232
JNI_GetDefaultJavaVMInitArgs;
33-
33+
3434
# JVM
3535
JVM_Accept;
3636
JVM_ActiveProcessorCount;
@@ -84,7 +84,6 @@ SUNWprivate_1.1 {
8484
JVM_DumpAllStacks;
8585
JVM_DumpThreads;
8686
JVM_EnableCompiler;
87-
JVM_Exit;
8887
JVM_FillInStackTrace;
8988
JVM_FindClassFromCaller;
9089
JVM_FindClassFromClass;

‎hotspot/src/share/vm/classfile/vmSymbols.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -333,7 +333,6 @@
333333
template(reference_lock_name, "lock") \
334334
template(reference_discovered_name, "discovered") \
335335
template(run_finalization_name, "runFinalization") \
336-
template(run_finalizers_on_exit_name, "runFinalizersOnExit") \
337336
template(uncaughtException_name, "uncaughtException") \
338337
template(dispatchUncaughtException_name, "dispatchUncaughtException") \
339338
template(initializeSystemClass_name, "initializeSystemClass") \

‎hotspot/src/share/vm/memory/universe.cpp

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -507,31 +507,6 @@ void Universe::fixup_mirrors(TRAPS) {
507507
java_lang_Class::set_fixup_mirror_list(NULL);
508508
}
509509

510-
static bool has_run_finalizers_on_exit = false;
511-
512-
void Universe::run_finalizers_on_exit() {
513-
if (has_run_finalizers_on_exit) return;
514-
has_run_finalizers_on_exit = true;
515-
516-
// Called on VM exit. This ought to be run in a separate thread.
517-
if (TraceReferenceGC) tty->print_cr("Callback to run finalizers on exit");
518-
{
519-
PRESERVE_EXCEPTION_MARK;
520-
KlassHandle finalizer_klass(THREAD, SystemDictionary::Finalizer_klass());
521-
JavaValue result(T_VOID);
522-
JavaCalls::call_static(
523-
&result,
524-
finalizer_klass,
525-
vmSymbols::run_finalizers_on_exit_name(),
526-
vmSymbols::void_method_signature(),
527-
THREAD
528-
);
529-
// Ignore any pending exceptions
530-
CLEAR_PENDING_EXCEPTION;
531-
}
532-
}
533-
534-
535510
// initialize_vtable could cause gc if
536511
// 1) we specified true to initialize_vtable and
537512
// 2) this ran after gc was enabled

‎hotspot/src/share/vm/memory/universe.hpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -406,9 +406,6 @@ class Universe: AllStatic {
406406
static bool should_fill_in_stack_trace(Handle throwable);
407407
static void check_alignment(uintx size, uintx alignment, const char* name);
408408

409-
// Finalizer support.
410-
static void run_finalizers_on_exit();
411-
412409
// Iteration
413410

414411
// Apply "f" to the addresses of all the direct heap pointers maintained

‎hotspot/src/share/vm/prims/jvm.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -434,16 +434,6 @@ JVM_END
434434

435435
extern volatile jint vm_created;
436436

437-
JVM_ENTRY_NO_ENV(void, JVM_Exit(jint code))
438-
if (vm_created != 0 && (code == 0)) {
439-
// The VM is about to exit. We call back into Java to check whether finalizers should be run
440-
Universe::run_finalizers_on_exit();
441-
}
442-
before_exit(thread);
443-
vm_exit(code);
444-
JVM_END
445-
446-
447437
JVM_ENTRY_NO_ENV(void, JVM_BeforeHalt())
448438
JVMWrapper("JVM_BeforeHalt");
449439
EventShutdown event;

‎hotspot/src/share/vm/prims/jvm.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -155,9 +155,6 @@ JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset,
155155
/*
156156
* java.lang.Runtime
157157
*/
158-
JNIEXPORT void JNICALL
159-
JVM_Exit(jint code);
160-
161158
JNIEXPORT void JNICALL
162159
JVM_BeforeHalt();
163160

‎hotspot/src/share/vm/runtime/java.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@ extern "C" { void register_on_exit_function(void (*func)(void)) ;}
3333
// Execute code before all handles are released and thread is killed; prologue to vm_exit
3434
extern void before_exit(JavaThread * thread);
3535

36-
// Forced VM exit (i.e, internal error or JVM_Exit)
36+
// Forced VM exit (i.e, internal error or JVM_Halt)
3737
extern void vm_exit(int code);
3838

3939
// Wrapper for ::exit()

‎hotspot/src/share/vm/runtime/thread.cpp

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -3928,10 +3928,9 @@ void JavaThread::invoke_shutdown_hooks() {
39283928
// SystemDictionary::resolve_or_null will return null if there was
39293929
// an exception. If we cannot load the Shutdown class, just don't
39303930
// call Shutdown.shutdown() at all. This will mean the shutdown hooks
3931-
// and finalizers (if runFinalizersOnExit is set) won't be run.
3932-
// Note that if a shutdown hook was registered or runFinalizersOnExit
3933-
// was called, the Shutdown class would have already been loaded
3934-
// (Runtime.addShutdownHook and runFinalizersOnExit will load it).
3931+
// won't be run. Note that if a shutdown hook was registered,
3932+
// the Shutdown class would have already been loaded
3933+
// (Runtime.addShutdownHook will load it).
39353934
instanceKlassHandle shutdown_klass (THREAD, k);
39363935
JavaValue result(T_VOID);
39373936
JavaCalls::call_static(&result,
@@ -3955,7 +3954,7 @@ void JavaThread::invoke_shutdown_hooks() {
39553954
// + Wait until we are the last non-daemon thread to execute
39563955
// <-- every thing is still working at this moment -->
39573956
// + Call java.lang.Shutdown.shutdown(), which will invoke Java level
3958-
// shutdown hooks, run finalizers if finalization-on-exit
3957+
// shutdown hooks
39593958
// + Call before_exit(), prepare for VM exit
39603959
// > run VM level shutdown hooks (they are registered through JVM_OnExit(),
39613960
// currently the only user of this mechanism is File.deleteOnExit())
@@ -4012,15 +4011,8 @@ bool Threads::destroy_vm() {
40124011
}
40134012
os::wait_for_keypress_at_exit();
40144013

4015-
if (JDK_Version::is_jdk12x_version()) {
4016-
// We are the last thread running, so check if finalizers should be run.
4017-
// For 1.3 or later this is done in thread->invoke_shutdown_hooks()
4018-
HandleMark rm(thread);
4019-
Universe::run_finalizers_on_exit();
4020-
} else {
4021-
// run Java level shutdown hooks
4022-
thread->invoke_shutdown_hooks();
4023-
}
4014+
// run Java level shutdown hooks
4015+
thread->invoke_shutdown_hooks();
40244016

40254017
before_exit(thread);
40264018

‎jdk/make/mapfiles/libjava/mapfile-vers

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -140,7 +140,6 @@ SUNWprivate_1.1 {
140140
Java_java_lang_Double_longBitsToDouble;
141141
Java_java_lang_Double_doubleToRawLongBits;
142142
Java_java_lang_reflect_Proxy_defineClass0;
143-
Java_java_lang_Shutdown_runAllFinalizers;
144143
Java_java_lang_Float_intBitsToFloat;
145144
Java_java_lang_Float_floatToRawIntBits;
146145
Java_java_lang_StrictMath_IEEEremainder;
@@ -278,7 +277,7 @@ SUNWprivate_1.1 {
278277
Java_sun_misc_VM_initialize;
279278
Java_sun_misc_VMSupport_initAgentProperties;
280279
Java_sun_misc_VMSupport_getVMTemporaryDirectory;
281-
280+
282281
# ZipFile.c needs this one
283282
throwFileNotFoundException;
284283
# zip_util.c needs this

‎jdk/src/share/classes/java/lang/Runtime.java

+53-81
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -67,38 +67,32 @@ private Runtime() {}
6767
* serves as a status code; by convention, a nonzero status code indicates
6868
* abnormal termination.
6969
*
70-
* <p> The virtual machine's shutdown sequence consists of two phases. In
71-
* the first phase all registered {@link #addShutdownHook shutdown hooks},
72-
* if any, are started in some unspecified order and allowed to run
73-
* concurrently until they finish. In the second phase all uninvoked
74-
* finalizers are run if {@link #runFinalizersOnExit finalization-on-exit}
75-
* has been enabled. Once this is done the virtual machine {@link #halt
76-
* halts}.
77-
*
78-
* <p> If this method is invoked after the virtual machine has begun its
79-
* shutdown sequence then if shutdown hooks are being run this method will
80-
* block indefinitely. If shutdown hooks have already been run and on-exit
81-
* finalization has been enabled then this method halts the virtual machine
82-
* with the given status code if the status is nonzero; otherwise, it
70+
* <p> All registered {@linkplain #addShutdownHook shutdown hooks}, if any,
71+
* are started in some unspecified order and allowed to run concurrently
72+
* until they finish. Once this is done the virtual machine
73+
* {@linkplain #halt halts}.
74+
*
75+
* <p> If this method is invoked after all shutdown hooks have already
76+
* been run and the status is nonzero then this method halts the
77+
* virtual machine with the given status code. Otherwise, this method
8378
* blocks indefinitely.
8479
*
85-
* <p> The <tt>{@link System#exit(int) System.exit}</tt> method is the
86-
* conventional and convenient means of invoking this method. <p>
80+
* <p> The {@link System#exit(int) System.exit} method is the
81+
* conventional and convenient means of invoking this method.
8782
*
8883
* @param status
8984
* Termination status. By convention, a nonzero status code
9085
* indicates abnormal termination.
9186
*
9287
* @throws SecurityException
93-
* If a security manager is present and its <tt>{@link
94-
* SecurityManager#checkExit checkExit}</tt> method does not permit
88+
* If a security manager is present and its
89+
* {@link SecurityManager#checkExit checkExit} method does not permit
9590
* exiting with the specified status
9691
*
9792
* @see java.lang.SecurityException
9893
* @see java.lang.SecurityManager#checkExit(int)
9994
* @see #addShutdownHook
10095
* @see #removeShutdownHook
101-
* @see #runFinalizersOnExit
10296
* @see #halt(int)
10397
*/
10498
public void exit(int status) {
@@ -118,11 +112,11 @@ public void exit(int status) {
118112
* <ul>
119113
*
120114
* <li> The program <i>exits</i> normally, when the last non-daemon
121-
* thread exits or when the <tt>{@link #exit exit}</tt> (equivalently,
115+
* thread exits or when the {@link #exit exit} (equivalently,
122116
* {@link System#exit(int) System.exit}) method is invoked, or
123117
*
124118
* <li> The virtual machine is <i>terminated</i> in response to a
125-
* user interrupt, such as typing <tt>^C</tt>, or a system-wide event,
119+
* user interrupt, such as typing {@code ^C}, or a system-wide event,
126120
* such as user logoff or system shutdown.
127121
*
128122
* </ul>
@@ -131,20 +125,18 @@ public void exit(int status) {
131125
* thread. When the virtual machine begins its shutdown sequence it will
132126
* start all registered shutdown hooks in some unspecified order and let
133127
* them run concurrently. When all the hooks have finished it will then
134-
* run all uninvoked finalizers if finalization-on-exit has been enabled.
135-
* Finally, the virtual machine will halt. Note that daemon threads will
136-
* continue to run during the shutdown sequence, as will non-daemon threads
137-
* if shutdown was initiated by invoking the <tt>{@link #exit exit}</tt>
138-
* method.
128+
* halt. Note that daemon threads will continue to run during the shutdown
129+
* sequence, as will non-daemon threads if shutdown was initiated by
130+
* invoking the {@link #exit exit} method.
139131
*
140132
* <p> Once the shutdown sequence has begun it can be stopped only by
141-
* invoking the <tt>{@link #halt halt}</tt> method, which forcibly
133+
* invoking the {@link #halt halt} method, which forcibly
142134
* terminates the virtual machine.
143135
*
144136
* <p> Once the shutdown sequence has begun it is impossible to register a
145137
* new shutdown hook or de-register a previously-registered hook.
146138
* Attempting either of these operations will cause an
147-
* <tt>{@link IllegalStateException}</tt> to be thrown.
139+
* {@link IllegalStateException} to be thrown.
148140
*
149141
* <p> Shutdown hooks run at a delicate time in the life cycle of a virtual
150142
* machine and should therefore be coded defensively. They should, in
@@ -156,7 +148,7 @@ public void exit(int status) {
156148
* deadlocks.
157149
*
158150
* <p> Shutdown hooks should also finish their work quickly. When a
159-
* program invokes <tt>{@link #exit exit}</tt> the expectation is
151+
* program invokes {@link #exit exit} the expectation is
160152
* that the virtual machine will promptly shut down and exit. When the
161153
* virtual machine is terminated due to user logoff or system shutdown the
162154
* underlying operating system may only allow a fixed amount of time in
@@ -165,25 +157,25 @@ public void exit(int status) {
165157
* hook.
166158
*
167159
* <p> Uncaught exceptions are handled in shutdown hooks just as in any
168-
* other thread, by invoking the <tt>{@link ThreadGroup#uncaughtException
169-
* uncaughtException}</tt> method of the thread's <tt>{@link
170-
* ThreadGroup}</tt> object. The default implementation of this method
171-
* prints the exception's stack trace to <tt>{@link System#err}</tt> and
160+
* other thread, by invoking the
161+
* {@link ThreadGroup#uncaughtException uncaughtException} method of the
162+
* thread's {@link ThreadGroup} object. The default implementation of this
163+
* method prints the exception's stack trace to {@link System#err} and
172164
* terminates the thread; it does not cause the virtual machine to exit or
173165
* halt.
174166
*
175167
* <p> In rare circumstances the virtual machine may <i>abort</i>, that is,
176168
* stop running without shutting down cleanly. This occurs when the
177169
* virtual machine is terminated externally, for example with the
178-
* <tt>SIGKILL</tt> signal on Unix or the <tt>TerminateProcess</tt> call on
170+
* {@code SIGKILL} signal on Unix or the {@code TerminateProcess} call on
179171
* Microsoft Windows. The virtual machine may also abort if a native
180172
* method goes awry by, for example, corrupting internal data structures or
181173
* attempting to access nonexistent memory. If the virtual machine aborts
182174
* then no guarantee can be made about whether or not any shutdown hooks
183-
* will be run. <p>
175+
* will be run.
184176
*
185177
* @param hook
186-
* An initialized but unstarted <tt>{@link Thread}</tt> object
178+
* An initialized but unstarted {@link Thread} object
187179
*
188180
* @throws IllegalArgumentException
189181
* If the specified hook has already been registered,
@@ -196,7 +188,7 @@ public void exit(int status) {
196188
*
197189
* @throws SecurityException
198190
* If a security manager is present and it denies
199-
* <tt>{@link RuntimePermission}("shutdownHooks")</tt>
191+
* {@link RuntimePermission}{@code ("shutdownHooks")}
200192
*
201193
* @see #removeShutdownHook
202194
* @see #halt(int)
@@ -244,23 +236,22 @@ public boolean removeShutdownHook(Thread hook) {
244236
* method never returns normally.
245237
*
246238
* <p> This method should be used with extreme caution. Unlike the
247-
* <tt>{@link #exit exit}</tt> method, this method does not cause shutdown
248-
* hooks to be started and does not run uninvoked finalizers if
249-
* finalization-on-exit has been enabled. If the shutdown sequence has
250-
* already been initiated then this method does not wait for any running
251-
* shutdown hooks or finalizers to finish their work. <p>
239+
* {@link #exit exit} method, this method does not cause shutdown
240+
* hooks to be started. If the shutdown sequence has already been
241+
* initiated then this method does not wait for any running
242+
* shutdown hooks to finish their work.
252243
*
253244
* @param status
254-
* Termination status. By convention, a nonzero status code
255-
* indicates abnormal termination. If the <tt>{@link Runtime#exit
256-
* exit}</tt> (equivalently, <tt>{@link System#exit(int)
257-
* System.exit}</tt>) method has already been invoked then this
258-
* status code will override the status code passed to that method.
245+
* Termination status. By convention, a nonzero status code
246+
* indicates abnormal termination. If the {@link Runtime#exit exit}
247+
* (equivalently, {@link System#exit(int) System.exit}) method
248+
* has already been invoked then this status code
249+
* will override the status code passed to that method.
259250
*
260251
* @throws SecurityException
261-
* If a security manager is present and its <tt>{@link
262-
* SecurityManager#checkExit checkExit}</tt> method does not permit
263-
* an exit with the specified status
252+
* If a security manager is present and its
253+
* {@link SecurityManager#checkExit checkExit} method
254+
* does not permit an exit with the specified status
264255
*
265256
* @see #exit
266257
* @see #addShutdownHook
@@ -277,42 +268,23 @@ public void halt(int status) {
277268
}
278269

279270
/**
280-
* Enable or disable finalization on exit; doing so specifies that the
281-
* finalizers of all objects that have finalizers that have not yet been
282-
* automatically invoked are to be run before the Java runtime exits.
283-
* By default, finalization on exit is disabled.
284-
*
285-
* <p>If there is a security manager,
286-
* its <code>checkExit</code> method is first called
287-
* with 0 as its argument to ensure the exit is allowed.
288-
* This could result in a SecurityException.
289-
*
290-
* @param value true to enable finalization on exit, false to disable
291-
* @deprecated This method is inherently unsafe. It may result in
292-
* finalizers being called on live objects while other threads are
293-
* concurrently manipulating those objects, resulting in erratic
294-
* behavior or deadlock.
271+
* Throws {@code UnsupportedOperationException}.
295272
*
296-
* @throws SecurityException
297-
* if a security manager exists and its <code>checkExit</code>
298-
* method doesn't allow the exit.
273+
* @param value ignored
299274
*
300-
* @see java.lang.Runtime#exit(int)
301-
* @see java.lang.Runtime#gc()
302-
* @see java.lang.SecurityManager#checkExit(int)
303-
* @since JDK1.1
275+
* @deprecated This method was originally designed to enable or disable
276+
* running finalizers on exit. Running finalizers on exit was disabled by default.
277+
* If enabled, then the finalizers of all objects whose finalizers had not
278+
* yet been automatically invoked were to be run before the Java runtime exits.
279+
* That behavior is inherently unsafe. It may result in finalizers being called
280+
* on live objects while other threads are concurrently manipulating those objects,
281+
* resulting in erratic behavior or deadlock.
282+
*
283+
* @since JDK1.1
304284
*/
305285
@Deprecated
306286
public static void runFinalizersOnExit(boolean value) {
307-
SecurityManager security = System.getSecurityManager();
308-
if (security != null) {
309-
try {
310-
security.checkExit(0);
311-
} catch (SecurityException e) {
312-
throw new SecurityException("runFinalizersOnExit");
313-
}
314-
}
315-
Shutdown.setRunFinalizersOnExit(value);
287+
throw new UnsupportedOperationException();
316288
}
317289

318290
/**

‎jdk/src/share/classes/java/lang/Shutdown.java

+55-103
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,36 +25,34 @@
2525

2626
package java.lang;
2727

28-
2928
/**
3029
* Package-private utility class containing data structures and logic
3130
* governing the virtual-machine shutdown sequence.
3231
*
3332
* @author Mark Reinhold
3433
* @since 1.3
34+
*
35+
* @see java.io.Console
36+
* @see ApplicationShutdownHooks
37+
* @see java.io.DeleteOnExitHook
3538
*/
3639

3740
class Shutdown {
3841

39-
/* Shutdown state */
40-
private static final int RUNNING = 0;
41-
private static final int HOOKS = 1;
42-
private static final int FINALIZERS = 2;
43-
private static int state = RUNNING;
44-
45-
/* Should we run all finalizers upon exit? */
46-
private static boolean runFinalizersOnExit = false;
47-
4842
// The system shutdown hooks are registered with a predefined slot.
4943
// The list of shutdown hooks is as follows:
5044
// (0) Console restore hook
51-
// (1) Application hooks
45+
// (1) ApplicationShutdownHooks that invokes all registered application
46+
// shutdown hooks and waits until they finish
5247
// (2) DeleteOnExit hook
5348
private static final int MAX_SYSTEM_HOOKS = 10;
5449
private static final Runnable[] hooks = new Runnable[MAX_SYSTEM_HOOKS];
5550

5651
// the index of the currently running shutdown hook to the hooks array
57-
private static int currentRunningHook = 0;
52+
private static int currentRunningHook = -1;
53+
54+
// track whether we have already (commenced) shutdown
55+
private static boolean isShutdown;
5856

5957
/* The preceding static fields are protected by this lock */
6058
private static class Lock { };
@@ -63,54 +61,63 @@ private static class Lock { };
6361
/* Lock object for the native halt method */
6462
private static Object haltLock = new Lock();
6563

66-
/* Invoked by Runtime.runFinalizersOnExit */
67-
static void setRunFinalizersOnExit(boolean run) {
68-
synchronized (lock) {
69-
runFinalizersOnExit = run;
70-
}
71-
}
72-
73-
7464
/**
75-
* Add a new shutdown hook. Checks the shutdown state and the hook itself,
76-
* but does not do any security checks.
65+
* Add a new system shutdown hook. Checks the shutdown state and
66+
* the hook itself, but does not do any security checks.
7767
*
7868
* The registerShutdownInProgress parameter should be false except
7969
* registering the DeleteOnExitHook since the first file may
8070
* be added to the delete on exit list by the application shutdown
8171
* hooks.
8272
*
83-
* @params slot the slot in the shutdown hook array, whose element
84-
* will be invoked in order during shutdown
85-
* @params registerShutdownInProgress true to allow the hook
86-
* to be registered even if the shutdown is in progress.
87-
* @params hook the hook to be registered
73+
* @param slot the slot in the shutdown hook array, whose element
74+
* will be invoked in order during shutdown
75+
* @param registerShutdownInProgress true to allow the hook
76+
* to be registered even if the shutdown is in progress.
77+
* @param hook the hook to be registered
8878
*
89-
* @throw IllegalStateException
90-
* if registerShutdownInProgress is false and shutdown is in progress; or
91-
* if registerShutdownInProgress is true and the shutdown process
92-
* already passes the given slot
79+
* @throws IllegalStateException
80+
* if registerShutdownInProgress is false and shutdown is in progress; or
81+
* if registerShutdownInProgress is true and the shutdown process
82+
* already passes the given slot
9383
*/
9484
static void add(int slot, boolean registerShutdownInProgress, Runnable hook) {
85+
if (slot < 0 || slot >= MAX_SYSTEM_HOOKS) {
86+
throw new IllegalArgumentException("Invalid slot: " + slot);
87+
}
9588
synchronized (lock) {
9689
if (hooks[slot] != null)
9790
throw new InternalError("Shutdown hook at slot " + slot + " already registered");
9891

9992
if (!registerShutdownInProgress) {
100-
if (state > RUNNING)
93+
if (currentRunningHook >= 0)
10194
throw new IllegalStateException("Shutdown in progress");
10295
} else {
103-
if (state > HOOKS || (state == HOOKS && slot <= currentRunningHook))
96+
if (isShutdown || slot <= currentRunningHook)
10497
throw new IllegalStateException("Shutdown in progress");
10598
}
10699

107100
hooks[slot] = hook;
108101
}
109102
}
110103

111-
/* Run all registered shutdown hooks
104+
/* Run all system shutdown hooks.
105+
*
106+
* The system shutdown hooks are run in the thread synchronized on
107+
* Shutdown.class. Other threads calling Runtime::exit, Runtime::halt
108+
* or JNI DestroyJavaVM will block indefinitely.
109+
*
110+
* ApplicationShutdownHooks is registered as one single hook that starts
111+
* all application shutdown hooks and waits until they finish.
112112
*/
113113
private static void runHooks() {
114+
synchronized (lock) {
115+
/* Guard against the possibility of a daemon thread invoking exit
116+
* after DestroyJavaVM initiates the shutdown sequence
117+
*/
118+
if (isShutdown) return;
119+
}
120+
114121
for (int i=0; i < MAX_SYSTEM_HOOKS; i++) {
115122
try {
116123
Runnable hook;
@@ -121,13 +128,20 @@ private static void runHooks() {
121128
hook = hooks[i];
122129
}
123130
if (hook != null) hook.run();
124-
} catch(Throwable t) {
131+
} catch (Throwable t) {
125132
if (t instanceof ThreadDeath) {
126133
ThreadDeath td = (ThreadDeath)t;
127134
throw td;
128135
}
129136
}
130137
}
138+
139+
// set shutdown state
140+
// Synchronization is for visibility; only one thread
141+
// can ever get here.
142+
synchronized (lock) {
143+
isShutdown = true;
144+
}
131145
}
132146

133147
/* Notify the VM that it's time to halt. */
@@ -145,75 +159,23 @@ static void halt(int status) {
145159

146160
static native void halt0(int status);
147161

148-
/* Wormhole for invoking java.lang.ref.Finalizer.runAllFinalizers */
149-
private static native void runAllFinalizers();
150-
151-
152-
/* The actual shutdown sequence is defined here.
153-
*
154-
* If it weren't for runFinalizersOnExit, this would be simple -- we'd just
155-
* run the hooks and then halt. Instead we need to keep track of whether
156-
* we're running hooks or finalizers. In the latter case a finalizer could
157-
* invoke exit(1) to cause immediate termination, while in the former case
158-
* any further invocations of exit(n), for any n, simply stall. Note that
159-
* if on-exit finalizers are enabled they're run iff the shutdown is
160-
* initiated by an exit(0); they're never run on exit(n) for n != 0 or in
161-
* response to SIGINT, SIGTERM, etc.
162-
*/
163-
private static void sequence() {
164-
synchronized (lock) {
165-
/* Guard against the possibility of a daemon thread invoking exit
166-
* after DestroyJavaVM initiates the shutdown sequence
167-
*/
168-
if (state != HOOKS) return;
169-
}
170-
runHooks();
171-
boolean rfoe;
172-
synchronized (lock) {
173-
state = FINALIZERS;
174-
rfoe = runFinalizersOnExit;
175-
}
176-
if (rfoe) runAllFinalizers();
177-
}
178-
179-
180162
/* Invoked by Runtime.exit, which does all the security checks.
181163
* Also invoked by handlers for system-provided termination events,
182164
* which should pass a nonzero status code.
183165
*/
184166
static void exit(int status) {
185-
boolean runMoreFinalizers = false;
186167
synchronized (lock) {
187-
if (status != 0) runFinalizersOnExit = false;
188-
switch (state) {
189-
case RUNNING: /* Initiate shutdown */
190-
state = HOOKS;
191-
break;
192-
case HOOKS: /* Stall and halt */
193-
break;
194-
case FINALIZERS:
195-
if (status != 0) {
196-
/* Halt immediately on nonzero status */
197-
halt(status);
198-
} else {
199-
/* Compatibility with old behavior:
200-
* Run more finalizers and then halt
201-
*/
202-
runMoreFinalizers = runFinalizersOnExit;
203-
}
204-
break;
168+
if (status != 0 && isShutdown) {
169+
/* Halt immediately on nonzero status */
170+
halt(status);
205171
}
206172
}
207-
if (runMoreFinalizers) {
208-
runAllFinalizers();
209-
halt(status);
210-
}
211173
synchronized (Shutdown.class) {
212174
/* Synchronize on the class object, causing any other thread
213175
* that attempts to initiate shutdown to stall indefinitely
214176
*/
215177
beforeHalt();
216-
sequence();
178+
runHooks();
217179
halt(status);
218180
}
219181
}
@@ -224,18 +186,8 @@ static void exit(int status) {
224186
* actually halt the VM.
225187
*/
226188
static void shutdown() {
227-
synchronized (lock) {
228-
switch (state) {
229-
case RUNNING: /* Initiate shutdown */
230-
state = HOOKS;
231-
break;
232-
case HOOKS: /* Stall and then return */
233-
case FINALIZERS:
234-
break;
235-
}
236-
}
237189
synchronized (Shutdown.class) {
238-
sequence();
190+
runHooks();
239191
}
240192
}
241193

‎jdk/src/share/classes/java/lang/System.java

+20-22
Original file line numberDiff line numberDiff line change
@@ -1018,29 +1018,27 @@ public static void runFinalization() {
10181018
}
10191019

10201020
/**
1021-
* Enable or disable finalization on exit; doing so specifies that the
1022-
* finalizers of all objects that have finalizers that have not yet been
1023-
* automatically invoked are to be run before the Java runtime exits.
1024-
* By default, finalization on exit is disabled.
1025-
*
1026-
* <p>If there is a security manager,
1027-
* its <code>checkExit</code> method is first called
1028-
* with 0 as its argument to ensure the exit is allowed.
1029-
* This could result in a SecurityException.
1030-
*
1031-
* @deprecated This method is inherently unsafe. It may result in
1032-
* finalizers being called on live objects while other threads are
1033-
* concurrently manipulating those objects, resulting in erratic
1034-
* behavior or deadlock.
1035-
* @param value indicating enabling or disabling of finalization
1036-
* @throws SecurityException
1037-
* if a security manager exists and its <code>checkExit</code>
1038-
* method doesn't allow the exit.
1021+
* Throws {@code UnsupportedOperationException}.
10391022
*
1040-
* @see java.lang.Runtime#exit(int)
1041-
* @see java.lang.Runtime#gc()
1042-
* @see java.lang.SecurityManager#checkExit(int)
1043-
* @since JDK1.1
1023+
* <p>The call {@code System.runFinalizersOnExit()} is effectively
1024+
* equivalent to the call:
1025+
* <blockquote><pre>
1026+
* Runtime.runFinalizersOnExit()
1027+
* </pre></blockquote>
1028+
*
1029+
* @param value ignored
1030+
*
1031+
* @deprecated This method was originally designed to enable or disable
1032+
* running finalizers on exit. Running finalizers on exit was disabled
1033+
* by default. If enabled, then the finalizers of all objects whose
1034+
* finalizers had not yet been automatically invoked were to be run before
1035+
* the Java runtime exits. That behavior is inherently unsafe. It may
1036+
* result in finalizers being called on live objects while other threads
1037+
* are concurrently manipulating those objects, resulting in erratic
1038+
* behavior or deadlock.
1039+
*
1040+
* @see java.lang.Runtime#runFinalizersOnExit(boolean)
1041+
* @since JDK1.1
10441042
*/
10451043
@Deprecated
10461044
public static void runFinalizersOnExit(boolean value) {

‎jdk/src/share/classes/java/lang/ref/Finalizer.java

+5-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -112,15 +112,12 @@ private void runFinalizer(JavaLangAccess jla) {
112112
/* Create a privileged secondary finalizer thread in the system thread
113113
group for the given Runnable, and wait for it to complete.
114114
115-
This method is used by both runFinalization and runFinalizersOnExit.
116-
The former method invokes all pending finalizers, while the latter
117-
invokes all uninvoked finalizers if on-exit finalization has been
118-
enabled.
115+
This method is used by runFinalization.
119116
120-
These two methods could have been implemented by offloading their work
121-
to the regular finalizer thread and waiting for that thread to finish.
117+
It could have been implemented by offloading the work to the
118+
regular finalizer thread and waiting for that thread to finish.
122119
The advantage of creating a fresh thread, however, is that it insulates
123-
invokers of these methods from a stalled or deadlocked finalizer thread.
120+
invokers of that method from a stalled or deadlocked finalizer thread.
124121
*/
125122
private static void forkSecondaryFinalizer(final Runnable proc) {
126123
AccessController.doPrivileged(
@@ -164,31 +161,6 @@ public void run() {
164161
});
165162
}
166163

167-
/* Invoked by java.lang.Shutdown */
168-
static void runAllFinalizers() {
169-
if (!VM.isBooted()) {
170-
return;
171-
}
172-
173-
forkSecondaryFinalizer(new Runnable() {
174-
private volatile boolean running;
175-
public void run() {
176-
// in case of recursive call to run()
177-
if (running)
178-
return;
179-
final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
180-
running = true;
181-
for (;;) {
182-
Finalizer f;
183-
synchronized (lock) {
184-
f = unfinalized;
185-
if (f == null) break;
186-
unfinalized = f.next;
187-
}
188-
f.runFinalizer(jla);
189-
}}});
190-
}
191-
192164
private static class FinalizerThread extends Thread {
193165
private volatile boolean running;
194166
FinalizerThread(ThreadGroup g) {

‎jdk/src/share/javavm/export/jvm.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -128,9 +128,6 @@ JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset,
128128
/*
129129
* java.lang.Runtime
130130
*/
131-
JNIEXPORT void JNICALL
132-
JVM_Exit(jint code);
133-
134131
JNIEXPORT void JNICALL
135132
JVM_BeforeHalt();
136133

‎jdk/src/share/native/java/lang/Shutdown.c

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,17 +40,3 @@ Java_java_lang_Shutdown_halt0(JNIEnv *env, jclass ignored, jint code)
4040
{
4141
JVM_Halt(code);
4242
}
43-
44-
45-
JNIEXPORT void JNICALL
46-
Java_java_lang_Shutdown_runAllFinalizers(JNIEnv *env, jclass ignored)
47-
{
48-
jclass cl;
49-
jmethodID mid;
50-
51-
if ((cl = (*env)->FindClass(env, "java/lang/ref/Finalizer"))
52-
&& (mid = (*env)->GetStaticMethodID(env, cl,
53-
"runAllFinalizers", "()V"))) {
54-
(*env)->CallStaticVoidMethod(env, cl, mid);
55-
}
56-
}

‎jdk/test/java/lang/System/finalization/FinExit.java

-54
This file was deleted.

‎jdk/test/java/lang/System/finalization/FinExit.sh

-36
This file was deleted.

‎jdk/test/java/lang/System/ExitFinalizersAndJIT.java ‎jdk/test/java/lang/System/finalization/RunFinalizersOnExit.java

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,16 +21,26 @@
2121
* questions.
2222
*/
2323

24-
/* @test
25-
@bug 4119554
26-
@summary runFinalizersOnExit(true) causes JIT to be unloaded and
27-
crashes the VM. Interim fix for 1.2 beta4 -- don't unload
28-
native libraries loaded by system classes.
29-
@run main/othervm ExitFinalizersAndJIT
30-
*/
24+
/*
25+
* @test
26+
* @bug 8287132
27+
* @summary Ensure that System.runFinalizersOnExit throws
28+
* UnsupportedOperationException
29+
*/
30+
public class RunFinalizersOnExit {
31+
public static void main(String[] args) {
32+
try {
33+
System.runFinalizersOnExit(true);
34+
throw new Error("UnsupportedOperationException was not thrown");
35+
}
36+
catch (UnsupportedOperationException expected) {
37+
}
3138

32-
public class ExitFinalizersAndJIT {
33-
public static void main(String[] args) throws Exception {
34-
System.runFinalizersOnExit(true);
39+
try {
40+
System.runFinalizersOnExit(false);
41+
throw new Error("UnsupportedOperationException was not thrown");
42+
}
43+
catch (UnsupportedOperationException expected) {
44+
}
3545
}
3646
}

0 commit comments

Comments
 (0)
Please sign in to comment.