//UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'" public static ExternalizableWrapper readTag(System.IO.BinaryReader in_Renamed, PrototypeFactory pf) { sbyte[] tag = new sbyte[PrototypeFactory.CLASS_HASH_SIZE]; in_Renamed.Read((byte[])(Array)tag, 0, tag.Length); if (PrototypeFactory.compareHash(tag, WRAPPER_TAG)) { int wrapperCode = ExtUtil.readInt(in_Renamed); //find wrapper indicated by code ExternalizableWrapper type = null; foreach (Object key in WRAPPER_CODES.Keys) { System.Type t = (System.Type)key; if ((int)WRAPPER_CODES[key] == wrapperCode) { try { type = (ExternalizableWrapper)PrototypeFactory.getInstance(t); } catch (CannotCreateObjectException ccoe) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new CannotCreateObjectException("Serious problem: cannot create built-in ExternalizableWrapper [" + t.FullName + "]"); } } } if (type == null) { throw new DeserializationException("Unrecognized ExternalizableWrapper type [" + wrapperCode + "]"); } type.metaReadExternal(in_Renamed, pf); return(type); } else { System.Type type = pf.getClass(tag); if (type == null) { throw new DeserializationException("No datatype registered to serialization code " + ExtUtil.printBytes((byte[])(Array)tag)); } return(new ExtWrapBase(type)); } }
public static sbyte[] getClassHash(System.Type type) { sbyte[] hash = new sbyte[CLASS_HASH_SIZE]; //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" sbyte[] md5 = MD5.hash(SupportClass.ToSByteArray(SupportClass.ToByteArray(type.FullName))); //add support for a salt, in case of collision? for (int i = 0; i < hash.Length; i++) { hash[i] = md5[i]; } sbyte[] badHash = new sbyte[] { 0, 4, 78, 97 }; if (PrototypeFactory.compareHash(badHash, hash)) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.Console.Out.WriteLine("BAD CLASS: " + type.FullName); } return(hash); }