< prev index next >

src/java.base/share/classes/java/lang/Runtime.java

Updates after review: remove status argument completely from beforeHalt

8041626: Shutdown tracing event

262      *         indicates abnormal termination. If the {@link Runtime#exit exit}                                            
263      *         (equivalently, {@link System#exit(int) System.exit}) method                                                 
264      *         has already been invoked then this status code                                                              
265      *         will override the status code passed to that method.                                                        
266      *                                                                                                                     
267      * @throws SecurityException                                                                                           
268      *         If a security manager is present and its                                                                    
269      *         {@link SecurityManager#checkExit checkExit} method                                                          
270      *         does not permit an exit with the specified status                                                           
271      *                                                                                                                     
272      * @see #exit                                                                                                          
273      * @see #addShutdownHook                                                                                               
274      * @see #removeShutdownHook                                                                                            
275      * @since 1.3                                                                                                          
276      */                                                                                                                    
277     public void halt(int status) {                                                                                         
278         SecurityManager sm = System.getSecurityManager();                                                                  
279         if (sm != null) {                                                                                                  
280             sm.checkExit(status);                                                                                          
281         }                                                                                                                  
                                                                                                                           
282         Shutdown.halt(status);                                                                                             
283     }                                                                                                                      
284 
285     /**                                                                                                                    
286      * Enable or disable finalization on exit; doing so specifies that the                                                 
287      * finalizers of all objects that have finalizers that have not yet been                                               
288      * automatically invoked are to be run before the Java runtime exits.                                                  
289      * By default, finalization on exit is disabled.                                                                       
290      *                                                                                                                     
291      * <p>If there is a security manager,                                                                                  
292      * its {@code checkExit} method is first called                                                                        
293      * with 0 as its argument to ensure the exit is allowed.                                                               
294      * This could result in a SecurityException.                                                                           
295      *                                                                                                                     
296      * @param value true to enable finalization on exit, false to disable                                                  
297      * @deprecated  This method is inherently unsafe.  It may result in                                                    
298      *      finalizers being called on live objects while other threads are                                                
299      *      concurrently manipulating those objects, resulting in erratic                                                  
300      *      behavior or deadlock.                                                                                          

262      *         indicates abnormal termination. If the {@link Runtime#exit exit}
263      *         (equivalently, {@link System#exit(int) System.exit}) method
264      *         has already been invoked then this status code
265      *         will override the status code passed to that method.
266      *
267      * @throws SecurityException
268      *         If a security manager is present and its
269      *         {@link SecurityManager#checkExit checkExit} method
270      *         does not permit an exit with the specified status
271      *
272      * @see #exit
273      * @see #addShutdownHook
274      * @see #removeShutdownHook
275      * @since 1.3
276      */
277     public void halt(int status) {
278         SecurityManager sm = System.getSecurityManager();
279         if (sm != null) {
280             sm.checkExit(status);
281         }
282         Shutdown.beforeHalt();
283         Shutdown.halt(status);
284     }
285 
286     /**
287      * Enable or disable finalization on exit; doing so specifies that the
288      * finalizers of all objects that have finalizers that have not yet been
289      * automatically invoked are to be run before the Java runtime exits.
290      * By default, finalization on exit is disabled.
291      *
292      * <p>If there is a security manager,
293      * its {@code checkExit} method is first called
294      * with 0 as its argument to ensure the exit is allowed.
295      * This could result in a SecurityException.
296      *
297      * @param value true to enable finalization on exit, false to disable
298      * @deprecated  This method is inherently unsafe.  It may result in
299      *      finalizers being called on live objects while other threads are
300      *      concurrently manipulating those objects, resulting in erratic
301      *      behavior or deadlock.
< prev index next >