01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.io;
27:
28: /**
29: * Used to set the Windows error mode at VM initialization time.
30: * <p>
31: * The error mode decides whether the system will handle specific types of serious errors
32: * or whether the process will handle them.
33: *
34: * @since 1.6
35: */
36: public class Win32ErrorMode {
37:
38: // The system does not display the critical-error-handler message box. Instead,
39: // the system sends the error to the calling process.
40: private static final long SEM_FAILCRITICALERRORS = 0x0001;
41:
42: // The system does not display the general-protection-fault message box. This flag should
43: // only be set by debugging applications that handle general protection (GP) faults themselves
44: // with an exception handler.
45: private static final long SEM_NOGPFAULTERRORBOX = 0x0002;
46:
47: // The system automatically fixes memory alignment faults and makes them invisible
48: // to the application. It does this for the calling process and any descendant processes.
49: private static final long SEM_NOALIGNMENTFAULTEXCEPT = 0x0004;
50:
51: // The system does not display a message box when it fails to find a file. Instead,
52: // the error is returned to the calling process.
53: private static final long SEM_NOOPENFILEERRORBOX = 0x8000;
54:
55: private Win32ErrorMode() {
56: }
57:
58: /**
59: * Invoke at VM initialization time to disable the critical error message box.
60: * <p>
61: * The critial error message box is disabled unless the system property
62: * <tt>sun.io.allowCriticalErrorMessageBox</tt> is set to something other than
63: * <code>false</code>. This includes the empty string.
64: * <p>
65: * This method does nothing if invoked after VM and class library initialization
66: * has completed.
67: */
68: public static void initialize() {
69: if (!sun.misc.VM.isBooted()) {
70: String s = (String) System
71: .getProperty("sun.io.allowCriticalErrorMessageBox");
72: if (s == null || s.equals(Boolean.FALSE.toString())) {
73: long mode = setErrorMode(0);
74: mode |= SEM_FAILCRITICALERRORS;
75: setErrorMode(mode);
76: }
77: }
78: }
79:
80: // Win32 SetErrorMode
81: private static native long setErrorMode(long mode);
82: }
|