Fri, 24 Sep 2010 22:42:14 -0700
6891766: Vulnerabilities in use of reflection in CORBA
Reviewed-by: hawtin
1 /*
2 * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 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 */
26 package org.omg.CORBA;
28 import org.omg.CORBA.portable.InputStream;
29 import org.omg.CORBA.portable.OutputStream;
30 import java.util.*;
31 import org.omg.CORBA.OMGVMCID;
32 import com.sun.corba.se.impl.util.SUNVMCID;
34 /**
35 * The root class for all CORBA standard exceptions. These exceptions
36 * may be thrown as a result of any CORBA operation invocation and may
37 * also be returned by many standard CORBA API methods. The standard
38 * exceptions contain a minor code, allowing more detailed specification, and a
39 * completion status. This class is subclassed to
40 * generate each one of the set of standard ORB exceptions.
41 * <code>SystemException</code> extends
42 * <code>java.lang.RuntimeException</code>; thus none of the
43 * <code>SystemException</code> exceptions need to be
44 * declared in signatures of the Java methods mapped from operations in
45 * IDL interfaces.
46 *
47 * @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
48 * Java IDL exceptions</A>
49 */
51 public abstract class SystemException extends java.lang.RuntimeException {
53 /**
54 * The CORBA Exception minor code.
55 * @serial
56 */
57 public int minor;
59 /**
60 * The status of the operation that threw this exception.
61 * @serial
62 */
63 public CompletionStatus completed;
65 /**
66 * Constructs a <code>SystemException</code> exception with the specified detail
67 * message, minor code, and completion status.
68 * A detail message is a String that describes this particular exception.
69 * @param reason the String containing a detail message
70 * @param minor the minor code
71 * @param completed the completion status
72 */
73 protected SystemException(String reason, int minor, CompletionStatus completed) {
74 super(reason);
75 this.minor = minor;
76 this.completed = completed;
77 }
79 /**
80 * Converts this exception to a representative string.
81 */
82 public String toString() {
83 // The fully qualified exception class name
84 String result = super.toString();
86 // The vmcid part
87 int vmcid = minor & 0xFFFFF000;
88 switch (vmcid) {
89 case OMGVMCID.value:
90 result += " vmcid: OMG";
91 break;
92 case SUNVMCID.value:
93 result += " vmcid: SUN";
94 break;
95 default:
96 result += " vmcid: 0x" + Integer.toHexString(vmcid);
97 break;
98 }
100 // The minor code part
101 int mc = minor & 0x00000FFF;
102 result += " minor code: " + mc;
104 // The completion status part
105 switch (completed.value()) {
106 case CompletionStatus._COMPLETED_YES:
107 result += " completed: Yes";
108 break;
109 case CompletionStatus._COMPLETED_NO:
110 result += " completed: No";
111 break;
112 case CompletionStatus._COMPLETED_MAYBE:
113 default:
114 result += " completed: Maybe";
115 break;
116 }
117 return result;
118 }
119 }