Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/classes/sun/io/Win32ErrorMode.java
32287 views
/*1* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.io;2627/**28* Used to set the Windows error mode at VM initialization time.29* <p>30* The error mode decides whether the system will handle specific types of serious errors31* or whether the process will handle them.32*33* @since 1.634*/35public class Win32ErrorMode {3637// The system does not display the critical-error-handler message box. Instead,38// the system sends the error to the calling process.39private static final long SEM_FAILCRITICALERRORS = 0x0001;4041// The system does not display the general-protection-fault message box. This flag should42// only be set by debugging applications that handle general protection (GP) faults themselves43// with an exception handler.44private static final long SEM_NOGPFAULTERRORBOX = 0x0002;4546// The system automatically fixes memory alignment faults and makes them invisible47// to the application. It does this for the calling process and any descendant processes.48private static final long SEM_NOALIGNMENTFAULTEXCEPT = 0x0004;4950// The system does not display a message box when it fails to find a file. Instead,51// the error is returned to the calling process.52private static final long SEM_NOOPENFILEERRORBOX = 0x8000;5354private Win32ErrorMode() {55}5657/**58* Invoke at VM initialization time to disable the critical error message box.59* <p>60* The critial error message box is disabled unless the system property61* <tt>sun.io.allowCriticalErrorMessageBox</tt> is set to something other than62* <code>false</code>. This includes the empty string.63* <p>64* This method does nothing if invoked after VM and class library initialization65* has completed.66*/67public static void initialize() {68if (!sun.misc.VM.isBooted()) {69String s = (String) System.getProperty("sun.io.allowCriticalErrorMessageBox");70if (s == null || s.equals(Boolean.FALSE.toString())) {71long mode = setErrorMode(0);72mode |= SEM_FAILCRITICALERRORS;73setErrorMode(mode);74}75}76}7778// Win32 SetErrorMode79private static native long setErrorMode(long mode);80}818283