src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryId_1_3_1.java

changeset 447
59bff16bc0bf
parent 439
e725dd195858
parent 446
f4f39d873b9a
child 448
996bd5fd0941
     1.1 --- a/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryId_1_3_1.java	Fri Feb 15 01:49:36 2013 +0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,1065 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.  Oracle designates this
    1.11 - * particular file as subject to the "Classpath" exception as provided
    1.12 - * by Oracle in the LICENSE file that accompanied this code.
    1.13 - *
    1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 - * version 2 for more details (a copy is included in the LICENSE file that
    1.18 - * accompanied this code).
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License version
    1.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 - *
    1.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 - * or visit www.oracle.com if you need additional information or have any
    1.26 - * questions.
    1.27 - */
    1.28 -
    1.29 -/*
    1.30 - */
    1.31 -package com.sun.corba.se.impl.orbutil;
    1.32 -
    1.33 -import java.util.StringTokenizer;
    1.34 -import java.util.Hashtable;
    1.35 -import java.io.IOException;
    1.36 -import java.lang.reflect.Method;
    1.37 -import java.net.MalformedURLException;
    1.38 -import org.omg.CORBA.portable.ValueBase;
    1.39 -import org.omg.CORBA.portable.IDLEntity;
    1.40 -
    1.41 -//d11638 files in the same package, therefore remove their reference
    1.42 -//import com.sun.corba.se.impl.util.JDKBridge;
    1.43 -//import com.sun.corba.se.impl.util.IdentityHashtable;
    1.44 -import com.sun.corba.se.impl.util.JDKBridge;
    1.45 -import com.sun.corba.se.impl.util.Utility;
    1.46 -import com.sun.corba.se.impl.util.PackagePrefixChecker;
    1.47 -import com.sun.corba.se.impl.util.IdentityHashtable;
    1.48 -
    1.49 -import javax.rmi.CORBA.Util;
    1.50 -
    1.51 -/**
    1.52 - * Because all methods in RepositoryId are static, we have
    1.53 - * to duplicate all of this code, freezing it in its 1.3.1
    1.54 - * form for backwards compatibility.
    1.55 - *
    1.56 - * For security reasons, we can't expose enough of
    1.57 - * io/ObjectStreamClass, so it has to be duplicated in
    1.58 - * orbutil.
    1.59 - */
    1.60 -public class RepositoryId_1_3_1 {
    1.61 -
    1.62 -    // Legal IDL Identifier characters (1 = legal). Note
    1.63 -    // that '.' (2E) is marked as legal even though it is
    1.64 -    // not legal in IDL. This allows us to treat a fully
    1.65 -    // qualified Java name with '.' package separators
    1.66 -    // uniformly, and is safe because that is the only
    1.67 -    // legal use of '.' in a Java name.
    1.68 -
    1.69 -    private static final byte[] IDL_IDENTIFIER_CHARS = {
    1.70 -
    1.71 -        // 0 1 2 3  4 5 6 7  8 9 a b  c d e f
    1.72 -        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
    1.73 -        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 10-1f
    1.74 -        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0, // 20-2f
    1.75 -        1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0, // 30-3f
    1.76 -        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 40-4f
    1.77 -        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1, // 50-5f
    1.78 -        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 60-6f
    1.79 -        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0, // 70-7f
    1.80 -        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 80-8f
    1.81 -        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 90-9f
    1.82 -        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // a0-af
    1.83 -        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // b0-bf
    1.84 -        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // c0-cf
    1.85 -        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // d0-df
    1.86 -        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // e0-ef
    1.87 -        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // f0-ff
    1.88 -    };
    1.89 -
    1.90 -
    1.91 -    private static final long serialVersionUID = 123456789L;
    1.92 -
    1.93 -    private static String defaultServerURL = null;
    1.94 -    private static boolean useCodebaseOnly = false;
    1.95 -
    1.96 -    static {
    1.97 -        if (defaultServerURL == null)
    1.98 -            defaultServerURL = (String)JDKBridge.getLocalCodebase();
    1.99 -        useCodebaseOnly = JDKBridge.useCodebaseOnly();
   1.100 -
   1.101 -    }
   1.102 -
   1.103 -    private static IdentityHashtable classToRepStr = new IdentityHashtable();
   1.104 -    private static IdentityHashtable classIDLToRepStr = new IdentityHashtable();
   1.105 -    private static IdentityHashtable classSeqToRepStr = new IdentityHashtable();
   1.106 -
   1.107 -    private static IdentityHashtable repStrToByteArray = new IdentityHashtable();
   1.108 -    private static Hashtable repStrToClass = new Hashtable();
   1.109 -
   1.110 -    private String repId = null;
   1.111 -    private boolean isSupportedFormat = true;
   1.112 -    private String typeString = null;
   1.113 -    private String versionString = null;
   1.114 -    private boolean isSequence = false;
   1.115 -    private boolean isRMIValueType = false;
   1.116 -    private boolean isIDLType = false;
   1.117 -    private String completeClassName = null;
   1.118 -    private String unqualifiedName = null;
   1.119 -    private String definedInId = null;
   1.120 -    private Class clazz = null;
   1.121 -    private String suid = null, actualSuid = null;
   1.122 -    private long suidLong = ObjectStreamClass_1_3_1.kDefaultUID, actualSuidLong = ObjectStreamClass_1_3_1.kDefaultUID;
   1.123 -
   1.124 -    // Repository ID fragments
   1.125 -    private static final String kSequenceKeyword = "seq";
   1.126 -    private static final String kValuePrefix = "RMI:";
   1.127 -    private static final String kIDLPrefix = "IDL:";
   1.128 -    private static final String kIDLNamePrefix = "omg.org/";
   1.129 -    private static final String kIDLClassnamePrefix = "org.omg.";
   1.130 -    private static final String kSequencePrefix = "[";
   1.131 -    private static final String kCORBAPrefix = "CORBA/";
   1.132 -    private static final String kArrayPrefix = kValuePrefix + kSequencePrefix + kCORBAPrefix;
   1.133 -    private static final int kValuePrefixLength = kValuePrefix.length();
   1.134 -    private static final int kIDLPrefixLength = kIDLPrefix.length();
   1.135 -    private static final int kSequencePrefixLength = kSequencePrefix.length();
   1.136 -    private static final String kInterfaceHashCode = ":0000000000000000";
   1.137 -    private static final String kInterfaceOnlyHashStr = "0000000000000000";
   1.138 -    private static final String kExternalizableHashStr = "0000000000000001";
   1.139 -
   1.140 -    // Value tag utility methods and constants
   1.141 -    public static final int kInitialValueTag= 0x7fffff00;
   1.142 -    public static final int kNoTypeInfo = 0;
   1.143 -    public static final int kSingleRepTypeInfo = 0x02;
   1.144 -    public static final int  kPartialListTypeInfo = 0x06;
   1.145 -    public static final int  kChunkedMask = 0x08;
   1.146 -    public static final int kPreComputed_StandardRMIUnchunked = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kSingleRepTypeInfo, false);
   1.147 -    public static final int kPreComputed_CodeBaseRMIUnchunked = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kSingleRepTypeInfo, false);
   1.148 -    public static final int kPreComputed_StandardRMIChunked = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kSingleRepTypeInfo, true);
   1.149 -    public static final int kPreComputed_CodeBaseRMIChunked = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kSingleRepTypeInfo, true);
   1.150 -
   1.151 -    public static final int kPreComputed_StandardRMIUnchunked_NoRep = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kNoTypeInfo, false);
   1.152 -    public static final int kPreComputed_CodeBaseRMIUnchunked_NoRep = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kNoTypeInfo, false);
   1.153 -    public static final int kPreComputed_StandardRMIChunked_NoRep = RepositoryId_1_3_1.computeValueTag(false, RepositoryId_1_3_1.kNoTypeInfo, true);
   1.154 -    public static final int kPreComputed_CodeBaseRMIChunked_NoRep = RepositoryId_1_3_1.computeValueTag(true, RepositoryId_1_3_1.kNoTypeInfo, true);
   1.155 -
   1.156 -    // Public, well known repository IDs
   1.157 -
   1.158 -    // _REVISIT_ : A table structure with a good search routine for all of this
   1.159 -    // would be more efficient and easier to maintain...
   1.160 -
   1.161 -    // String
   1.162 -    public static final String kWStringValueVersion = "1.0";
   1.163 -    public static final String kWStringValueHash = ":"+kWStringValueVersion;
   1.164 -    public static final String kWStringStubValue = "WStringValue";
   1.165 -    public static final String kWStringTypeStr = "omg.org/CORBA/"+kWStringStubValue;
   1.166 -    public static final String kWStringValueRepID = kIDLPrefix + kWStringTypeStr + kWStringValueHash;
   1.167 -
   1.168 -    // Any
   1.169 -    public static final String kAnyRepID = kIDLPrefix + "omg.org/CORBA/Any";
   1.170 -
   1.171 -    // Class
   1.172 -    // Anita4: convert to uppercase
   1.173 -    public static final String kClassDescValueHash = ":" +
   1.174 -       Long.toHexString(
   1.175 -       ObjectStreamClass_1_3_1.getActualSerialVersionUID(javax.rmi.CORBA.ClassDesc.class)).toUpperCase() + ":" +
   1.176 -      Long.toHexString(
   1.177 -       ObjectStreamClass_1_3_1.getSerialVersionUID(javax.rmi.CORBA.ClassDesc.class)).toUpperCase();
   1.178 -    public static final String kClassDescStubValue = "ClassDesc";
   1.179 -    public static final String kClassDescTypeStr = "javax.rmi.CORBA."+kClassDescStubValue;
   1.180 -    public static final String kClassDescValueRepID = kValuePrefix + kClassDescTypeStr + kClassDescValueHash;
   1.181 -
   1.182 -    // Object
   1.183 -    public static final String kObjectValueHash = ":1.0";
   1.184 -    public static final String kObjectStubValue = "Object";
   1.185 -
   1.186 -    // Sequence
   1.187 -    public static final String kSequenceValueHash = ":1.0";
   1.188 -    public static final String kPrimitiveSequenceValueHash = ":0000000000000000";
   1.189 -
   1.190 -    // Serializable
   1.191 -    public static final String kSerializableValueHash = ":1.0";
   1.192 -    public static final String kSerializableStubValue = "Serializable";
   1.193 -
   1.194 -    // Externalizable
   1.195 -    public static final String kExternalizableValueHash = ":1.0";
   1.196 -    public static final String kExternalizableStubValue = "Externalizable";
   1.197 -
   1.198 -    // Remote (The empty string is used for java.rmi.Remote)
   1.199 -    public static final String kRemoteValueHash = "";
   1.200 -    public static final String kRemoteStubValue = "";
   1.201 -    public static final String kRemoteTypeStr = "";
   1.202 -    public static final String kRemoteValueRepID = "";
   1.203 -
   1.204 -    private static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
   1.205 -
   1.206 -    static {
   1.207 -        kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
   1.208 -        kSpecialArrayTypeStrings.put("javax.rmi.CORBA.ClassDesc", new StringBuffer(java.lang.Class.class.getName()));
   1.209 -        kSpecialArrayTypeStrings.put("CORBA.Object", new StringBuffer(java.rmi.Remote.class.getName()));
   1.210 -
   1.211 -    }
   1.212 -
   1.213 -    private static final Hashtable kSpecialCasesRepIDs = new Hashtable();
   1.214 -
   1.215 -    static {
   1.216 -        kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
   1.217 -        kSpecialCasesRepIDs.put(java.lang.Class.class, kClassDescValueRepID);
   1.218 -        kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
   1.219 -    }
   1.220 -
   1.221 -    private static final Hashtable kSpecialCasesStubValues = new Hashtable();
   1.222 -
   1.223 -    static {
   1.224 -        kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
   1.225 -        kSpecialCasesStubValues.put(java.lang.Class.class, kClassDescStubValue);
   1.226 -        kSpecialCasesStubValues.put(java.lang.Object.class, kObjectStubValue);
   1.227 -        kSpecialCasesStubValues.put(java.io.Serializable.class, kSerializableStubValue);
   1.228 -        kSpecialCasesStubValues.put(java.io.Externalizable.class, kExternalizableStubValue);
   1.229 -        kSpecialCasesStubValues.put(java.rmi.Remote.class, kRemoteStubValue);
   1.230 -    }
   1.231 -
   1.232 -
   1.233 -    private static final Hashtable kSpecialCasesVersions = new Hashtable();
   1.234 -
   1.235 -    static {
   1.236 -        kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
   1.237 -        kSpecialCasesVersions.put(java.lang.Class.class, kClassDescValueHash);
   1.238 -        kSpecialCasesVersions.put(java.lang.Object.class, kObjectValueHash);
   1.239 -        kSpecialCasesVersions.put(java.io.Serializable.class, kSerializableValueHash);
   1.240 -        kSpecialCasesVersions.put(java.io.Externalizable.class, kExternalizableValueHash);
   1.241 -        kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
   1.242 -    }
   1.243 -
   1.244 -    private static final Hashtable kSpecialCasesClasses = new Hashtable();
   1.245 -
   1.246 -    static {
   1.247 -        kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
   1.248 -        kSpecialCasesClasses.put(kClassDescTypeStr, java.lang.Class.class);
   1.249 -        kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
   1.250 -
   1.251 -        kSpecialCasesClasses.put("org.omg.CORBA.WStringValue", java.lang.String.class);
   1.252 -        kSpecialCasesClasses.put("javax.rmi.CORBA.ClassDesc", java.lang.Class.class);
   1.253 -        //kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
   1.254 -    }
   1.255 -
   1.256 -    private static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
   1.257 -
   1.258 -    static {
   1.259 -        kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
   1.260 -        kSpecialCasesArrayPrefix.put(java.lang.Class.class, kValuePrefix + kSequencePrefix + "javax/rmi/CORBA/");
   1.261 -        kSpecialCasesArrayPrefix.put(java.lang.Object.class, kValuePrefix + kSequencePrefix + "java/lang/");
   1.262 -        kSpecialCasesArrayPrefix.put(java.io.Serializable.class, kValuePrefix + kSequencePrefix + "java/io/");
   1.263 -        kSpecialCasesArrayPrefix.put(java.io.Externalizable.class, kValuePrefix + kSequencePrefix + "java/io/");
   1.264 -        kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
   1.265 -    }
   1.266 -
   1.267 -    private static final Hashtable kSpecialPrimitives = new Hashtable();
   1.268 -
   1.269 -    static {
   1.270 -        kSpecialPrimitives.put("int","long");
   1.271 -        kSpecialPrimitives.put("long","longlong");
   1.272 -        kSpecialPrimitives.put("byte","octet");
   1.273 -    }
   1.274 -
   1.275 -    /**
   1.276 -     * Used to convert ascii to hex.
   1.277 -     */
   1.278 -    private static final byte ASCII_HEX[] =     {
   1.279 -        (byte)'0',
   1.280 -        (byte)'1',
   1.281 -        (byte)'2',
   1.282 -        (byte)'3',
   1.283 -        (byte)'4',
   1.284 -        (byte)'5',
   1.285 -        (byte)'6',
   1.286 -        (byte)'7',
   1.287 -        (byte)'8',
   1.288 -        (byte)'9',
   1.289 -        (byte)'A',
   1.290 -        (byte)'B',
   1.291 -        (byte)'C',
   1.292 -        (byte)'D',
   1.293 -        (byte)'E',
   1.294 -        (byte)'F',
   1.295 -    };
   1.296 -
   1.297 -
   1.298 -    // bug fix for 4328952; to eliminate possibility of overriding this
   1.299 -    // in a subclass.
   1.300 -    public static final RepositoryIdCache_1_3_1 cache = new RepositoryIdCache_1_3_1();
   1.301 -
   1.302 -    // Interface Rep ID Strings
   1.303 -    public static final String kjava_rmi_Remote = createForAnyType(java.rmi.Remote.class);
   1.304 -    public static final String korg_omg_CORBA_Object = createForAnyType(org.omg.CORBA.Object.class);
   1.305 -
   1.306 -    // Dummy arguments for getIdFromHelper method
   1.307 -    public static final Class kNoParamTypes[] ={};
   1.308 -    public static final Object kNoArgs[] = {};
   1.309 -
   1.310 -
   1.311 -    // To create a RepositoryID, use code similar to the following:
   1.312 -    // RepositoryId.cache.getId( id );
   1.313 -
   1.314 -    RepositoryId_1_3_1(){}
   1.315 -
   1.316 -    RepositoryId_1_3_1(String aRepId){
   1.317 -        init(aRepId);
   1.318 -    }
   1.319 -
   1.320 -    RepositoryId_1_3_1 init(String aRepId){
   1.321 -
   1.322 -        this.repId = aRepId;
   1.323 -
   1.324 -        // Special case for remote
   1.325 -        if (aRepId.length() == 0) {
   1.326 -            clazz = java.rmi.Remote.class;
   1.327 -            typeString = "";
   1.328 -            isRMIValueType = true;
   1.329 -            suid = kInterfaceOnlyHashStr;
   1.330 -            return this;
   1.331 -        }
   1.332 -        else if (aRepId.equals(kWStringValueRepID)) {
   1.333 -            clazz = java.lang.String.class;
   1.334 -            typeString = kWStringTypeStr;
   1.335 -            isIDLType = true;
   1.336 -            // fix where Attempting to obtain a FullValueDescription
   1.337 -            // for an RMI value type with a String field causes an exception.
   1.338 -            completeClassName = "java.lang.String";
   1.339 -            versionString = kWStringValueVersion;
   1.340 -            return this;
   1.341 -        }
   1.342 -        else {
   1.343 -
   1.344 -        String repId = convertFromISOLatin1(aRepId);
   1.345 -
   1.346 -        versionString = repId.substring(repId.indexOf(':', repId.indexOf(':')+1));
   1.347 -        if (repId.startsWith(kIDLPrefix)) {
   1.348 -            typeString =
   1.349 -                repId.substring(kIDLPrefixLength, repId.indexOf(':', kIDLPrefixLength));
   1.350 -            isIDLType = true;
   1.351 -            if (typeString.startsWith(kIDLNamePrefix))
   1.352 -                completeClassName = kIDLClassnamePrefix +
   1.353 -                    typeString.substring(kIDLNamePrefix.length()).replace('/','.');
   1.354 -            else completeClassName = typeString.replace('/','.');
   1.355 -
   1.356 -        }
   1.357 -        else if (repId.startsWith(kValuePrefix)) {
   1.358 -            typeString =
   1.359 -                repId.substring(kValuePrefixLength, repId.indexOf(':', kValuePrefixLength));
   1.360 -            isRMIValueType = true;
   1.361 -
   1.362 -            if (versionString.indexOf('.') == -1) {
   1.363 -                    actualSuid = versionString.substring(1);
   1.364 -                    suid = actualSuid;  // default if not explicitly specified
   1.365 -
   1.366 -                    if (actualSuid.indexOf(':') != -1){
   1.367 -                    // we have a declared hash also
   1.368 -                        int pos = actualSuid.indexOf(':')+1;
   1.369 -                        // actualSuid = suid.substring(pos);
   1.370 -                        // suid = suid.substring(0, pos-1);
   1.371 -                        suid = actualSuid.substring(pos);
   1.372 -                        actualSuid = actualSuid.substring(0, pos-1);
   1.373 -                }
   1.374 -
   1.375 -            }
   1.376 -            else {
   1.377 -                    // _REVISIT_ : Special case version failure ?
   1.378 -            }
   1.379 -        }
   1.380 -        else isSupportedFormat = false;
   1.381 -
   1.382 -        if (typeString.startsWith(kSequencePrefix)) {
   1.383 -            isSequence = true;
   1.384 -        }
   1.385 -
   1.386 -
   1.387 -        return this;
   1.388 -    }
   1.389 -    }
   1.390 -
   1.391 -    public final String getUnqualifiedName() {
   1.392 -        if (unqualifiedName == null){
   1.393 -            String className = getClassName();
   1.394 -            int index = className.lastIndexOf('.');
   1.395 -            if (index == -1){
   1.396 -                unqualifiedName = className;
   1.397 -                definedInId = "IDL::1.0";
   1.398 -            }
   1.399 -            else {
   1.400 -                unqualifiedName = className.substring(index);
   1.401 -                definedInId = "IDL:" + className.substring(0, index).replace('.','/') + ":1.0";
   1.402 -            }
   1.403 -        }
   1.404 -
   1.405 -        return unqualifiedName;
   1.406 -    }
   1.407 -
   1.408 -    public final String getDefinedInId() {
   1.409 -        if (definedInId == null){
   1.410 -            getUnqualifiedName();
   1.411 -        }
   1.412 -
   1.413 -        return definedInId;
   1.414 -    }
   1.415 -
   1.416 -    public final String getTypeString() {
   1.417 -        return typeString;
   1.418 -    }
   1.419 -
   1.420 -    public final String getVersionString() {
   1.421 -        return versionString;
   1.422 -    }
   1.423 -
   1.424 -    public final String getSerialVersionUID() {
   1.425 -        return suid;
   1.426 -    }
   1.427 -
   1.428 -    public final String getActualSerialVersionUID() {
   1.429 -        return actualSuid;
   1.430 -    }
   1.431 -    public final long getSerialVersionUIDAsLong() {
   1.432 -        return suidLong;
   1.433 -    }
   1.434 -
   1.435 -    public final long getActualSerialVersionUIDAsLong() {
   1.436 -        return actualSuidLong;
   1.437 -    }
   1.438 -
   1.439 -    public final boolean isRMIValueType() {
   1.440 -        return isRMIValueType;
   1.441 -    }
   1.442 -
   1.443 -    public final boolean isIDLType() {
   1.444 -        return isIDLType;
   1.445 -    }
   1.446 -
   1.447 -    public final String getRepositoryId() {
   1.448 -        return repId;
   1.449 -    }
   1.450 -
   1.451 -    public static byte[] getByteArray(String repStr) {
   1.452 -        synchronized (repStrToByteArray){
   1.453 -            return (byte[]) repStrToByteArray.get(repStr);
   1.454 -        }
   1.455 -    }
   1.456 -
   1.457 -    public static void setByteArray(String repStr, byte[] repStrBytes) {
   1.458 -        synchronized (repStrToByteArray){
   1.459 -            repStrToByteArray.put(repStr, repStrBytes);
   1.460 -        }
   1.461 -    }
   1.462 -
   1.463 -    public final boolean isSequence() {
   1.464 -        return isSequence;
   1.465 -    }
   1.466 -
   1.467 -    public final boolean isSupportedFormat() {
   1.468 -        return isSupportedFormat;
   1.469 -    }
   1.470 -
   1.471 -
   1.472 -    // This method will return the classname from the typestring OR if the classname turns out to be
   1.473 -    // a special class "pseudo" name, then the matching real classname is returned.
   1.474 -    public final String getClassName() {
   1.475 -
   1.476 -        if (isRMIValueType)
   1.477 -            return typeString;
   1.478 -        else if (isIDLType)
   1.479 -            return completeClassName;
   1.480 -        else return null;
   1.481 -
   1.482 -    }
   1.483 -
   1.484 -    // This method calls getClazzFromType() and falls back to the repStrToClass
   1.485 -    // cache if no class was found.  It's used where any class matching the
   1.486 -    // given repid is an acceptable result.
   1.487 -    public final Class getAnyClassFromType() throws ClassNotFoundException {
   1.488 -        try {
   1.489 -            return getClassFromType();
   1.490 -        } catch (ClassNotFoundException cnfe) {
   1.491 -            Class clz = (Class)repStrToClass.get(repId);
   1.492 -            if (clz != null)
   1.493 -                return clz;
   1.494 -            else
   1.495 -                throw cnfe;
   1.496 -        }
   1.497 -    }
   1.498 -
   1.499 -    public final Class getClassFromType()
   1.500 -        throws ClassNotFoundException {
   1.501 -        if (clazz != null)
   1.502 -            return clazz;
   1.503 -
   1.504 -        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
   1.505 -
   1.506 -        if (specialCase != null){
   1.507 -            clazz = specialCase;
   1.508 -            return specialCase;
   1.509 -        }
   1.510 -        else
   1.511 -            {
   1.512 -                try{
   1.513 -                    return Util.loadClass(getClassName(), null, null);
   1.514 -                }
   1.515 -                catch(ClassNotFoundException cnfe){
   1.516 -                    if (defaultServerURL != null) {
   1.517 -                        try{
   1.518 -                            return getClassFromType(defaultServerURL);
   1.519 -                        }
   1.520 -                        catch(MalformedURLException mue){
   1.521 -                            throw cnfe;
   1.522 -                        }
   1.523 -                    }
   1.524 -                    else throw cnfe;
   1.525 -                }
   1.526 -            }
   1.527 -
   1.528 -    }
   1.529 -
   1.530 -    public final Class getClassFromType(Class expectedType, String codebase)
   1.531 -        throws ClassNotFoundException {
   1.532 -        if (clazz != null)
   1.533 -            return clazz;
   1.534 -
   1.535 -        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
   1.536 -
   1.537 -        if (specialCase != null){
   1.538 -            clazz = specialCase;
   1.539 -            return specialCase;
   1.540 -        } else {
   1.541 -            ClassLoader expectedTypeClassLoader = (expectedType == null ? null : expectedType.getClassLoader());
   1.542 -            return loadClassOfType(getClassName(),
   1.543 -                                   codebase,
   1.544 -                                   expectedTypeClassLoader,
   1.545 -                                   expectedType,
   1.546 -                                   expectedTypeClassLoader);
   1.547 -        }
   1.548 -
   1.549 -    }
   1.550 -
   1.551 -    public final Class getClassFromType(String url)
   1.552 -        throws ClassNotFoundException, MalformedURLException {
   1.553 -        return Util.loadClass(getClassName(), url, null);
   1.554 -    }
   1.555 -
   1.556 -    public final String toString() {
   1.557 -        return repId;
   1.558 -    }
   1.559 -
   1.560 -    /**
   1.561 -     * Checks to see if the FullValueDescription should be retrieved.
   1.562 -     * @exception Throws IOException if suids do not match or if the repositoryID
   1.563 -     * is not an RMIValueType
   1.564 -     */
   1.565 -    public static boolean useFullValueDescription(Class clazz, String repositoryID)
   1.566 -        throws IOException{
   1.567 -
   1.568 -        String clazzRepIDStr = createForAnyType(clazz);
   1.569 -
   1.570 -        if (clazzRepIDStr.equals(repositoryID))
   1.571 -            return false;
   1.572 -
   1.573 -        RepositoryId_1_3_1 targetRepid;
   1.574 -        RepositoryId_1_3_1 clazzRepid;
   1.575 -
   1.576 -        synchronized(cache) {
   1.577 -        // to avoid race condition where multiple threads could be
   1.578 -        // accessing this method, and their access to the cache may
   1.579 -        // be interleaved giving unexpected results
   1.580 -
   1.581 -            targetRepid = cache.getId(repositoryID);
   1.582 -            clazzRepid = cache.getId(clazzRepIDStr);
   1.583 -        }
   1.584 -        //ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
   1.585 -
   1.586 -        if ((targetRepid.isRMIValueType()) && (clazzRepid.isRMIValueType())){
   1.587 -            if (!targetRepid.getSerialVersionUID().equals(clazzRepid.getSerialVersionUID())) {
   1.588 -
   1.589 -                String mssg = "Mismatched serialization UIDs : Source (Rep. ID" +
   1.590 -                    clazzRepid + ") = " +
   1.591 -                    clazzRepid.getSerialVersionUID() + " whereas Target (Rep. ID " + repositoryID +
   1.592 -                    ") = " + targetRepid.getSerialVersionUID();
   1.593 -                                //com.sun.corba.se.impl.io.ValueUtility.log("RepositoryId",mssg);
   1.594 -                throw new IOException(mssg);
   1.595 -        }
   1.596 -            else {
   1.597 -                return true;
   1.598 -            }
   1.599 -        }
   1.600 -        else {
   1.601 -
   1.602 -            throw new IOException("The repository ID is not of an RMI value type (Expected ID = " + clazzRepIDStr + "; Received ID = " + repositoryID +")");
   1.603 -    }
   1.604 -    }
   1.605 -
   1.606 -    private static String createHashString(java.io.Serializable ser) {
   1.607 -
   1.608 -        return createHashString(ser.getClass());
   1.609 -    }
   1.610 -
   1.611 -    private static String createHashString(java.lang.Class clazz) {
   1.612 -
   1.613 -        if (clazz.isInterface() || !java.io.Serializable.class.isAssignableFrom(clazz))
   1.614 -            return kInterfaceHashCode;
   1.615 -
   1.616 -        //ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
   1.617 -
   1.618 -        long actualLong = ObjectStreamClass_1_3_1.getActualSerialVersionUID(clazz);
   1.619 -        String hash = null;
   1.620 -        if (actualLong == 0)
   1.621 -            hash = kInterfaceOnlyHashStr;
   1.622 -        else if (actualLong == 1)
   1.623 -            hash = kExternalizableHashStr;
   1.624 -        else
   1.625 -            hash = Long.toHexString(actualLong).toUpperCase();
   1.626 -        while(hash.length() < 16){
   1.627 -            hash = "0" + hash;
   1.628 -        }
   1.629 -
   1.630 -        long declaredLong = ObjectStreamClass_1_3_1.getSerialVersionUID(clazz);
   1.631 -        String declared = null;
   1.632 -        if (declaredLong == 0)
   1.633 -            declared = kInterfaceOnlyHashStr;
   1.634 -        else if (declaredLong == 1)
   1.635 -            declared = kExternalizableHashStr;
   1.636 -        else
   1.637 -            declared = Long.toHexString(declaredLong).toUpperCase();
   1.638 -        while (declared.length() < 16){
   1.639 -            declared = "0" + declared;
   1.640 -    }
   1.641 -        hash = hash + ":" + declared;
   1.642 -
   1.643 -        return ":" + hash;
   1.644 -    }
   1.645 -
   1.646 -    /**
   1.647 -     * Creates a repository ID for a sequence.  This is for expert users only as
   1.648 -     * this method assumes the object passed is an array.  If passed an object
   1.649 -     * that is not an array, it will produce a rep id for a sequence of zero
   1.650 -     * length.  This would be an error.
   1.651 -     * @param ser The Java object to create a repository ID for
   1.652 -     **/
   1.653 -    public static String createSequenceRepID(java.lang.Object ser){
   1.654 -        return createSequenceRepID(ser.getClass());
   1.655 -    }
   1.656 -
   1.657 -    /**
   1.658 -     * Creates a repository ID for a sequence.  This is for expert users only as
   1.659 -     * this method assumes the object passed is an array.  If passed an object
   1.660 -     * that is not an array, it will produce a malformed rep id.
   1.661 -     * @param clazz The Java class to create a repository ID for
   1.662 -     **/
   1.663 -    public static String createSequenceRepID(java.lang.Class clazz){
   1.664 -        synchronized (classSeqToRepStr){
   1.665 -
   1.666 -        String repid = (String)classSeqToRepStr.get(clazz);
   1.667 -        if (repid != null)
   1.668 -            return repid;
   1.669 -
   1.670 -        Class originalClazz = clazz;
   1.671 -
   1.672 -        Class type = null;
   1.673 -        int numOfDims = 0;
   1.674 -
   1.675 -        while ((type = clazz.getComponentType()) != null) {
   1.676 -            numOfDims++;
   1.677 -            clazz = type;
   1.678 -        }
   1.679 -
   1.680 -        if (clazz.isPrimitive())
   1.681 -            repid = kValuePrefix + originalClazz.getName() + kPrimitiveSequenceValueHash;
   1.682 -        else {
   1.683 -            StringBuffer buf = new StringBuffer();
   1.684 -            buf.append(kValuePrefix);
   1.685 -            while(numOfDims-- > 0) {
   1.686 -                buf.append("[");
   1.687 -            }
   1.688 -            buf.append("L");
   1.689 -            buf.append(convertToISOLatin1(clazz.getName()));
   1.690 -            buf.append(";");
   1.691 -            buf.append(createHashString(clazz));
   1.692 -            repid = buf.toString();
   1.693 -        }
   1.694 -        classSeqToRepStr.put(originalClazz,repid);
   1.695 -        return repid;
   1.696 -        }
   1.697 -
   1.698 -    }
   1.699 -
   1.700 -
   1.701 -    public static String createForSpecialCase(java.lang.Class clazz){
   1.702 -        if (clazz.isArray()){
   1.703 -            return createSequenceRepID(clazz);
   1.704 -        }
   1.705 -        else {
   1.706 -            return (String)kSpecialCasesRepIDs.get(clazz);
   1.707 -        }
   1.708 -    }
   1.709 -
   1.710 -    public static String createForSpecialCase(java.io.Serializable ser){
   1.711 -        Class clazz = ser.getClass();
   1.712 -        if (clazz.isArray()){
   1.713 -            return createSequenceRepID(ser);
   1.714 -        }
   1.715 -        else
   1.716 -            return createForSpecialCase(clazz);
   1.717 -    }
   1.718 -
   1.719 -    /**
   1.720 -     * Creates a repository ID for a normal Java Type.
   1.721 -     * @param ser The Java object to create a repository ID for
   1.722 -     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
   1.723 -     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
   1.724 -     **/
   1.725 -    public static String createForJavaType(java.io.Serializable ser)
   1.726 -        throws com.sun.corba.se.impl.io.TypeMismatchException
   1.727 -    {
   1.728 -        synchronized (classToRepStr) {
   1.729 -        String repid = createForSpecialCase(ser);
   1.730 -        if (repid != null)
   1.731 -            return repid;
   1.732 -        Class clazz = ser.getClass();
   1.733 -        repid = (String)classToRepStr.get(clazz);
   1.734 -
   1.735 -        if (repid != null)
   1.736 -            return repid;
   1.737 -
   1.738 -        repid = kValuePrefix + convertToISOLatin1(clazz.getName()) +
   1.739 -            createHashString(clazz);
   1.740 -
   1.741 -        classToRepStr.put(clazz, repid);
   1.742 -            repStrToClass.put(repid, clazz);
   1.743 -        return repid;
   1.744 -    }
   1.745 -    }
   1.746 -
   1.747 -    /**
   1.748 -     * Creates a repository ID for a normal Java Type.
   1.749 -     * @param clz The Java class to create a repository ID for
   1.750 -     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
   1.751 -     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
   1.752 -     **/
   1.753 -    public static String createForJavaType(Class clz)
   1.754 -        throws com.sun.corba.se.impl.io.TypeMismatchException
   1.755 -    {
   1.756 -        synchronized (classToRepStr){
   1.757 -        String repid = createForSpecialCase(clz);
   1.758 -        if (repid != null)
   1.759 -            return repid;
   1.760 -
   1.761 -        repid = (String)classToRepStr.get(clz);
   1.762 -        if (repid != null)
   1.763 -            return repid;
   1.764 -
   1.765 -        repid = kValuePrefix + convertToISOLatin1(clz.getName()) +
   1.766 -            createHashString(clz);
   1.767 -
   1.768 -        classToRepStr.put(clz, repid);
   1.769 -            repStrToClass.put(repid, clz);
   1.770 -        return repid;
   1.771 -    }
   1.772 -    }
   1.773 -
   1.774 -    /**
   1.775 -     * Creates a repository ID for an IDL Java Type.
   1.776 -     * @param ser The IDL Value object to create a repository ID for
   1.777 -     * @param major The major version number
   1.778 -     * @param minor The minor version number
   1.779 -     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser does not implement the
   1.780 -     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
   1.781 -     **/
   1.782 -    public static String createForIDLType(Class ser, int major, int minor)
   1.783 -        throws com.sun.corba.se.impl.io.TypeMismatchException
   1.784 -    {
   1.785 -        synchronized (classIDLToRepStr){
   1.786 -        String repid = (String)classIDLToRepStr.get(ser);
   1.787 -        if (repid != null)
   1.788 -            return repid;
   1.789 -
   1.790 -        repid = kIDLPrefix + convertToISOLatin1(ser.getName()).replace('.','/') +
   1.791 -            ":" + major + "." + minor;
   1.792 -        classIDLToRepStr.put(ser, repid);
   1.793 -        return repid;
   1.794 -    }
   1.795 -    }
   1.796 -
   1.797 -    private static String getIdFromHelper(Class clazz){
   1.798 -        try {
   1.799 -            Class helperClazz = Utility.loadClassForClass(clazz.getName()+"Helper", null,
   1.800 -                                    clazz.getClassLoader(), clazz, clazz.getClassLoader());
   1.801 -            Method idMethod = helperClazz.getDeclaredMethod("id", kNoParamTypes);
   1.802 -            return (String)idMethod.invoke(null, kNoArgs);
   1.803 -        }
   1.804 -        catch(java.lang.ClassNotFoundException cnfe)
   1.805 -            {
   1.806 -                throw new org.omg.CORBA.MARSHAL(cnfe.toString());
   1.807 -            }
   1.808 -        catch(java.lang.NoSuchMethodException nsme)
   1.809 -            {
   1.810 -                throw new org.omg.CORBA.MARSHAL(nsme.toString());
   1.811 -            }
   1.812 -        catch(java.lang.reflect.InvocationTargetException ite)
   1.813 -            {
   1.814 -                throw new org.omg.CORBA.MARSHAL(ite.toString());
   1.815 -            }
   1.816 -        catch(java.lang.IllegalAccessException iae)
   1.817 -            {
   1.818 -                throw new org.omg.CORBA.MARSHAL(iae.toString());
   1.819 -    }
   1.820 -    }
   1.821 -
   1.822 -    /**
   1.823 -     * Createa a repository ID for the type if it is either a java type
   1.824 -     * or an IDL type.
   1.825 -     * @param type The type to create rep. id for
   1.826 -     * @return The rep. id.
   1.827 -     **/
   1.828 -    public static String createForAnyType(Class type) {
   1.829 -        try{
   1.830 -            if (type.isArray())
   1.831 -                return createSequenceRepID(type);
   1.832 -            else if (IDLEntity.class.isAssignableFrom(type))
   1.833 -                {
   1.834 -                    try{
   1.835 -                        return getIdFromHelper(type);
   1.836 -                    }
   1.837 -                    catch(Throwable t) {
   1.838 -                        return createForIDLType(type, 1, 0);
   1.839 -                    }
   1.840 -                }
   1.841 -            else return createForJavaType(type);
   1.842 -        }
   1.843 -        catch(com.sun.corba.se.impl.io.TypeMismatchException e){
   1.844 -            return null;
   1.845 -        }
   1.846 -
   1.847 -    }
   1.848 -
   1.849 -    public static boolean isAbstractBase(Class clazz) {
   1.850 -        return (clazz.isInterface() &&
   1.851 -                IDLEntity.class.isAssignableFrom(clazz) &&
   1.852 -                (!ValueBase.class.isAssignableFrom(clazz)) &&
   1.853 -                (!org.omg.CORBA.Object.class.isAssignableFrom(clazz)));
   1.854 -
   1.855 -    }
   1.856 -
   1.857 -    public static boolean isAnyRequired(Class clazz) {
   1.858 -        return ((clazz == java.lang.Object.class) ||
   1.859 -                (clazz == java.io.Serializable.class) ||
   1.860 -                (clazz == java.io.Externalizable.class));
   1.861 -    }
   1.862 -
   1.863 -    public static long fromHex(String hexNumber) {
   1.864 -        if (hexNumber.startsWith("0x"))
   1.865 -            return Long.valueOf(hexNumber.substring(2), 16).longValue();
   1.866 -        else return Long.valueOf(hexNumber, 16).longValue();
   1.867 -    }
   1.868 -
   1.869 -    /**
   1.870 -     * Convert strings with illegal IDL identifier characters.
   1.871 -     * <p>
   1.872 -     * Section 5.5.7 of OBV spec.
   1.873 -     */
   1.874 -    private static String convertToISOLatin1 (String name) {
   1.875 -
   1.876 -        int length = name.length();
   1.877 -        if (length == 0) {
   1.878 -            return name;
   1.879 -        }
   1.880 -        StringBuffer buffer = null;
   1.881 -
   1.882 -        for (int i = 0; i < length; i++) {
   1.883 -
   1.884 -            char c = name.charAt(i);
   1.885 -
   1.886 -            if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) {
   1.887 -
   1.888 -                // We gotta convert. Have we already started?
   1.889 -
   1.890 -                if (buffer == null) {
   1.891 -
   1.892 -                    // No, so get set up...
   1.893 -
   1.894 -                    buffer = new StringBuffer(name.substring(0,i));
   1.895 -                }
   1.896 -
   1.897 -                // Convert the character into the IDL escape syntax...
   1.898 -                buffer.append(
   1.899 -                              "\\U" +
   1.900 -                              (char)ASCII_HEX[(c & 0xF000) >>> 12] +
   1.901 -                              (char)ASCII_HEX[(c & 0x0F00) >>> 8] +
   1.902 -                              (char)ASCII_HEX[(c & 0x00F0) >>> 4] +
   1.903 -                              (char)ASCII_HEX[(c & 0x000F)]);
   1.904 -
   1.905 -            } else {
   1.906 -                if (buffer != null) {
   1.907 -                    buffer.append(c);
   1.908 -                }
   1.909 -            }
   1.910 -        }
   1.911 -
   1.912 -        if (buffer != null) {
   1.913 -            name = buffer.toString();
   1.914 -        }
   1.915 -
   1.916 -        return name;
   1.917 -    }
   1.918 -
   1.919 -    /**
   1.920 -     * Convert strings with ISO Latin 1 escape sequences back to original strings.
   1.921 -     * <p>
   1.922 -     * Section 5.5.7 of OBV spec.
   1.923 -     */
   1.924 -    private static String convertFromISOLatin1 (String name) {
   1.925 -
   1.926 -        int index = -1;
   1.927 -        StringBuffer buf = new StringBuffer(name);
   1.928 -
   1.929 -        while ((index = buf.toString().indexOf("\\U")) != -1){
   1.930 -            String str = "0000" + buf.toString().substring(index+2, index+6);
   1.931 -
   1.932 -            // Convert Hexadecimal
   1.933 -            byte[] buffer = new byte[(str.length() - 4) / 2];
   1.934 -            for (int i=4, j=0; i < str.length(); i +=2, j++) {
   1.935 -                buffer[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << 4) & 0xF0);
   1.936 -                buffer[j] |= (byte)((ORBUtility.hexOf(str.charAt(i+1)) << 0) & 0x0F);
   1.937 -            }
   1.938 -            buf = new StringBuffer(delete(buf.toString(), index, index+6));
   1.939 -            buf.insert(index, (char)buffer[1]);
   1.940 -        }
   1.941 -
   1.942 -        return buf.toString();
   1.943 -
   1.944 -
   1.945 -    }
   1.946 -
   1.947 -    private static String delete(String str, int from, int to)
   1.948 -    {
   1.949 -        return str.substring(0, from) + str.substring(to, str.length());
   1.950 -    }
   1.951 -
   1.952 -    private static String replace(String target, String arg, String source)
   1.953 -    {
   1.954 -        int i = 0;
   1.955 -        i = target.indexOf(arg);
   1.956 -
   1.957 -        while(i != -1)
   1.958 -            {
   1.959 -                String left = target.substring(0, i);
   1.960 -                String right = target.substring(i+arg.length());
   1.961 -                target = new String(left+source+right);
   1.962 -                i = target.indexOf(arg);
   1.963 -            }
   1.964 -        return target;
   1.965 -    }
   1.966 -
   1.967 -    public static int computeValueTag(boolean codeBasePresent, int typeInfo, boolean chunkedEncoding){
   1.968 -        int value_tag = kInitialValueTag;
   1.969 -
   1.970 -        if (codeBasePresent)
   1.971 -            value_tag = value_tag | 0x00000001;
   1.972 -
   1.973 -        value_tag = value_tag | typeInfo;
   1.974 -
   1.975 -        if (chunkedEncoding)
   1.976 -            value_tag = value_tag | kChunkedMask;
   1.977 -
   1.978 -        return value_tag;
   1.979 -    }
   1.980 -
   1.981 -    public static boolean isCodeBasePresent(int value_tag){
   1.982 -        return ((value_tag & 0x00000001) == 1);
   1.983 -    }
   1.984 -
   1.985 -    public static int getTypeInfo(int value_tag){
   1.986 -        return (value_tag & 0x00000006);
   1.987 -    }
   1.988 -
   1.989 -    public static boolean isChunkedEncoding(int value_tag){
   1.990 -        return ((value_tag & kChunkedMask) != 0);
   1.991 -    }
   1.992 -
   1.993 -    public static String getServerURL(){
   1.994 -        return defaultServerURL;
   1.995 -    }
   1.996 -
   1.997 -    /*
   1.998 -     * Load a class and check that it is assignable to a given type.
   1.999 -     * @param className the class name.
  1.1000 -     * @param remoteCodebase the codebase to use. May be null.
  1.1001 -     * @param loader the class loader of last resort. May be null.
  1.1002 -     * @param expectedType the expected type. May be null.
  1.1003 -     * @return the loaded class.
  1.1004 -     */
  1.1005 -    private Class loadClassOfType (String className,
  1.1006 -                                  String remoteCodebase,
  1.1007 -                                  ClassLoader loader,
  1.1008 -                                  Class expectedType,
  1.1009 -                                  ClassLoader expectedTypeClassLoader)
  1.1010 -        throws ClassNotFoundException {
  1.1011 -
  1.1012 -        Class loadedClass = null;
  1.1013 -
  1.1014 -        try {
  1.1015 -            //Sequence finding of the stubs according to spec
  1.1016 -            try{
  1.1017 -                //If-else is put here for speed up of J2EE.
  1.1018 -                //According to the OMG spec, the if clause is not dead code.
  1.1019 -                //It can occur if some compiler has allowed generation
  1.1020 -                //into org.omg.stub hierarchy for non-offending
  1.1021 -                //classes. This will encourage people to
  1.1022 -                //produce non-offending class stubs in their own hierarchy.
  1.1023 -                if(!PackagePrefixChecker
  1.1024 -                   .hasOffendingPrefix(PackagePrefixChecker
  1.1025 -                                       .withoutPackagePrefix(className))){
  1.1026 -                    loadedClass = Util.loadClass
  1.1027 -                        (PackagePrefixChecker.withoutPackagePrefix(className),
  1.1028 -                         remoteCodebase,
  1.1029 -                         loader);
  1.1030 -                } else {
  1.1031 -                    loadedClass = Util.loadClass
  1.1032 -                        (className,
  1.1033 -                         remoteCodebase,
  1.1034 -                         loader);
  1.1035 -                }
  1.1036 -            } catch (ClassNotFoundException cnfe) {
  1.1037 -                loadedClass = Util.loadClass
  1.1038 -                    (className,
  1.1039 -                     remoteCodebase,
  1.1040 -                     loader);
  1.1041 -            }
  1.1042 -            if (expectedType == null)
  1.1043 -                return loadedClass;
  1.1044 -        } catch (ClassNotFoundException cnfe) {
  1.1045 -            if (expectedType == null)
  1.1046 -                throw cnfe;
  1.1047 -        }
  1.1048 -
  1.1049 -        // If no class was not loaded, or if the loaded class is not of the
  1.1050 -        // correct type, make a further attempt to load the correct class
  1.1051 -        // using the classloader of the expected type.
  1.1052 -        // _REVISIT_ Is this step necessary, or should the Util,loadClass
  1.1053 -        // algorithm always produce a valid class if the setup is correct?
  1.1054 -        // Does the OMG standard algorithm need to be changed to include
  1.1055 -        // this step?
  1.1056 -        if (loadedClass == null || !expectedType.isAssignableFrom(loadedClass)) {
  1.1057 -            if (expectedType.getClassLoader() != expectedTypeClassLoader)
  1.1058 -                throw new IllegalArgumentException("expectedTypeClassLoader not class loader of expectedType.");
  1.1059 -
  1.1060 -            if (expectedTypeClassLoader != null)
  1.1061 -                loadedClass = expectedTypeClassLoader.loadClass(className);
  1.1062 -            else
  1.1063 -                loadedClass = Class.forName(className);
  1.1064 -        }
  1.1065 -
  1.1066 -        return loadedClass;
  1.1067 -    }
  1.1068 -}

mercurial