Fri, 24 Sep 2010 22:42:14 -0700
6891766: Vulnerabilities in use of reflection in CORBA
Reviewed-by: hawtin
duke@1 | 1 | /* |
ohair@158 | 2 | * Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@158 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@158 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@158 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@158 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@158 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | package org.omg.CORBA; |
duke@1 | 26 | |
duke@1 | 27 | /** |
duke@1 | 28 | * An object that indicates whether a method had completed running |
duke@1 | 29 | * when a <code>SystemException</code> was thrown. |
duke@1 | 30 | * <P> |
duke@1 | 31 | * The class <code>CompletionStatus</code> |
duke@1 | 32 | * contains three <code>CompletionStatus</code> instances, which are constants |
duke@1 | 33 | * representing each |
duke@1 | 34 | * possible completion status: <code>COMPLETED_MAYBE</code>, |
duke@1 | 35 | * <code>COMPLETED_NO</code>, and <code>COMPLETED_YES</code>. |
duke@1 | 36 | * It also contains |
duke@1 | 37 | * three <code>int</code> members, each a constant corresponding to one of |
duke@1 | 38 | * the <code>CompletionStatus</code> instances. These <code>int</code> |
duke@1 | 39 | * members make it possible to use a <code>switch</code> statement. |
duke@1 | 40 | * <P> |
duke@1 | 41 | * The class also contains two methods: |
duke@1 | 42 | * <UL> |
duke@1 | 43 | * <LI><code>public int <bold>value</bold>()</code> -- which accesses the |
duke@1 | 44 | * <code>value</code> field of a <code>CompletionStatus</code> object |
duke@1 | 45 | * <LI><code>public static CompletionStatus |
duke@1 | 46 | * <bold>from_int</bold>(int i)</code> -- |
duke@1 | 47 | * for creating an instance from one of the <code>int</code> members |
duke@1 | 48 | * </UL> |
duke@1 | 49 | * @see org.omg.CORBA.SystemException |
duke@1 | 50 | * @since JDK1.2 |
duke@1 | 51 | */ |
duke@1 | 52 | |
duke@1 | 53 | public final class CompletionStatus implements org.omg.CORBA.portable.IDLEntity |
duke@1 | 54 | { |
duke@1 | 55 | /** |
duke@1 | 56 | * The constant indicating that a method completed running |
duke@1 | 57 | * before a <code>SystemException</code> was thrown. |
duke@1 | 58 | */ |
duke@1 | 59 | public static final int _COMPLETED_YES = 0, |
duke@1 | 60 | |
duke@1 | 61 | /** |
duke@1 | 62 | * The constant indicating that a method had not completed running |
duke@1 | 63 | * when a <code>SystemException</code> was thrown. |
duke@1 | 64 | */ |
duke@1 | 65 | _COMPLETED_NO = 1, |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * The constant indicating that it is unknown whether a method had |
duke@1 | 69 | * completed running when a <code>SystemException</code> was thrown. |
duke@1 | 70 | */ |
duke@1 | 71 | _COMPLETED_MAYBE = 2; |
duke@1 | 72 | |
duke@1 | 73 | |
duke@1 | 74 | /** |
duke@1 | 75 | * An instance of <code>CompletionStatus</code> initialized with |
duke@1 | 76 | * the constant <code>_COMPLETED_YES</code>. |
duke@1 | 77 | */ |
duke@1 | 78 | public static final CompletionStatus COMPLETED_YES = new CompletionStatus(_COMPLETED_YES); |
duke@1 | 79 | |
duke@1 | 80 | /** |
duke@1 | 81 | * An instance of <code>CompletionStatus</code> initialized with |
duke@1 | 82 | * the constant <code>_COMPLETED_NO</code>. |
duke@1 | 83 | */ |
duke@1 | 84 | public static final CompletionStatus COMPLETED_NO = new CompletionStatus(_COMPLETED_NO); |
duke@1 | 85 | |
duke@1 | 86 | /** |
duke@1 | 87 | * An instance of <code>CompletionStatus</code> initialized with |
duke@1 | 88 | * the constant <code>_COMPLETED_MAYBE</code>. |
duke@1 | 89 | */ |
duke@1 | 90 | public static final CompletionStatus COMPLETED_MAYBE = new CompletionStatus(_COMPLETED_MAYBE); |
duke@1 | 91 | |
duke@1 | 92 | /** |
duke@1 | 93 | * Retrieves the value of this <code>CompletionStatus</code> object. |
duke@1 | 94 | * |
duke@1 | 95 | * @return one of the possible <code>CompletionStatus</code> values: |
duke@1 | 96 | * <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or |
duke@1 | 97 | * <code>_COMPLETED_MAYBE</code> |
duke@1 | 98 | * |
duke@1 | 99 | */ |
duke@1 | 100 | public int value() { return _value; } |
duke@1 | 101 | |
duke@1 | 102 | /** |
duke@1 | 103 | * Creates a <code>CompletionStatus</code> object from the given <code>int</code>. |
duke@1 | 104 | * |
duke@1 | 105 | * @param i one of <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or |
duke@1 | 106 | * <code>_COMPLETED_MAYBE</code> |
duke@1 | 107 | * |
duke@1 | 108 | * @return one of the possible <code>CompletionStatus</code> objects |
duke@1 | 109 | * with values: |
duke@1 | 110 | * <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or |
duke@1 | 111 | * <code>_COMPLETED_MAYBE</code> |
duke@1 | 112 | * |
duke@1 | 113 | * @exception org.omg.CORBA.BAD_PARAM if the argument given is not one of the |
duke@1 | 114 | * <code>int</code> constants defined in <code>CompletionStatus</code> |
duke@1 | 115 | */ |
duke@1 | 116 | public static CompletionStatus from_int(int i) { |
duke@1 | 117 | switch (i) { |
duke@1 | 118 | case _COMPLETED_YES: |
duke@1 | 119 | return COMPLETED_YES; |
duke@1 | 120 | case _COMPLETED_NO: |
duke@1 | 121 | return COMPLETED_NO; |
duke@1 | 122 | case _COMPLETED_MAYBE: |
duke@1 | 123 | return COMPLETED_MAYBE; |
duke@1 | 124 | default: |
duke@1 | 125 | throw new org.omg.CORBA.BAD_PARAM(); |
duke@1 | 126 | } |
duke@1 | 127 | } |
duke@1 | 128 | |
duke@1 | 129 | |
duke@1 | 130 | /** |
duke@1 | 131 | * Creates a <code>CompletionStatus</code> object from the given <code>int</code>. |
duke@1 | 132 | * |
duke@1 | 133 | * @param _value one of <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or |
duke@1 | 134 | * <code>_COMPLETED_MAYBE</code> |
duke@1 | 135 | * |
duke@1 | 136 | */ |
duke@1 | 137 | private CompletionStatus(int _value) { |
duke@1 | 138 | this._value = _value; |
duke@1 | 139 | } |
duke@1 | 140 | |
duke@1 | 141 | private int _value; |
duke@1 | 142 | } |