📄 repositoryid_1_3_1.java
字号:
} } else { // _REVISIT_ : Special case version failure ? } } else isSupportedFormat = false; if (typeString.startsWith(kSequencePrefix)) { isSequence = true; } return this; } } public final String getUnqualifiedName() { if (unqualifiedName == null){ String className = getClassName(); int index = className.lastIndexOf('.'); if (index == -1){ unqualifiedName = className; definedInId = "IDL::1.0"; } else { unqualifiedName = className.substring(index); definedInId = "IDL:" + className.substring(0, index).replace('.','/') + ":1.0"; } } return unqualifiedName; } public final String getDefinedInId() { if (definedInId == null){ getUnqualifiedName(); } return definedInId; } public final String getTypeString() { return typeString; } public final String getVersionString() { return versionString; } public final String getSerialVersionUID() { return suid; } public final String getActualSerialVersionUID() { return actualSuid; } public final long getSerialVersionUIDAsLong() { return suidLong; } public final long getActualSerialVersionUIDAsLong() { return actualSuidLong; } public final boolean isRMIValueType() { return isRMIValueType; } public final boolean isIDLType() { return isIDLType; } public final String getRepositoryId() { return repId; } public static byte[] getByteArray(String repStr) { synchronized (repStrToByteArray){ return (byte[]) repStrToByteArray.get(repStr); } } public static void setByteArray(String repStr, byte[] repStrBytes) { synchronized (repStrToByteArray){ repStrToByteArray.put(repStr, repStrBytes); } } public final boolean isSequence() { return isSequence; } public final boolean isSupportedFormat() { return isSupportedFormat; } // This method will return the classname from the typestring OR if the classname turns out to be // a special class "pseudo" name, then the matching real classname is returned. public final String getClassName() { if (isRMIValueType) return typeString; else if (isIDLType) return completeClassName; else return null; } // This method calls getClazzFromType() and falls back to the repStrToClass // cache if no class was found. It's used where any class matching the // given repid is an acceptable result. public final Class getAnyClassFromType() throws ClassNotFoundException { try { return getClassFromType(); } catch (ClassNotFoundException cnfe) { Class clz = (Class)repStrToClass.get(repId); if (clz != null) return clz; else throw cnfe; } } public final Class getClassFromType() throws ClassNotFoundException { if (clazz != null) return clazz; Class specialCase = (Class)kSpecialCasesClasses.get(getClassName()); if (specialCase != null){ clazz = specialCase; return specialCase; } else { try{ return Util.loadClass(getClassName(), null, null); } catch(ClassNotFoundException cnfe){ if (defaultServerURL != null) { try{ return getClassFromType(defaultServerURL); } catch(MalformedURLException mue){ throw cnfe; } } else throw cnfe; } } } public final Class getClassFromType(Class expectedType, String codebase) throws ClassNotFoundException { if (clazz != null) return clazz; Class specialCase = (Class)kSpecialCasesClasses.get(getClassName()); if (specialCase != null){ clazz = specialCase; return specialCase; } else { ClassLoader expectedTypeClassLoader = (expectedType == null ? null : expectedType.getClassLoader()); return loadClassOfType(getClassName(), codebase, expectedTypeClassLoader, expectedType, expectedTypeClassLoader); } } public final Class getClassFromType(String url) throws ClassNotFoundException, MalformedURLException { return Util.loadClass(getClassName(), url, null); } public final String toString() { return repId; } /** * Checks to see if the FullValueDescription should be retrieved. * @exception Throws IOException if suids do not match or if the repositoryID * is not an RMIValueType */ public static boolean useFullValueDescription(Class clazz, String repositoryID) throws IOException{ String clazzRepIDStr = createForAnyType(clazz); if (clazzRepIDStr.equals(repositoryID)) return false; RepositoryId_1_3_1 targetRepid; RepositoryId_1_3_1 clazzRepid; synchronized(cache) { // to avoid race condition where multiple threads could be // accessing this method, and their access to the cache may // be interleaved giving unexpected results targetRepid = cache.getId(repositoryID); clazzRepid = cache.getId(clazzRepIDStr); } //ObjectStreamClass osc = ObjectStreamClass.lookup(clazz); if ((targetRepid.isRMIValueType()) && (clazzRepid.isRMIValueType())){ if (!targetRepid.getSerialVersionUID().equals(clazzRepid.getSerialVersionUID())) { String mssg = "Mismatched serialization UIDs : Source (Rep. ID" + clazzRepid + ") = " + clazzRepid.getSerialVersionUID() + " whereas Target (Rep. ID " + repositoryID + ") = " + targetRepid.getSerialVersionUID(); //com.sun.corba.se.internal.io.ValueUtility.log("RepositoryId",mssg); throw new IOException(mssg); } else { return true; } } else { throw new IOException("The repository ID is not of an RMI value type (Expected ID = " + clazzRepIDStr + "; Received ID = " + repositoryID +")"); } } private static String createHashString(java.io.Serializable ser) { return createHashString(ser.getClass()); } private static String createHashString(java.lang.Class clazz) { if (clazz.isInterface() || !java.io.Serializable.class.isAssignableFrom(clazz)) return kInterfaceHashCode; //ObjectStreamClass osc = ObjectStreamClass.lookup(clazz); long actualLong = ObjectStreamClass_1_3_1.getActualSerialVersionUID(clazz); String hash = null; if (actualLong == 0) hash = kInterfaceOnlyHashStr; else if (actualLong == 1) hash = kExternalizableHashStr; else hash = Long.toHexString(actualLong).toUpperCase(); while(hash.length() < 16){ hash = "0" + hash; } long declaredLong = ObjectStreamClass_1_3_1.getSerialVersionUID(clazz); String declared = null; if (declaredLong == 0) declared = kInterfaceOnlyHashStr; else if (declaredLong == 1) declared = kExternalizableHashStr; else declared = Long.toHexString(declaredLong).toUpperCase(); while (declared.length() < 16){ declared = "0" + declared; } hash = hash + ":" + declared; return ":" + hash; } /** * Creates a repository ID for a sequence. This is for expert users only as * this method assumes the object passed is an array. If passed an object * that is not an array, it will produce a rep id for a sequence of zero * length. This would be an error. * @param ser The Java object to create a repository ID for **/ public static String createSequenceRepID(java.lang.Object ser){ return createSequenceRepID(ser.getClass()); } /** * Creates a repository ID for a sequence. This is for expert users only as * this method assumes the object passed is an array. If passed an object * that is not an array, it will produce a malformed rep id. * @param clazz The Java class to create a repository ID for **/ public static String createSequenceRepID(java.lang.Class clazz){ synchronized (classSeqToRepStr){ String repid = (String)classSeqToRepStr.get(clazz); if (repid != null) return repid; Class originalClazz = clazz; Class type = null; int numOfDims = 0; while ((type = clazz.getComponentType()) != null) { numOfDims++; clazz = type; } if (clazz.isPrimitive()) repid = kValuePrefix + originalClazz.getName() + kPrimitiveSequenceValueHash; else { StringBuffer buf = new StringBuffer(); buf.append(kValuePrefix); while(numOfDims-- > 0) { buf.append("["); } buf.append("L"); buf.append(convertToISOLatin1(clazz.getName())); buf.append(";"); buf.append(createHashString(clazz)); repid = buf.toString(); } classSeqToRepStr.put(originalClazz,repid); return repid; } } public static String createForSpecialCase(java.lang.Class clazz){ if (clazz.isArray()){ return createSequenceRepID(clazz); } else { return (String)kSpecialCasesRepIDs.get(clazz); } } public static String createForSpecialCase(java.io.Serializable ser){ Class clazz = ser.getClass(); if (clazz.isArray()){ return createSequenceRepID(ser); } else return createForSpecialCase(clazz); } /** * Creates a repository ID for a normal Java Type. * @param ser The Java object to create a repository ID for * @exception com.sun.corba.se.internal.io.TypeMismatchException if ser implements the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -