Fri, 24 Sep 2010 22:42:14 -0700
6891766: Vulnerabilities in use of reflection in CORBA
Reviewed-by: hawtin
1.1 --- a/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Fri Sep 24 16:38:05 2010 -0700 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,2721 +0,0 @@ 1.4 -/* 1.5 - * Copyright (c) 1998, 2004, 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 - * Licensed Materials - Property of IBM 1.30 - * RMI-IIOP v1.0 1.31 - * Copyright IBM Corp. 1998 1999 All Rights Reserved 1.32 - * 1.33 - */ 1.34 - 1.35 -package com.sun.corba.se.impl.io; 1.36 - 1.37 -import java.io.InputStream; 1.38 -import java.io.IOException; 1.39 -import java.io.StreamCorruptedException; 1.40 -import java.io.ObjectInputValidation; 1.41 -import java.io.NotActiveException; 1.42 -import java.io.InvalidObjectException; 1.43 -import java.io.InvalidClassException; 1.44 -import java.io.DataInputStream; 1.45 -import java.io.OptionalDataException; 1.46 -import java.io.WriteAbortedException; 1.47 -import java.io.Externalizable; 1.48 -import java.io.EOFException; 1.49 -import java.lang.reflect.*; 1.50 -import java.util.Vector; 1.51 -import java.util.Stack; 1.52 -import java.util.Hashtable; 1.53 -import java.util.Enumeration; 1.54 - 1.55 -import sun.corba.Bridge ; 1.56 - 1.57 -import java.security.AccessController ; 1.58 -import java.security.PrivilegedAction ; 1.59 - 1.60 -import com.sun.corba.se.impl.io.ObjectStreamClass; 1.61 -import com.sun.corba.se.impl.util.Utility; 1.62 - 1.63 -import org.omg.CORBA.portable.ValueInputStream; 1.64 - 1.65 -import org.omg.CORBA.ValueMember; 1.66 -import org.omg.CORBA.SystemException; 1.67 -import org.omg.CORBA.TCKind; 1.68 -import org.omg.CORBA.ORB; 1.69 -import org.omg.CORBA.CompletionStatus; 1.70 -import org.omg.CORBA.portable.IndirectionException; 1.71 -import org.omg.CORBA.MARSHAL; 1.72 -import org.omg.CORBA.TypeCode; 1.73 - 1.74 -import com.sun.org.omg.CORBA.ValueDefPackage.FullValueDescription; 1.75 -import com.sun.org.omg.SendingContext.CodeBase; 1.76 - 1.77 -import javax.rmi.PortableRemoteObject; 1.78 -import javax.rmi.CORBA.Util; 1.79 -import javax.rmi.CORBA.ValueHandler; 1.80 - 1.81 -import java.security.*; 1.82 -import java.util.*; 1.83 - 1.84 -import com.sun.corba.se.impl.orbutil.ObjectUtility ; 1.85 -import com.sun.corba.se.impl.logging.OMGSystemException ; 1.86 -import com.sun.corba.se.impl.logging.UtilSystemException ; 1.87 - 1.88 -import com.sun.corba.se.spi.logging.CORBALogDomains ; 1.89 - 1.90 -/** 1.91 - * IIOPInputStream is used by the ValueHandlerImpl to handle Java serialization 1.92 - * input semantics. 1.93 - * 1.94 - * @author Stephen Lewallen 1.95 - * @since JDK1.1.6 1.96 - */ 1.97 - 1.98 -public class IIOPInputStream 1.99 - extends com.sun.corba.se.impl.io.InputStreamHook 1.100 -{ 1.101 - private static Bridge bridge = 1.102 - (Bridge)AccessController.doPrivileged( 1.103 - new PrivilegedAction() { 1.104 - public Object run() { 1.105 - return Bridge.get() ; 1.106 - } 1.107 - } 1.108 - ) ; 1.109 - 1.110 - private static OMGSystemException omgWrapper = OMGSystemException.get( 1.111 - CORBALogDomains.RPC_ENCODING ) ; 1.112 - private static UtilSystemException utilWrapper = UtilSystemException.get( 1.113 - CORBALogDomains.RPC_ENCODING ) ; 1.114 - 1.115 - // Necessary to pass the appropriate fields into the 1.116 - // defaultReadObjectDelegate method (which takes no 1.117 - // parameters since it's called from 1.118 - // java.io.ObjectInpuStream defaultReadObject() 1.119 - // which we can't change). 1.120 - // 1.121 - // This is only used in the case where the fields had 1.122 - // to be obtained remotely because of a serializable 1.123 - // version difference. Set in inputObjectUsingFVD. 1.124 - // Part of serialization evolution fixes for Ladybird, 1.125 - // bug 4365188. 1.126 - private ValueMember defaultReadObjectFVDMembers[] = null; 1.127 - 1.128 - private org.omg.CORBA_2_3.portable.InputStream orbStream; 1.129 - 1.130 - private CodeBase cbSender; 1.131 - 1.132 - private ValueHandlerImpl vhandler; //d4365188 1.133 - 1.134 - private Object currentObject = null; 1.135 - 1.136 - private ObjectStreamClass currentClassDesc = null; 1.137 - 1.138 - private Class currentClass = null; 1.139 - 1.140 - private int recursionDepth = 0; 1.141 - 1.142 - private int simpleReadDepth = 0; 1.143 - 1.144 - // The ActiveRecursionManager replaces the old RecursionManager which 1.145 - // used to record how many recursions were made, and resolve them after 1.146 - // an object was completely deserialized. 1.147 - // 1.148 - // That created problems (as in bug 4414154) because when custom 1.149 - // unmarshaling in readObject, there can be recursive references 1.150 - // to one of the objects currently being unmarshaled, and the 1.151 - // passive recursion system failed. 1.152 - ActiveRecursionManager activeRecursionMgr = new ActiveRecursionManager(); 1.153 - 1.154 - private IOException abortIOException = null; 1.155 - 1.156 - /* Remember the first exception that stopped this stream. */ 1.157 - private ClassNotFoundException abortClassNotFoundException = null; 1.158 - 1.159 - /* Vector of validation callback objects 1.160 - * The vector is created as needed. The vector is maintained in 1.161 - * order of highest (first) priority to lowest 1.162 - */ 1.163 - private Vector callbacks; 1.164 - 1.165 - // Serialization machinery fields 1.166 - /* Arrays used to keep track of classes and ObjectStreamClasses 1.167 - * as they are being merged; used in inputObject. 1.168 - * spClass is the stack pointer for both. */ 1.169 - ObjectStreamClass[] classdesc; 1.170 - Class[] classes; 1.171 - int spClass; 1.172 - 1.173 - private static final String kEmptyStr = ""; 1.174 - 1.175 - // TCKind TypeCodes used in FVD inputClassFields 1.176 - //public static final TypeCode kRemoteTypeCode = new TypeCodeImpl(TCKind._tk_objref); 1.177 - //public static final TypeCode kValueTypeCode = new TypeCodeImpl(TCKind._tk_value); 1.178 - // removed TypeCodeImpl dependency 1.179 - public static final TypeCode kRemoteTypeCode = ORB.init().get_primitive_tc(TCKind.tk_objref); 1.180 - public static final TypeCode kValueTypeCode = ORB.init().get_primitive_tc(TCKind.tk_value); 1.181 - 1.182 - // TESTING CODE - useFVDOnly should be made final before FCS in order to 1.183 - // optimize out the check. 1.184 - private static final boolean useFVDOnly = false; 1.185 - 1.186 - private byte streamFormatVersion; 1.187 - 1.188 - // Since java.io.OptionalDataException's constructors are 1.189 - // package private, but we need to throw it in some special 1.190 - // cases, we try to do it by reflection. 1.191 - private static final Constructor OPT_DATA_EXCEPTION_CTOR; 1.192 - 1.193 - private Object[] readObjectArgList = { this } ; 1.194 - 1.195 - static { 1.196 - OPT_DATA_EXCEPTION_CTOR = getOptDataExceptionCtor(); 1.197 - } 1.198 - 1.199 - // Grab the OptionalDataException boolean ctor and make 1.200 - // it accessible. Note that any exceptions 1.201 - // will be wrapped in ExceptionInInitializerErrors. 1.202 - private static Constructor getOptDataExceptionCtor() { 1.203 - 1.204 - try { 1.205 - 1.206 - Constructor result = 1.207 - 1.208 - (Constructor) AccessController.doPrivileged( 1.209 - new PrivilegedExceptionAction() { 1.210 - public java.lang.Object run() 1.211 - throws NoSuchMethodException, 1.212 - SecurityException { 1.213 - 1.214 - Constructor boolCtor 1.215 - = OptionalDataException.class.getDeclaredConstructor( 1.216 - new Class[] { 1.217 - Boolean.TYPE }); 1.218 - 1.219 - boolCtor.setAccessible(true); 1.220 - 1.221 - return boolCtor; 1.222 - }}); 1.223 - 1.224 - if (result == null) 1.225 - // XXX I18N, logging needed. 1.226 - throw new Error("Unable to find OptionalDataException constructor"); 1.227 - 1.228 - return result; 1.229 - 1.230 - } catch (Exception ex) { 1.231 - // XXX I18N, logging needed. 1.232 - throw new ExceptionInInitializerError(ex); 1.233 - } 1.234 - } 1.235 - 1.236 - // Create a new OptionalDataException with the EOF marker 1.237 - // set to true. See handleOptionalDataMarshalException. 1.238 - private OptionalDataException createOptionalDataException() { 1.239 - try { 1.240 - OptionalDataException result 1.241 - = (OptionalDataException) 1.242 - OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] { 1.243 - Boolean.TRUE }); 1.244 - 1.245 - if (result == null) 1.246 - // XXX I18N, logging needed. 1.247 - throw new Error("Created null OptionalDataException"); 1.248 - 1.249 - return result; 1.250 - 1.251 - } catch (Exception ex) { 1.252 - // XXX I18N, logging needed. 1.253 - throw new Error("Couldn't create OptionalDataException", ex); 1.254 - } 1.255 - } 1.256 - 1.257 - // Return the stream format version currently being used 1.258 - // to deserialize an object 1.259 - protected byte getStreamFormatVersion() { 1.260 - return streamFormatVersion; 1.261 - } 1.262 - 1.263 - // At the beginning of data sent by a writeObject or 1.264 - // writeExternal method there is a byte telling the 1.265 - // reader the stream format version. 1.266 - private void readFormatVersion() throws IOException { 1.267 - 1.268 - streamFormatVersion = orbStream.read_octet(); 1.269 - 1.270 - if (streamFormatVersion < 1 || 1.271 - streamFormatVersion > vhandler.getMaximumStreamFormatVersion()) { 1.272 - SystemException sysex = omgWrapper.unsupportedFormatVersion( 1.273 - CompletionStatus.COMPLETED_MAYBE); 1.274 - // XXX I18N? Logging for IOException? 1.275 - IOException result = new IOException("Unsupported format version: " 1.276 - + streamFormatVersion); 1.277 - result.initCause( sysex ) ; 1.278 - throw result ; 1.279 - } 1.280 - 1.281 - if (streamFormatVersion == 2) { 1.282 - if (!(orbStream instanceof ValueInputStream)) { 1.283 - SystemException sysex = omgWrapper.notAValueinputstream( 1.284 - CompletionStatus.COMPLETED_MAYBE); 1.285 - // XXX I18N? Logging for IOException? 1.286 - IOException result = new IOException("Not a ValueInputStream"); 1.287 - result.initCause( sysex ) ; 1.288 - throw result; 1.289 - } 1.290 - } 1.291 - } 1.292 - 1.293 - public static void setTestFVDFlag(boolean val){ 1.294 - // useFVDOnly = val; 1.295 - } 1.296 - 1.297 - /** 1.298 - * Dummy constructor; passes upper stream a dummy stream; 1.299 - **/ 1.300 - public IIOPInputStream() 1.301 - throws java.io.IOException { 1.302 - super(); 1.303 - resetStream(); 1.304 - } 1.305 - 1.306 - public final void setOrbStream(org.omg.CORBA_2_3.portable.InputStream os) { 1.307 - orbStream = os; 1.308 - } 1.309 - 1.310 - public final org.omg.CORBA_2_3.portable.InputStream getOrbStream() { 1.311 - return orbStream; 1.312 - } 1.313 - 1.314 - //added setSender and getSender 1.315 - public final void setSender(CodeBase cb) { 1.316 - cbSender = cb; 1.317 - } 1.318 - 1.319 - public final CodeBase getSender() { 1.320 - return cbSender; 1.321 - } 1.322 - 1.323 - // 4365188 this is added to enable backward compatability w/ wrong 1.324 - // rep-ids 1.325 - public final void setValueHandler(ValueHandler vh) { 1.326 - vhandler = (com.sun.corba.se.impl.io.ValueHandlerImpl) vh; 1.327 - } 1.328 - 1.329 - public final ValueHandler getValueHandler() { 1.330 - return (javax.rmi.CORBA.ValueHandler) vhandler; 1.331 - } 1.332 - 1.333 - public final void increaseRecursionDepth(){ 1.334 - recursionDepth++; 1.335 - } 1.336 - 1.337 - public final int decreaseRecursionDepth(){ 1.338 - return --recursionDepth; 1.339 - } 1.340 - 1.341 - /** 1.342 - * Override the actions of the final method "readObject()" 1.343 - * in ObjectInputStream. 1.344 - * @since JDK1.1.6 1.345 - * 1.346 - * Read an object from the ObjectInputStream. 1.347 - * The class of the object, the signature of the class, and the values 1.348 - * of the non-transient and non-static fields of the class and all 1.349 - * of its supertypes are read. Default deserializing for a class can be 1.350 - * overriden using the writeObject and readObject methods. 1.351 - * Objects referenced by this object are read transitively so 1.352 - * that a complete equivalent graph of objects is reconstructed by readObject. <p> 1.353 - * 1.354 - * The root object is completly restored when all of its fields 1.355 - * and the objects it references are completely restored. At this 1.356 - * point the object validation callbacks are executed in order 1.357 - * based on their registered priorities. The callbacks are 1.358 - * registered by objects (in the readObject special methods) 1.359 - * as they are individually restored. 1.360 - * 1.361 - * Exceptions are thrown for problems with the InputStream and for classes 1.362 - * that should not be deserialized. All exceptions are fatal to the 1.363 - * InputStream and leave it in an indeterminate state; it is up to the caller 1.364 - * to ignore or recover the stream state. 1.365 - * @exception java.lang.ClassNotFoundException Class of a serialized object 1.366 - * cannot be found. 1.367 - * @exception InvalidClassException Something is wrong with a class used by 1.368 - * serialization. 1.369 - * @exception StreamCorruptedException Control information in the 1.370 - * stream is inconsistent. 1.371 - * @exception OptionalDataException Primitive data was found in the 1.372 - * stream instead of objects. 1.373 - * @exception IOException Any of the usual Input/Output related exceptions. 1.374 - * @since JDK1.1 1.375 - */ 1.376 - public final Object readObjectDelegate() throws IOException 1.377 - { 1.378 - try { 1.379 - 1.380 - readObjectState.readData(this); 1.381 - 1.382 - return orbStream.read_abstract_interface(); 1.383 - } catch (MARSHAL marshalException) { 1.384 - handleOptionalDataMarshalException(marshalException, true); 1.385 - throw marshalException; 1.386 - } catch(IndirectionException cdrie) 1.387 - { 1.388 - // The CDR stream had never seen the given offset before, 1.389 - // so check the recursion manager (it will throw an 1.390 - // IOException if it doesn't have a reference, either). 1.391 - return activeRecursionMgr.getObject(cdrie.offset); 1.392 - } 1.393 - } 1.394 - 1.395 - final Object simpleReadObject(Class clz, 1.396 - String repositoryID, 1.397 - com.sun.org.omg.SendingContext.CodeBase sender, 1.398 - int offset) 1.399 - /* throws OptionalDataException, ClassNotFoundException, IOException */ 1.400 - { 1.401 - 1.402 - /* Save the current state and get ready to read an object. */ 1.403 - Object prevObject = currentObject; 1.404 - ObjectStreamClass prevClassDesc = currentClassDesc; 1.405 - Class prevClass = currentClass; 1.406 - byte oldStreamFormatVersion = streamFormatVersion; 1.407 - 1.408 - simpleReadDepth++; // Entering 1.409 - Object obj = null; 1.410 - 1.411 - /* 1.412 - * Check for reset, handle it before reading an object. 1.413 - */ 1.414 - try { 1.415 - // d4365188: backward compatability 1.416 - if (vhandler.useFullValueDescription(clz, repositoryID)) { 1.417 - obj = inputObjectUsingFVD(clz, repositoryID, sender, offset); 1.418 - } else { 1.419 - obj = inputObject(clz, repositoryID, sender, offset); 1.420 - } 1.421 - 1.422 - obj = currentClassDesc.readResolve(obj); 1.423 - } 1.424 - catch(ClassNotFoundException cnfe) 1.425 - { 1.426 - bridge.throwException( cnfe ) ; 1.427 - return null; 1.428 - } 1.429 - catch(IOException ioe) 1.430 - { 1.431 - // System.out.println("CLZ = " + clz + "; " + ioe.toString()); 1.432 - bridge.throwException(ioe) ; 1.433 - return null; 1.434 - } 1.435 - finally { 1.436 - simpleReadDepth --; 1.437 - currentObject = prevObject; 1.438 - currentClassDesc = prevClassDesc; 1.439 - currentClass = prevClass; 1.440 - streamFormatVersion = oldStreamFormatVersion; 1.441 - } 1.442 - 1.443 - 1.444 - /* Check for thrown exceptions and re-throw them, clearing them if 1.445 - * this is the last recursive call . 1.446 - */ 1.447 - IOException exIOE = abortIOException; 1.448 - if (simpleReadDepth == 0) 1.449 - abortIOException = null; 1.450 - if (exIOE != null){ 1.451 - bridge.throwException( exIOE ) ; 1.452 - return null; 1.453 - } 1.454 - 1.455 - 1.456 - ClassNotFoundException exCNF = abortClassNotFoundException; 1.457 - if (simpleReadDepth == 0) 1.458 - abortClassNotFoundException = null; 1.459 - if (exCNF != null) { 1.460 - bridge.throwException( exCNF ) ; 1.461 - return null; 1.462 - } 1.463 - 1.464 - return obj; 1.465 - } 1.466 - 1.467 - public final void simpleSkipObject(String repositoryID, 1.468 - com.sun.org.omg.SendingContext.CodeBase sender) 1.469 - /* throws OptionalDataException, ClassNotFoundException, IOException */ 1.470 - { 1.471 - 1.472 - /* Save the current state and get ready to read an object. */ 1.473 - Object prevObject = currentObject; 1.474 - ObjectStreamClass prevClassDesc = currentClassDesc; 1.475 - Class prevClass = currentClass; 1.476 - byte oldStreamFormatVersion = streamFormatVersion; 1.477 - 1.478 - simpleReadDepth++; // Entering 1.479 - Object obj = null; 1.480 - 1.481 - /* 1.482 - * Check for reset, handle it before reading an object. 1.483 - */ 1.484 - try { 1.485 - skipObjectUsingFVD(repositoryID, sender); 1.486 - } 1.487 - catch(ClassNotFoundException cnfe) 1.488 - { 1.489 - bridge.throwException( cnfe ) ; 1.490 - return; 1.491 - } 1.492 - catch(IOException ioe) 1.493 - { 1.494 - bridge.throwException( ioe ) ; 1.495 - return; 1.496 - } 1.497 - finally { 1.498 - simpleReadDepth --; 1.499 - streamFormatVersion = oldStreamFormatVersion; 1.500 - currentObject = prevObject; 1.501 - currentClassDesc = prevClassDesc; 1.502 - currentClass = prevClass; 1.503 - } 1.504 - 1.505 - 1.506 - /* Check for thrown exceptions and re-throw them, clearing them if 1.507 - * this is the last recursive call . 1.508 - */ 1.509 - IOException exIOE = abortIOException; 1.510 - if (simpleReadDepth == 0) 1.511 - abortIOException = null; 1.512 - if (exIOE != null){ 1.513 - bridge.throwException( exIOE ) ; 1.514 - return; 1.515 - } 1.516 - 1.517 - 1.518 - ClassNotFoundException exCNF = abortClassNotFoundException; 1.519 - if (simpleReadDepth == 0) 1.520 - abortClassNotFoundException = null; 1.521 - if (exCNF != null) { 1.522 - bridge.throwException( exCNF ) ; 1.523 - return; 1.524 - } 1.525 - 1.526 - return; 1.527 - } 1.528 - ///////////////// 1.529 - 1.530 - /** 1.531 - * This method is called by trusted subclasses of ObjectOutputStream 1.532 - * that constructed ObjectOutputStream using the 1.533 - * protected no-arg constructor. The subclass is expected to provide 1.534 - * an override method with the modifier "final". 1.535 - * 1.536 - * @return the Object read from the stream. 1.537 - * 1.538 - * @see #ObjectInputStream() 1.539 - * @see #readObject 1.540 - * @since JDK 1.2 1.541 - */ 1.542 - protected final Object readObjectOverride() 1.543 - throws OptionalDataException, ClassNotFoundException, IOException 1.544 - { 1.545 - return readObjectDelegate(); 1.546 - } 1.547 - 1.548 - /** 1.549 - * Override the actions of the final method "defaultReadObject()" 1.550 - * in ObjectInputStream. 1.551 - * @since JDK1.1.6 1.552 - * 1.553 - * Read the non-static and non-transient fields of the current class 1.554 - * from this stream. This may only be called from the readObject method 1.555 - * of the class being deserialized. It will throw the NotActiveException 1.556 - * if it is called otherwise. 1.557 - * 1.558 - * @exception java.lang.ClassNotFoundException if the class of a serialized 1.559 - * object could not be found. 1.560 - * @exception IOException if an I/O error occurs. 1.561 - * @exception NotActiveException if the stream is not currently reading 1.562 - * objects. 1.563 - * @since JDK1.1 1.564 - */ 1.565 - public final void defaultReadObjectDelegate() 1.566 - /* throws IOException, ClassNotFoundException, NotActiveException */ 1.567 - { 1.568 - try { 1.569 - if (currentObject == null || currentClassDesc == null) 1.570 - // XXX I18N, logging needed. 1.571 - throw new NotActiveException("defaultReadObjectDelegate"); 1.572 - 1.573 - // The array will be null unless fields were retrieved 1.574 - // remotely because of a serializable version difference. 1.575 - // Bug fix for 4365188. See the definition of 1.576 - // defaultReadObjectFVDMembers for more information. 1.577 - if (defaultReadObjectFVDMembers != null && 1.578 - defaultReadObjectFVDMembers.length > 0) { 1.579 - 1.580 - // WARNING: Be very careful! What if some of 1.581 - // these fields actually have to do this, too? 1.582 - // This works because the defaultReadObjectFVDMembers 1.583 - // reference is passed to inputClassFields, but 1.584 - // there is no guarantee that 1.585 - // defaultReadObjectFVDMembers will point to the 1.586 - // same array after calling inputClassFields. 1.587 - 1.588 - // Use the remote fields to unmarshal. 1.589 - inputClassFields(currentObject, 1.590 - currentClass, 1.591 - currentClassDesc, 1.592 - defaultReadObjectFVDMembers, 1.593 - cbSender); 1.594 - 1.595 - } else { 1.596 - 1.597 - // Use the local fields to unmarshal. 1.598 - ObjectStreamField[] fields = 1.599 - currentClassDesc.getFieldsNoCopy(); 1.600 - if (fields.length > 0) { 1.601 - inputClassFields(currentObject, currentClass, fields, cbSender); 1.602 - } 1.603 - } 1.604 - } 1.605 - catch(NotActiveException nae) 1.606 - { 1.607 - bridge.throwException( nae ) ; 1.608 - } 1.609 - catch(IOException ioe) 1.610 - { 1.611 - bridge.throwException( ioe ) ; 1.612 - } 1.613 - catch(ClassNotFoundException cnfe) 1.614 - { 1.615 - bridge.throwException( cnfe ) ; 1.616 - } 1.617 - 1.618 - } 1.619 - 1.620 - /** 1.621 - * Override the actions of the final method "enableResolveObject()" 1.622 - * in ObjectInputStream. 1.623 - * @since JDK1.1.6 1.624 - * 1.625 - * Enable the stream to allow objects read from the stream to be replaced. 1.626 - * If the stream is a trusted class it is allowed to enable replacment. 1.627 - * Trusted classes are those classes with a classLoader equals null. <p> 1.628 - * 1.629 - * When enabled the resolveObject method is called for every object 1.630 - * being deserialized. 1.631 - * 1.632 - * @exception SecurityException The classloader of this stream object is non-null. 1.633 - * @since JDK1.1 1.634 - */ 1.635 - public final boolean enableResolveObjectDelegate(boolean enable) 1.636 - /* throws SecurityException */ 1.637 - { 1.638 - return false; 1.639 - } 1.640 - 1.641 - // The following three methods allow the implementing orbStream 1.642 - // to provide mark/reset behavior as defined in java.io.InputStream. 1.643 - 1.644 - public final void mark(int readAheadLimit) { 1.645 - orbStream.mark(readAheadLimit); 1.646 - } 1.647 - 1.648 - public final boolean markSupported() { 1.649 - return orbStream.markSupported(); 1.650 - } 1.651 - 1.652 - public final void reset() throws IOException { 1.653 - try { 1.654 - orbStream.reset(); 1.655 - } catch (Error e) { 1.656 - IOException err = new IOException(e.getMessage()); 1.657 - err.initCause(e) ; 1.658 - throw err ; 1.659 - } 1.660 - } 1.661 - 1.662 - public final int available() throws IOException{ 1.663 - return 0; // unreliable 1.664 - } 1.665 - 1.666 - public final void close() throws IOException{ 1.667 - // no op 1.668 - } 1.669 - 1.670 - public final int read() throws IOException{ 1.671 - try{ 1.672 - readObjectState.readData(this); 1.673 - 1.674 - return (orbStream.read_octet() << 0) & 0x000000FF; 1.675 - } catch (MARSHAL marshalException) { 1.676 - if (marshalException.minor 1.677 - == OMGSystemException.RMIIIOP_OPTIONAL_DATA_INCOMPATIBLE1) { 1.678 - setState(IN_READ_OBJECT_NO_MORE_OPT_DATA); 1.679 - return -1; 1.680 - } 1.681 - 1.682 - throw marshalException; 1.683 - } catch(Error e) { 1.684 - IOException exc = new IOException(e.getMessage()); 1.685 - exc.initCause(e) ; 1.686 - throw exc ; 1.687 - } 1.688 - } 1.689 - 1.690 - public final int read(byte data[], int offset, int length) throws IOException{ 1.691 - try{ 1.692 - readObjectState.readData(this); 1.693 - 1.694 - orbStream.read_octet_array(data, offset, length); 1.695 - return length; 1.696 - } catch (MARSHAL marshalException) { 1.697 - if (marshalException.minor 1.698 - == OMGSystemException.RMIIIOP_OPTIONAL_DATA_INCOMPATIBLE1) { 1.699 - setState(IN_READ_OBJECT_NO_MORE_OPT_DATA); 1.700 - return -1; 1.701 - } 1.702 - 1.703 - throw marshalException; 1.704 - } catch(Error e) { 1.705 - IOException exc = new IOException(e.getMessage()); 1.706 - exc.initCause(e) ; 1.707 - throw exc ; 1.708 - } 1.709 - 1.710 - } 1.711 - 1.712 - public final boolean readBoolean() throws IOException{ 1.713 - try{ 1.714 - readObjectState.readData(this); 1.715 - 1.716 - return orbStream.read_boolean(); 1.717 - } catch (MARSHAL marshalException) { 1.718 - handleOptionalDataMarshalException(marshalException, false); 1.719 - throw marshalException; 1.720 - 1.721 - } catch(Error e) { 1.722 - IOException exc = new IOException(e.getMessage()); 1.723 - exc.initCause(e); 1.724 - throw exc ; 1.725 - } 1.726 - } 1.727 - 1.728 - public final byte readByte() throws IOException{ 1.729 - try{ 1.730 - readObjectState.readData(this); 1.731 - 1.732 - return orbStream.read_octet(); 1.733 - } catch (MARSHAL marshalException) { 1.734 - handleOptionalDataMarshalException(marshalException, false); 1.735 - throw marshalException; 1.736 - 1.737 - } catch(Error e) { 1.738 - IOException exc = new IOException(e.getMessage()); 1.739 - exc.initCause(e); 1.740 - throw exc ; 1.741 - } 1.742 - } 1.743 - 1.744 - public final char readChar() throws IOException{ 1.745 - try{ 1.746 - readObjectState.readData(this); 1.747 - 1.748 - return orbStream.read_wchar(); 1.749 - } catch (MARSHAL marshalException) { 1.750 - handleOptionalDataMarshalException(marshalException, false); 1.751 - throw marshalException; 1.752 - 1.753 - } catch(Error e) { 1.754 - IOException exc = new IOException(e.getMessage()); 1.755 - exc.initCause(e); 1.756 - throw exc ; 1.757 - } 1.758 - } 1.759 - 1.760 - public final double readDouble() throws IOException{ 1.761 - try{ 1.762 - readObjectState.readData(this); 1.763 - 1.764 - return orbStream.read_double(); 1.765 - } catch (MARSHAL marshalException) { 1.766 - handleOptionalDataMarshalException(marshalException, false); 1.767 - throw marshalException; 1.768 - } catch(Error e) { 1.769 - IOException exc = new IOException(e.getMessage()); 1.770 - exc.initCause(e); 1.771 - throw exc ; 1.772 - } 1.773 - } 1.774 - 1.775 - public final float readFloat() throws IOException{ 1.776 - try{ 1.777 - readObjectState.readData(this); 1.778 - 1.779 - return orbStream.read_float(); 1.780 - } catch (MARSHAL marshalException) { 1.781 - handleOptionalDataMarshalException(marshalException, false); 1.782 - throw marshalException; 1.783 - } catch(Error e) { 1.784 - IOException exc = new IOException(e.getMessage()); 1.785 - exc.initCause(e); 1.786 - throw exc ; 1.787 - } 1.788 - } 1.789 - 1.790 - public final void readFully(byte data[]) throws IOException{ 1.791 -// d11623 : implement readFully, required for serializing some core classes 1.792 - 1.793 - readFully(data, 0, data.length); 1.794 - } 1.795 - 1.796 - public final void readFully(byte data[], int offset, int size) throws IOException{ 1.797 -// d11623 : implement readFully, required for serializing some core classes 1.798 - try{ 1.799 - readObjectState.readData(this); 1.800 - 1.801 - orbStream.read_octet_array(data, offset, size); 1.802 - } catch (MARSHAL marshalException) { 1.803 - handleOptionalDataMarshalException(marshalException, false); 1.804 - 1.805 - throw marshalException; 1.806 - } catch(Error e) { 1.807 - IOException exc = new IOException(e.getMessage()); 1.808 - exc.initCause(e); 1.809 - throw exc ; 1.810 - } 1.811 - } 1.812 - 1.813 - public final int readInt() throws IOException{ 1.814 - try{ 1.815 - readObjectState.readData(this); 1.816 - 1.817 - return orbStream.read_long(); 1.818 - } catch (MARSHAL marshalException) { 1.819 - handleOptionalDataMarshalException(marshalException, false); 1.820 - throw marshalException; 1.821 - } catch(Error e) { 1.822 - IOException exc = new IOException(e.getMessage()); 1.823 - exc.initCause(e); 1.824 - throw exc ; 1.825 - } 1.826 - } 1.827 - 1.828 - public final String readLine() throws IOException{ 1.829 - // XXX I18N, logging needed. 1.830 - throw new IOException("Method readLine not supported"); 1.831 - } 1.832 - 1.833 - public final long readLong() throws IOException{ 1.834 - try{ 1.835 - readObjectState.readData(this); 1.836 - 1.837 - return orbStream.read_longlong(); 1.838 - } catch (MARSHAL marshalException) { 1.839 - handleOptionalDataMarshalException(marshalException, false); 1.840 - throw marshalException; 1.841 - } catch(Error e) { 1.842 - IOException exc = new IOException(e.getMessage()); 1.843 - exc.initCause(e); 1.844 - throw exc ; 1.845 - } 1.846 - } 1.847 - 1.848 - public final short readShort() throws IOException{ 1.849 - try{ 1.850 - readObjectState.readData(this); 1.851 - 1.852 - return orbStream.read_short(); 1.853 - } catch (MARSHAL marshalException) { 1.854 - handleOptionalDataMarshalException(marshalException, false); 1.855 - throw marshalException; 1.856 - } catch(Error e) { 1.857 - IOException exc = new IOException(e.getMessage()); 1.858 - exc.initCause(e); 1.859 - throw exc ; 1.860 - } 1.861 - } 1.862 - 1.863 - protected final void readStreamHeader() throws IOException, StreamCorruptedException{ 1.864 - // no op 1.865 - } 1.866 - 1.867 - public final int readUnsignedByte() throws IOException{ 1.868 - try{ 1.869 - readObjectState.readData(this); 1.870 - 1.871 - return (orbStream.read_octet() << 0) & 0x000000FF; 1.872 - } catch (MARSHAL marshalException) { 1.873 - handleOptionalDataMarshalException(marshalException, false); 1.874 - throw marshalException; 1.875 - } catch(Error e) { 1.876 - IOException exc = new IOException(e.getMessage()); 1.877 - exc.initCause(e); 1.878 - throw exc ; 1.879 - } 1.880 - } 1.881 - 1.882 - public final int readUnsignedShort() throws IOException{ 1.883 - try{ 1.884 - readObjectState.readData(this); 1.885 - 1.886 - return (orbStream.read_ushort() << 0) & 0x0000FFFF; 1.887 - } catch (MARSHAL marshalException) { 1.888 - handleOptionalDataMarshalException(marshalException, false); 1.889 - throw marshalException; 1.890 - } catch(Error e) { 1.891 - IOException exc = new IOException(e.getMessage()); 1.892 - exc.initCause(e); 1.893 - throw exc ; 1.894 - } 1.895 - } 1.896 - 1.897 - /** 1.898 - * Helper method for correcting the Kestrel bug 4367783 (dealing 1.899 - * with larger than 8-bit chars). The old behavior is preserved 1.900 - * in orbutil.IIOPInputStream_1_3 in order to interoperate with 1.901 - * our legacy ORBs. 1.902 - */ 1.903 - protected String internalReadUTF(org.omg.CORBA.portable.InputStream stream) 1.904 - { 1.905 - return stream.read_wstring(); 1.906 - } 1.907 - 1.908 - public final String readUTF() throws IOException{ 1.909 - try{ 1.910 - readObjectState.readData(this); 1.911 - 1.912 - return internalReadUTF(orbStream); 1.913 - } catch (MARSHAL marshalException) { 1.914 - handleOptionalDataMarshalException(marshalException, false); 1.915 - throw marshalException; 1.916 - } catch(Error e) { 1.917 - IOException exc = new IOException(e.getMessage()); 1.918 - exc.initCause(e); 1.919 - throw exc ; 1.920 - } 1.921 - } 1.922 - 1.923 - // If the ORB stream detects an incompatibility between what's 1.924 - // on the wire and what our Serializable's readObject wants, 1.925 - // it throws a MARSHAL exception with a specific minor code. 1.926 - // This is rethrown to the readObject as an OptionalDataException. 1.927 - // So far in RMI-IIOP, this process isn't specific enough to 1.928 - // tell the readObject how much data is available, so we always 1.929 - // set the OptionalDataException's EOF marker to true. 1.930 - private void handleOptionalDataMarshalException(MARSHAL marshalException, 1.931 - boolean objectRead) 1.932 - throws IOException { 1.933 - 1.934 - // Java Object Serialization spec 3.4: "If the readObject method 1.935 - // of the class attempts to read more data than is present in the 1.936 - // optional part of the stream for this class, the stream will 1.937 - // return -1 for bytewise reads, throw an EOFException for 1.938 - // primitive data reads, or throw an OptionalDataException 1.939 - // with the eof field set to true for object reads." 1.940 - if (marshalException.minor 1.941 - == OMGSystemException.RMIIIOP_OPTIONAL_DATA_INCOMPATIBLE1) { 1.942 - 1.943 - IOException result; 1.944 - 1.945 - if (!objectRead) 1.946 - result = new EOFException("No more optional data"); 1.947 - else 1.948 - result = createOptionalDataException(); 1.949 - 1.950 - result.initCause(marshalException); 1.951 - 1.952 - setState(IN_READ_OBJECT_NO_MORE_OPT_DATA); 1.953 - 1.954 - throw result; 1.955 - } 1.956 - } 1.957 - 1.958 - public final synchronized void registerValidation(ObjectInputValidation obj, 1.959 - int prio) 1.960 - throws NotActiveException, InvalidObjectException{ 1.961 - // XXX I18N, logging needed. 1.962 - throw new Error("Method registerValidation not supported"); 1.963 - } 1.964 - 1.965 - protected final Class resolveClass(ObjectStreamClass v) 1.966 - throws IOException, ClassNotFoundException{ 1.967 - // XXX I18N, logging needed. 1.968 - throw new IOException("Method resolveClass not supported"); 1.969 - } 1.970 - 1.971 - protected final Object resolveObject(Object obj) throws IOException{ 1.972 - // XXX I18N, logging needed. 1.973 - throw new IOException("Method resolveObject not supported"); 1.974 - } 1.975 - 1.976 - public final int skipBytes(int len) throws IOException{ 1.977 - try{ 1.978 - readObjectState.readData(this); 1.979 - 1.980 - byte buf[] = new byte[len]; 1.981 - orbStream.read_octet_array(buf, 0, len); 1.982 - return len; 1.983 - } catch (MARSHAL marshalException) { 1.984 - handleOptionalDataMarshalException(marshalException, false); 1.985 - 1.986 - throw marshalException; 1.987 - } catch(Error e) { 1.988 - IOException exc = new IOException(e.getMessage()); 1.989 - exc.initCause(e) ; 1.990 - throw exc ; 1.991 - } 1.992 - } 1.993 - 1.994 - private Object inputObject(Class clz, 1.995 - String repositoryID, 1.996 - com.sun.org.omg.SendingContext.CodeBase sender, 1.997 - int offset) 1.998 - throws IOException, ClassNotFoundException 1.999 - { 1.1000 - 1.1001 - /* 1.1002 - * Get the descriptor and then class of the incoming object. 1.1003 - */ 1.1004 - 1.1005 - currentClassDesc = ObjectStreamClass.lookup(clz); 1.1006 - currentClass = currentClassDesc.forClass(); 1.1007 - //currentClassDesc.setClass(currentClass); 1.1008 - if (currentClass == null) 1.1009 - // XXX I18N, logging needed. 1.1010 - throw new ClassNotFoundException(currentClassDesc.getName()); 1.1011 - 1.1012 - try { 1.1013 - /* If Externalizable, 1.1014 - * Create an instance and tell it to read its data. 1.1015 - * else, 1.1016 - * Handle it as a serializable class. 1.1017 - */ 1.1018 - if (currentClassDesc.isExternalizable()) { 1.1019 - try { 1.1020 - currentObject = (currentClass == null) ? 1.1021 - null : currentClassDesc.newInstance(); 1.1022 - if (currentObject != null) { 1.1023 - 1.1024 - // Store this object and its beginning position 1.1025 - // since there might be indirections to it while 1.1026 - // it's been unmarshalled. 1.1027 - activeRecursionMgr.addObject(offset, currentObject); 1.1028 - 1.1029 - // Read format version 1.1030 - readFormatVersion(); 1.1031 - 1.1032 - Externalizable ext = (Externalizable)currentObject; 1.1033 - ext.readExternal(this); 1.1034 - } 1.1035 - } catch (InvocationTargetException e) { 1.1036 - InvalidClassException exc = new InvalidClassException( 1.1037 - currentClass.getName(), 1.1038 - "InvocationTargetException accessing no-arg constructor"); 1.1039 - exc.initCause( e ) ; 1.1040 - throw exc ; 1.1041 - } catch (UnsupportedOperationException e) { 1.1042 - InvalidClassException exc = new InvalidClassException( 1.1043 - currentClass.getName(), 1.1044 - "UnsupportedOperationException accessing no-arg constructor"); 1.1045 - exc.initCause( e ) ; 1.1046 - throw exc ; 1.1047 - } catch (InstantiationException e) { 1.1048 - InvalidClassException exc = new InvalidClassException( 1.1049 - currentClass.getName(), 1.1050 - "InstantiationException accessing no-arg constructor"); 1.1051 - exc.initCause( e ) ; 1.1052 - throw exc ; 1.1053 - } 1.1054 - } // end : if (currentClassDesc.isExternalizable()) 1.1055 - else { 1.1056 - /* Count number of classes and descriptors we might have 1.1057 - * to work on. 1.1058 - */ 1.1059 - 1.1060 - ObjectStreamClass currdesc = currentClassDesc; 1.1061 - Class currclass = currentClass; 1.1062 - 1.1063 - int spBase = spClass; // current top of stack 1.1064 - 1.1065 - /* The object's classes should be processed from supertype to subtype 1.1066 - * Push all the clases of the current object onto a stack. 1.1067 - * Note that only the serializable classes are represented 1.1068 - * in the descriptor list. 1.1069 - * 1.1070 - * Handle versioning where one or more supertypes of 1.1071 - * have been inserted or removed. The stack will 1.1072 - * contain pairs of descriptors and the corresponding 1.1073 - * class. If the object has a class that did not occur in 1.1074 - * the original the descriptor will be null. If the 1.1075 - * original object had a descriptor for a class not 1.1076 - * present in the local hierarchy of the object the class will be 1.1077 - * null. 1.1078 - * 1.1079 - */ 1.1080 - 1.1081 - /* 1.1082 - * This is your basic diff pattern, made simpler 1.1083 - * because reordering is not allowed. 1.1084 - */ 1.1085 - // sun.4296963 ibm.11861 1.1086 - // d11861 we should stop when we find the highest serializable class 1.1087 - // We need this so that when we allocate the new object below, we 1.1088 - // can call the constructor of the non-serializable superclass. 1.1089 - // Note that in the JRMP variant of this code the 1.1090 - // ObjectStreamClass.lookup() method handles this, but we've put 1.1091 - // this fix here rather than change lookup because the new behaviour 1.1092 - // is needed in other cases. 1.1093 - 1.1094 - for (currdesc = currentClassDesc, currclass = currentClass; 1.1095 - currdesc != null && currdesc.isSerializable(); /*sun.4296963 ibm.11861*/ 1.1096 - currdesc = currdesc.getSuperclass()) { 1.1097 - 1.1098 - /* 1.1099 - * Search the classes to see if the class of this 1.1100 - * descriptor appears further up the hierarchy. Until 1.1101 - * it's found assume its an inserted class. If it's 1.1102 - * not found, its the descriptor's class that has been 1.1103 - * removed. 1.1104 - */ 1.1105 - Class cc = currdesc.forClass(); 1.1106 - Class cl; 1.1107 - for (cl = currclass; cl != null; cl = cl.getSuperclass()) { 1.1108 - if (cc == cl) { 1.1109 - // found a superclass that matches this descriptor 1.1110 - break; 1.1111 - } else { 1.1112 - /* Ignore a class that doesn't match. No 1.1113 - * action is needed since it is already 1.1114 - * initialized. 1.1115 - */ 1.1116 - } 1.1117 - } // end : for (cl = currclass; cl != null; cl = cl.getSuperclass()) 1.1118 - /* Test if there is room for this new entry. 1.1119 - * If not, double the size of the arrays and copy the contents. 1.1120 - */ 1.1121 - spClass++; 1.1122 - if (spClass >= classes.length) { 1.1123 - int newlen = classes.length * 2; 1.1124 - Class[] newclasses = new Class[newlen]; 1.1125 - ObjectStreamClass[] newclassdesc = new ObjectStreamClass[newlen]; 1.1126 - 1.1127 - System.arraycopy(classes, 0, 1.1128 - newclasses, 0, 1.1129 - classes.length); 1.1130 - System.arraycopy(classdesc, 0, 1.1131 - newclassdesc, 0, 1.1132 - classes.length); 1.1133 - 1.1134 - classes = newclasses; 1.1135 - classdesc = newclassdesc; 1.1136 - } 1.1137 - 1.1138 - if (cl == null) { 1.1139 - /* Class not found corresponding to this descriptor. 1.1140 - * Pop off all the extra classes pushed. 1.1141 - * Push the descriptor and a null class. 1.1142 - */ 1.1143 - classdesc[spClass] = currdesc; 1.1144 - classes[spClass] = null; 1.1145 - } else { 1.1146 - /* Current class descriptor matches current class. 1.1147 - * Some classes may have been inserted. 1.1148 - * Record the match and advance the class, continue 1.1149 - * with the next descriptor. 1.1150 - */ 1.1151 - classdesc[spClass] = currdesc; 1.1152 - classes[spClass] = cl; 1.1153 - currclass = cl.getSuperclass(); 1.1154 - } 1.1155 - } // end : for (currdesc = currentClassDesc, currclass = currentClass; 1.1156 - 1.1157 - /* Allocate a new object. The object is only constructed 1.1158 - * above the highest serializable class and is set to 1.1159 - * default values for all more specialized classes. 1.1160 - */ 1.1161 - try { 1.1162 - currentObject = (currentClass == null) ? 1.1163 - null : currentClassDesc.newInstance() ; 1.1164 - 1.1165 - // Store this object and its beginning position 1.1166 - // since there might be indirections to it while 1.1167 - // it's been unmarshalled. 1.1168 - activeRecursionMgr.addObject(offset, currentObject); 1.1169 - } catch (InvocationTargetException e) { 1.1170 - InvalidClassException exc = new InvalidClassException( 1.1171 - currentClass.getName(), 1.1172 - "InvocationTargetException accessing no-arg constructor"); 1.1173 - exc.initCause( e ) ; 1.1174 - throw exc ; 1.1175 - } catch (UnsupportedOperationException e) { 1.1176 - InvalidClassException exc = new InvalidClassException( 1.1177 - currentClass.getName(), 1.1178 - "UnsupportedOperationException accessing no-arg constructor"); 1.1179 - exc.initCause( e ) ; 1.1180 - throw exc ; 1.1181 - } catch (InstantiationException e) { 1.1182 - InvalidClassException exc = new InvalidClassException( 1.1183 - currentClass.getName(), 1.1184 - "InstantiationException accessing no-arg constructor"); 1.1185 - exc.initCause( e ) ; 1.1186 - throw exc ; 1.1187 - } 1.1188 - 1.1189 - /* 1.1190 - * For all the pushed descriptors and classes. 1.1191 - * if the class has its own writeObject and readObject methods 1.1192 - * call the readObject method 1.1193 - * else 1.1194 - * invoke the defaultReadObject method 1.1195 - */ 1.1196 - try { 1.1197 - for (spClass = spClass; spClass > spBase; spClass--) { 1.1198 - /* 1.1199 - * Set current descriptor and corresponding class 1.1200 - */ 1.1201 - currentClassDesc = classdesc[spClass]; 1.1202 - currentClass = classes[spClass]; 1.1203 - if (classes[spClass] != null) { 1.1204 - /* Read the data from the stream described by the 1.1205 - * descriptor and store into the matching class. 1.1206 - */ 1.1207 - 1.1208 - ReadObjectState oldState = readObjectState; 1.1209 - setState(DEFAULT_STATE); 1.1210 - 1.1211 - try { 1.1212 - 1.1213 - // Changed since invokeObjectReader no longer does this. 1.1214 - if (currentClassDesc.hasWriteObject()) { 1.1215 - 1.1216 - // Read format version 1.1217 - readFormatVersion(); 1.1218 - 1.1219 - // Read defaultWriteObject indicator 1.1220 - boolean calledDefaultWriteObject = readBoolean(); 1.1221 - 1.1222 - readObjectState.beginUnmarshalCustomValue(this, 1.1223 - calledDefaultWriteObject, 1.1224 - (currentClassDesc.readObjectMethod 1.1225 - != null)); 1.1226 - } else { 1.1227 - if (currentClassDesc.hasReadObject()) 1.1228 - setState(IN_READ_OBJECT_REMOTE_NOT_CUSTOM_MARSHALED); 1.1229 - } 1.1230 - 1.1231 - if (!invokeObjectReader(currentClassDesc, currentObject, currentClass) || 1.1232 - readObjectState == IN_READ_OBJECT_DEFAULTS_SENT) { 1.1233 - 1.1234 - // Error case of no readObject and didn't call 1.1235 - // defaultWriteObject handled in default state 1.1236 - 1.1237 - ObjectStreamField[] fields = 1.1238 - currentClassDesc.getFieldsNoCopy(); 1.1239 - if (fields.length > 0) { 1.1240 - inputClassFields(currentObject, currentClass, fields, sender); 1.1241 - } 1.1242 - } 1.1243 - 1.1244 - if (currentClassDesc.hasWriteObject()) 1.1245 - readObjectState.endUnmarshalCustomValue(this); 1.1246 - 1.1247 - } finally { 1.1248 - setState(oldState); 1.1249 - } 1.1250 - 1.1251 - } else { 1.1252 - 1.1253 - // _REVISIT_ : Can we ever get here? 1.1254 - /* No local class for this descriptor, 1.1255 - * Skip over the data for this class. 1.1256 - * like defaultReadObject with a null currentObject. 1.1257 - * The code will read the values but discard them. 1.1258 - */ 1.1259 - ObjectStreamField[] fields = 1.1260 - currentClassDesc.getFieldsNoCopy(); 1.1261 - if (fields.length > 0) { 1.1262 - inputClassFields(null, currentClass, fields, sender); 1.1263 - } 1.1264 - 1.1265 - } 1.1266 - 1.1267 - } 1.1268 - } finally { 1.1269 - // Make sure we exit at the same stack level as when we started. 1.1270 - spClass = spBase; 1.1271 - } 1.1272 - } 1.1273 - } finally { 1.1274 - // We've completed deserializing this object. Any 1.1275 - // future indirections will be handled correctly at the 1.1276 - // CDR level. The ActiveRecursionManager only deals with 1.1277 - // objects currently being deserialized. 1.1278 - activeRecursionMgr.removeObject(offset); 1.1279 - } 1.1280 - 1.1281 - return currentObject; 1.1282 - } 1.1283 - 1.1284 - // This retrieves a vector of FVD's for the hierarchy of serializable classes stemming from 1.1285 - // repositoryID. It is assumed that the sender will not provide base_value id's for non-serializable 1.1286 - // classes! 1.1287 - private Vector getOrderedDescriptions(String repositoryID, 1.1288 - com.sun.org.omg.SendingContext.CodeBase sender) { 1.1289 - Vector descs = new Vector(); 1.1290 - 1.1291 - if (sender == null) { 1.1292 - return descs; 1.1293 - } 1.1294 - 1.1295 - FullValueDescription aFVD = sender.meta(repositoryID); 1.1296 - while (aFVD != null) { 1.1297 - descs.insertElementAt(aFVD, 0); 1.1298 - if ((aFVD.base_value != null) && !kEmptyStr.equals(aFVD.base_value)) { 1.1299 - aFVD = sender.meta(aFVD.base_value); 1.1300 - } 1.1301 - else return descs; 1.1302 - } 1.1303 - 1.1304 - return descs; 1.1305 - } 1.1306 - 1.1307 - /** 1.1308 - * This input method uses FullValueDescriptions retrieved from the sender's runtime to 1.1309 - * read in the data. This method is capable of throwing out data not applicable to client's fields. 1.1310 - * This method handles instances where the reader has a class not sent by the sender, the sender sent 1.1311 - * a class not present on the reader, and/or the reader's class does not match the sender's class. 1.1312 - * 1.1313 - * NOTE : If the local description indicates custom marshaling and the remote type's FVD also 1.1314 - * indicates custom marsahling than the local type is used to read the data off the wire. However, 1.1315 - * if either says custom while the other does not, a MARSHAL error is thrown. Externalizable is 1.1316 - * a form of custom marshaling. 1.1317 - * 1.1318 - */ 1.1319 - private Object inputObjectUsingFVD(Class clz, 1.1320 - String repositoryID, 1.1321 - com.sun.org.omg.SendingContext.CodeBase sender, 1.1322 - int offset) 1.1323 - throws IOException, ClassNotFoundException 1.1324 - { 1.1325 - int spBase = spClass; // current top of stack 1.1326 - try{ 1.1327 - 1.1328 - /* 1.1329 - * Get the descriptor and then class of the incoming object. 1.1330 - */ 1.1331 - 1.1332 - ObjectStreamClass currdesc = currentClassDesc = ObjectStreamClass.lookup(clz); 1.1333 - Class currclass = currentClass = clz; 1.1334 - 1.1335 - /* If Externalizable, 1.1336 - * Create an instance and tell it to read its data. 1.1337 - * else, 1.1338 - * Handle it as a serializable class. 1.1339 - */ 1.1340 - if (currentClassDesc.isExternalizable()) { 1.1341 - try { 1.1342 - currentObject = (currentClass == null) ? 1.1343 - null : currentClassDesc.newInstance(); 1.1344 - if (currentObject != null) { 1.1345 - // Store this object and its beginning position 1.1346 - // since there might be indirections to it while 1.1347 - // it's been unmarshalled. 1.1348 - activeRecursionMgr.addObject(offset, currentObject); 1.1349 - 1.1350 - // Read format version 1.1351 - readFormatVersion(); 1.1352 - 1.1353 - Externalizable ext = (Externalizable)currentObject; 1.1354 - ext.readExternal(this); 1.1355 - } 1.1356 - } catch (InvocationTargetException e) { 1.1357 - InvalidClassException exc = new InvalidClassException( 1.1358 - currentClass.getName(), 1.1359 - "InvocationTargetException accessing no-arg constructor"); 1.1360 - exc.initCause( e ) ; 1.1361 - throw exc ; 1.1362 - } catch (UnsupportedOperationException e) { 1.1363 - InvalidClassException exc = new InvalidClassException( 1.1364 - currentClass.getName(), 1.1365 - "UnsupportedOperationException accessing no-arg constructor"); 1.1366 - exc.initCause( e ) ; 1.1367 - throw exc ; 1.1368 - } catch (InstantiationException e) { 1.1369 - InvalidClassException exc = new InvalidClassException( 1.1370 - currentClass.getName(), 1.1371 - "InstantiationException accessing no-arg constructor"); 1.1372 - exc.initCause( e ) ; 1.1373 - throw exc ; 1.1374 - } 1.1375 - } else { 1.1376 - /* 1.1377 - * This is your basic diff pattern, made simpler 1.1378 - * because reordering is not allowed. 1.1379 - */ 1.1380 - for (currdesc = currentClassDesc, currclass = currentClass; 1.1381 - currdesc != null && currdesc.isSerializable(); /*sun.4296963 ibm.11861*/ 1.1382 - 1.1383 - currdesc = currdesc.getSuperclass()) { 1.1384 - 1.1385 - /* 1.1386 - * Search the classes to see if the class of this 1.1387 - * descriptor appears further up the hierarchy. Until 1.1388 - * it's found assume its an inserted class. If it's 1.1389 - * not found, its the descriptor's class that has been 1.1390 - * removed. 1.1391 - */ 1.1392 - Class cc = currdesc.forClass(); 1.1393 - Class cl; 1.1394 - for (cl = currclass; cl != null; cl = cl.getSuperclass()) { 1.1395 - if (cc == cl) { 1.1396 - // found a superclass that matches this descriptor 1.1397 - break; 1.1398 - } else { 1.1399 - /* Ignore a class that doesn't match. No 1.1400 - * action is needed since it is already 1.1401 - * initialized. 1.1402 - */ 1.1403 - } 1.1404 - } // end : for (cl = currclass; cl != null; cl = cl.getSuperclass()) 1.1405 - /* Test if there is room for this new entry. 1.1406 - * If not, double the size of the arrays and copy the contents. 1.1407 - */ 1.1408 - spClass++; 1.1409 - if (spClass >= classes.length) { 1.1410 - int newlen = classes.length * 2; 1.1411 - Class[] newclasses = new Class[newlen]; 1.1412 - ObjectStreamClass[] newclassdesc = new ObjectStreamClass[newlen]; 1.1413 - 1.1414 - System.arraycopy(classes, 0, 1.1415 - newclasses, 0, 1.1416 - classes.length); 1.1417 - System.arraycopy(classdesc, 0, 1.1418 - newclassdesc, 0, 1.1419 - classes.length); 1.1420 - 1.1421 - classes = newclasses; 1.1422 - classdesc = newclassdesc; 1.1423 - } 1.1424 - 1.1425 - if (cl == null) { 1.1426 - /* Class not found corresponding to this descriptor. 1.1427 - * Pop off all the extra classes pushed. 1.1428 - * Push the descriptor and a null class. 1.1429 - */ 1.1430 - classdesc[spClass] = currdesc; 1.1431 - classes[spClass] = null; 1.1432 - } else { 1.1433 - /* Current class descriptor matches current class. 1.1434 - * Some classes may have been inserted. 1.1435 - * Record the match and advance the class, continue 1.1436 - * with the next descriptor. 1.1437 - */ 1.1438 - classdesc[spClass] = currdesc; 1.1439 - classes[spClass] = cl; 1.1440 - currclass = cl.getSuperclass(); 1.1441 - } 1.1442 - } // end : for (currdesc = currentClassDesc, currclass = currentClass; 1.1443 - 1.1444 - /* Allocate a new object. 1.1445 - */ 1.1446 - try { 1.1447 - currentObject = (currentClass == null) ? 1.1448 - null : currentClassDesc.newInstance(); 1.1449 - 1.1450 - // Store this object and its beginning position 1.1451 - // since there might be indirections to it while 1.1452 - // it's been unmarshalled. 1.1453 - activeRecursionMgr.addObject(offset, currentObject); 1.1454 - } catch (InvocationTargetException e) { 1.1455 - InvalidClassException exc = new InvalidClassException( 1.1456 - currentClass.getName(), 1.1457 - "InvocationTargetException accessing no-arg constructor"); 1.1458 - exc.initCause( e ) ; 1.1459 - throw exc ; 1.1460 - } catch (UnsupportedOperationException e) { 1.1461 - InvalidClassException exc = new InvalidClassException( 1.1462 - currentClass.getName(), 1.1463 - "UnsupportedOperationException accessing no-arg constructor"); 1.1464 - exc.initCause( e ) ; 1.1465 - throw exc ; 1.1466 - } catch (InstantiationException e) { 1.1467 - InvalidClassException exc = new InvalidClassException( 1.1468 - currentClass.getName(), 1.1469 - "InstantiationException accessing no-arg constructor"); 1.1470 - exc.initCause( e ) ; 1.1471 - throw exc ; 1.1472 - } 1.1473 - 1.1474 - Enumeration fvdsList = getOrderedDescriptions(repositoryID, sender).elements(); 1.1475 - 1.1476 - while((fvdsList.hasMoreElements()) && (spClass > spBase)) { 1.1477 - FullValueDescription fvd = (FullValueDescription)fvdsList.nextElement(); 1.1478 - // d4365188: backward compatability 1.1479 - String repIDForFVD = vhandler.getClassName(fvd.id); 1.1480 - String repIDForClass = vhandler.getClassName(vhandler.getRMIRepositoryID(currentClass)); 1.1481 - 1.1482 - while ((spClass > spBase) && 1.1483 - (!repIDForFVD.equals(repIDForClass))) { 1.1484 - int pos = findNextClass(repIDForFVD, classes, spClass, spBase); 1.1485 - if (pos != -1) { 1.1486 - spClass = pos; 1.1487 - currclass = currentClass = classes[spClass]; 1.1488 - repIDForClass = vhandler.getClassName(vhandler.getRMIRepositoryID(currentClass)); 1.1489 - } 1.1490 - else { // Read and throw away one level of the fvdslist 1.1491 - 1.1492 - // This seems to mean that the sender had a superclass that 1.1493 - // we don't have 1.1494 - 1.1495 - if (fvd.is_custom) { 1.1496 - 1.1497 - readFormatVersion(); 1.1498 - boolean calledDefaultWriteObject = readBoolean(); 1.1499 - 1.1500 - if (calledDefaultWriteObject) 1.1501 - inputClassFields(null, null, null, fvd.members, sender); 1.1502 - 1.1503 - if (getStreamFormatVersion() == 2) { 1.1504 - 1.1505 - ((ValueInputStream)getOrbStream()).start_value(); 1.1506 - ((ValueInputStream)getOrbStream()).end_value(); 1.1507 - } 1.1508 - 1.1509 - // WARNING: If stream format version is 1 and there's 1.1510 - // optional data, we'll get some form of exception down 1.1511 - // the line or data corruption. 1.1512 - 1.1513 - } else { 1.1514 - 1.1515 - inputClassFields(null, currentClass, null, fvd.members, sender); 1.1516 - } 1.1517 - 1.1518 - if (fvdsList.hasMoreElements()){ 1.1519 - fvd = (FullValueDescription)fvdsList.nextElement(); 1.1520 - repIDForFVD = vhandler.getClassName(fvd.id); 1.1521 - } 1.1522 - else return currentObject; 1.1523 - } 1.1524 - } 1.1525 - 1.1526 - currdesc = currentClassDesc = ObjectStreamClass.lookup(currentClass); 1.1527 - 1.1528 - if (!repIDForClass.equals("java.lang.Object")) { 1.1529 - 1.1530 - // If the sender used custom marshaling, then it should have put 1.1531 - // the two bytes on the wire indicating stream format version 1.1532 - // and whether or not the writeObject method called 1.1533 - // defaultWriteObject/writeFields. 1.1534 - 1.1535 - ReadObjectState oldState = readObjectState; 1.1536 - setState(DEFAULT_STATE); 1.1537 - 1.1538 - try { 1.1539 - 1.1540 - if (fvd.is_custom) { 1.1541 - 1.1542 - // Read format version 1.1543 - readFormatVersion(); 1.1544 - 1.1545 - // Read defaultWriteObject indicator 1.1546 - boolean calledDefaultWriteObject = readBoolean(); 1.1547 - 1.1548 - readObjectState.beginUnmarshalCustomValue(this, 1.1549 - calledDefaultWriteObject, 1.1550 - (currentClassDesc.readObjectMethod 1.1551 - != null)); 1.1552 - } 1.1553 - 1.1554 - boolean usedReadObject = false; 1.1555 - 1.1556 - // Always use readObject if it exists, and fall back to default 1.1557 - // unmarshaling if it doesn't. 1.1558 - try { 1.1559 - 1.1560 - if (!fvd.is_custom && currentClassDesc.hasReadObject()) 1.1561 - setState(IN_READ_OBJECT_REMOTE_NOT_CUSTOM_MARSHALED); 1.1562 - 1.1563 - // See the definition of defaultReadObjectFVDMembers 1.1564 - // for more information. This concerns making sure 1.1565 - // we use the remote FVD's members in defaultReadObject. 1.1566 - defaultReadObjectFVDMembers = fvd.members; 1.1567 - usedReadObject = invokeObjectReader(currentClassDesc, 1.1568 - currentObject, 1.1569 - currentClass); 1.1570 - 1.1571 - } finally { 1.1572 - defaultReadObjectFVDMembers = null; 1.1573 - } 1.1574 - 1.1575 - // Note that the !usedReadObject !calledDefaultWriteObject 1.1576 - // case is handled by the beginUnmarshalCustomValue method 1.1577 - // of the default state 1.1578 - if (!usedReadObject || readObjectState == IN_READ_OBJECT_DEFAULTS_SENT) 1.1579 - inputClassFields(currentObject, currentClass, currdesc, fvd.members, sender); 1.1580 - 1.1581 - if (fvd.is_custom) 1.1582 - readObjectState.endUnmarshalCustomValue(this); 1.1583 - 1.1584 - } finally { 1.1585 - setState(oldState); 1.1586 - } 1.1587 - 1.1588 - currclass = currentClass = classes[--spClass]; 1.1589 - 1.1590 - } else { 1.1591 - 1.1592 - // The remaining hierarchy of the local class does not match the sender's FVD. 1.1593 - // So, use remaining FVDs to read data off wire. If any remaining FVDs indicate 1.1594 - // custom marshaling, throw MARSHAL error. 1.1595 - inputClassFields(null, currentClass, null, fvd.members, sender); 1.1596 - 1.1597 - while (fvdsList.hasMoreElements()){ 1.1598 - fvd = (FullValueDescription)fvdsList.nextElement(); 1.1599 - 1.1600 - if (fvd.is_custom) 1.1601 - skipCustomUsingFVD(fvd.members, sender); 1.1602 - else 1.1603 - inputClassFields(null, currentClass, null, fvd.members, sender); 1.1604 - } 1.1605 - 1.1606 - } 1.1607 - 1.1608 - } // end : while(fvdsList.hasMoreElements()) 1.1609 - while (fvdsList.hasMoreElements()){ 1.1610 - 1.1611 - FullValueDescription fvd = (FullValueDescription)fvdsList.nextElement(); 1.1612 - if (fvd.is_custom) 1.1613 - skipCustomUsingFVD(fvd.members, sender); 1.1614 - else 1.1615 - throwAwayData(fvd.members, sender); 1.1616 - } 1.1617 - } 1.1618 - 1.1619 - return currentObject; 1.1620 - } 1.1621 - finally { 1.1622 - // Make sure we exit at the same stack level as when we started. 1.1623 - spClass = spBase; 1.1624 - 1.1625 - // We've completed deserializing this object. Any 1.1626 - // future indirections will be handled correctly at the 1.1627 - // CDR level. The ActiveRecursionManager only deals with 1.1628 - // objects currently being deserialized. 1.1629 - activeRecursionMgr.removeObject(offset); 1.1630 - } 1.1631 - 1.1632 - } 1.1633 - 1.1634 - /** 1.1635 - * This input method uses FullValueDescriptions retrieved from the sender's runtime to 1.1636 - * read in the data. This method is capable of throwing out data not applicable to client's fields. 1.1637 - * 1.1638 - * NOTE : If the local description indicates custom marshaling and the remote type's FVD also 1.1639 - * indicates custom marsahling than the local type is used to read the data off the wire. However, 1.1640 - * if either says custom while the other does not, a MARSHAL error is thrown. Externalizable is 1.1641 - * a form of custom marshaling. 1.1642 - * 1.1643 - */ 1.1644 - private Object skipObjectUsingFVD(String repositoryID, 1.1645 - com.sun.org.omg.SendingContext.CodeBase sender) 1.1646 - throws IOException, ClassNotFoundException 1.1647 - { 1.1648 - 1.1649 - Enumeration fvdsList = getOrderedDescriptions(repositoryID, sender).elements(); 1.1650 - 1.1651 - while(fvdsList.hasMoreElements()) { 1.1652 - FullValueDescription fvd = (FullValueDescription)fvdsList.nextElement(); 1.1653 - String repIDForFVD = vhandler.getClassName(fvd.id); 1.1654 - 1.1655 - if (!repIDForFVD.equals("java.lang.Object")) { 1.1656 - if (fvd.is_custom) { 1.1657 - 1.1658 - readFormatVersion(); 1.1659 - 1.1660 - boolean calledDefaultWriteObject = readBoolean(); 1.1661 - 1.1662 - if (calledDefaultWriteObject) 1.1663 - inputClassFields(null, null, null, fvd.members, sender); 1.1664 - 1.1665 - if (getStreamFormatVersion() == 2) { 1.1666 - 1.1667 - ((ValueInputStream)getOrbStream()).start_value(); 1.1668 - ((ValueInputStream)getOrbStream()).end_value(); 1.1669 - } 1.1670 - 1.1671 - // WARNING: If stream format version is 1 and there's 1.1672 - // optional data, we'll get some form of exception down 1.1673 - // the line. 1.1674 - 1.1675 - } else { 1.1676 - // Use default marshaling 1.1677 - inputClassFields(null, null, null, fvd.members, sender); 1.1678 - } 1.1679 - } 1.1680 - 1.1681 - } // end : while(fvdsList.hasMoreElements()) 1.1682 - return null; 1.1683 - 1.1684 - } 1.1685 - 1.1686 - /////////////////// 1.1687 - 1.1688 - private int findNextClass(String classname, Class classes[], int _spClass, int _spBase){ 1.1689 - 1.1690 - for (int i = _spClass; i > _spBase; i--){ 1.1691 - if (classname.equals(classes[i].getName())) { 1.1692 - return i; 1.1693 - } 1.1694 - } 1.1695 - 1.1696 - return -1; 1.1697 - } 1.1698 - 1.1699 - /* 1.1700 - * Invoke the readObject method if present. Assumes that in the case of custom 1.1701 - * marshaling, the format version and defaultWriteObject indicator were already 1.1702 - * removed. 1.1703 - */ 1.1704 - private boolean invokeObjectReader(ObjectStreamClass osc, Object obj, Class aclass) 1.1705 - throws InvalidClassException, StreamCorruptedException, 1.1706 - ClassNotFoundException, IOException 1.1707 - { 1.1708 - if (osc.readObjectMethod == null) { 1.1709 - return false; 1.1710 - } 1.1711 - 1.1712 - try { 1.1713 - osc.readObjectMethod.invoke( obj, readObjectArgList ) ; 1.1714 - return true; 1.1715 - } catch (InvocationTargetException e) { 1.1716 - Throwable t = e.getTargetException(); 1.1717 - if (t instanceof ClassNotFoundException) 1.1718 - throw (ClassNotFoundException)t; 1.1719 - else if (t instanceof IOException) 1.1720 - throw (IOException)t; 1.1721 - else if (t instanceof RuntimeException) 1.1722 - throw (RuntimeException) t; 1.1723 - else if (t instanceof Error) 1.1724 - throw (Error) t; 1.1725 - else 1.1726 - // XXX I18N, logging needed. 1.1727 - throw new Error("internal error"); 1.1728 - } catch (IllegalAccessException e) { 1.1729 - return false; 1.1730 - } 1.1731 - } 1.1732 - 1.1733 - /* 1.1734 - * Reset the stream to be just like it was after the constructor. 1.1735 - */ 1.1736 - private void resetStream() throws IOException { 1.1737 - 1.1738 - if (classes == null) 1.1739 - classes = new Class[20]; 1.1740 - else { 1.1741 - for (int i = 0; i < classes.length; i++) 1.1742 - classes[i] = null; 1.1743 - } 1.1744 - if (classdesc == null) 1.1745 - classdesc = new ObjectStreamClass[20]; 1.1746 - else { 1.1747 - for (int i = 0; i < classdesc.length; i++) 1.1748 - classdesc[i] = null; 1.1749 - } 1.1750 - spClass = 0; 1.1751 - 1.1752 - if (callbacks != null) 1.1753 - callbacks.setSize(0); // discard any pending callbacks 1.1754 - } 1.1755 - 1.1756 - /** 1.1757 - * Factored out of inputClassFields This reads a primitive value and sets it 1.1758 - * in the field of o described by the ObjectStreamField field. 1.1759 - * 1.1760 - * Note that reflection cannot be used here, because reflection cannot be used 1.1761 - * to set final fields. 1.1762 - */ 1.1763 - private void inputPrimitiveField(Object o, Class cl, ObjectStreamField field) 1.1764 - throws InvalidClassException, IOException { 1.1765 - 1.1766 - try { 1.1767 - switch (field.getTypeCode()) { 1.1768 - case 'B': 1.1769 - byte byteValue = orbStream.read_octet(); 1.1770 - bridge.putByte( o, field.getFieldID(), byteValue ) ; 1.1771 - //reflective code: field.getField().setByte( o, byteValue ) ; 1.1772 - break; 1.1773 - case 'Z': 1.1774 - boolean booleanValue = orbStream.read_boolean(); 1.1775 - bridge.putBoolean( o, field.getFieldID(), booleanValue ) ; 1.1776 - //reflective code: field.getField().setBoolean( o, booleanValue ) ; 1.1777 - break; 1.1778 - case 'C': 1.1779 - char charValue = orbStream.read_wchar(); 1.1780 - bridge.putChar( o, field.getFieldID(), charValue ) ; 1.1781 - //reflective code: field.getField().setChar( o, charValue ) ; 1.1782 - break; 1.1783 - case 'S': 1.1784 - short shortValue = orbStream.read_short(); 1.1785 - bridge.putShort( o, field.getFieldID(), shortValue ) ; 1.1786 - //reflective code: field.getField().setShort( o, shortValue ) ; 1.1787 - break; 1.1788 - case 'I': 1.1789 - int intValue = orbStream.read_long(); 1.1790 - bridge.putInt( o, field.getFieldID(), intValue ) ; 1.1791 - //reflective code: field.getField().setInt( o, intValue ) ; 1.1792 - break; 1.1793 - case 'J': 1.1794 - long longValue = orbStream.read_longlong(); 1.1795 - bridge.putLong( o, field.getFieldID(), longValue ) ; 1.1796 - //reflective code: field.getField().setLong( o, longValue ) ; 1.1797 - break; 1.1798 - case 'F' : 1.1799 - float floatValue = orbStream.read_float(); 1.1800 - bridge.putFloat( o, field.getFieldID(), floatValue ) ; 1.1801 - //reflective code: field.getField().setFloat( o, floatValue ) ; 1.1802 - break; 1.1803 - case 'D' : 1.1804 - double doubleValue = orbStream.read_double(); 1.1805 - bridge.putDouble( o, field.getFieldID(), doubleValue ) ; 1.1806 - //reflective code: field.getField().setDouble( o, doubleValue ) ; 1.1807 - break; 1.1808 - default: 1.1809 - // XXX I18N, logging needed. 1.1810 - throw new InvalidClassException(cl.getName()); 1.1811 - } 1.1812 - } catch (IllegalArgumentException e) { 1.1813 - /* This case should never happen. If the field types 1.1814 - are not the same, InvalidClassException is raised when 1.1815 - matching the local class to the serialized ObjectStreamClass. */ 1.1816 - ClassCastException cce = new ClassCastException("Assigning instance of class " + 1.1817 - field.getType().getName() + 1.1818 - " to field " + 1.1819 - currentClassDesc.getName() + '#' + 1.1820 - field.getField().getName()); 1.1821 - cce.initCause( e ) ; 1.1822 - throw cce ; 1.1823 - } 1.1824 - } 1.1825 - 1.1826 - private Object inputObjectField(org.omg.CORBA.ValueMember field, 1.1827 - com.sun.org.omg.SendingContext.CodeBase sender) 1.1828 - throws IndirectionException, ClassNotFoundException, IOException, 1.1829 - StreamCorruptedException { 1.1830 - 1.1831 - Object objectValue = null; 1.1832 - Class type = null; 1.1833 - String id = field.id; 1.1834 - 1.1835 - try { 1.1836 - type = vhandler.getClassFromType(id); 1.1837 - } catch(ClassNotFoundException cnfe) { 1.1838 - // Make sure type = null 1.1839 - type = null; 1.1840 - } 1.1841 - 1.1842 - String signature = null; 1.1843 - if (type != null) 1.1844 - signature = ValueUtility.getSignature(field); 1.1845 - 1.1846 - if (signature != null && (signature.equals("Ljava/lang/Object;") || 1.1847 - signature.equals("Ljava/io/Serializable;") || 1.1848 - signature.equals("Ljava/io/Externalizable;"))) { 1.1849 - objectValue = javax.rmi.CORBA.Util.readAny(orbStream); 1.1850 - } else { 1.1851 - // Decide what method call to make based on the type. If 1.1852 - // it is a type for which we need to load a stub, convert 1.1853 - // the type to the correct stub type. 1.1854 - // 1.1855 - // NOTE : Since FullValueDescription does not allow us 1.1856 - // to ask whether something is an interface we do not 1.1857 - // have the ability to optimize this check. 1.1858 - 1.1859 - int callType = ValueHandlerImpl.kValueType; 1.1860 - 1.1861 - if (!vhandler.isSequence(id)) { 1.1862 - 1.1863 - if (field.type.kind().value() == kRemoteTypeCode.kind().value()) { 1.1864 - 1.1865 - // RMI Object reference... 1.1866 - callType = ValueHandlerImpl.kRemoteType; 1.1867 - 1.1868 - } else { 1.1869 - 1.1870 - // REVISIT. If we don't have the local class, 1.1871 - // we should probably verify that it's an RMI type, 1.1872 - // query the remote FVD, and use is_abstract. 1.1873 - // Our FVD seems to get NullPointerExceptions for any 1.1874 - // non-RMI types. 1.1875 - 1.1876 - // This uses the local class in the same way as 1.1877 - // inputObjectField(ObjectStreamField) does. REVISIT 1.1878 - // inputObjectField(ObjectStreamField)'s loadStubClass 1.1879 - // logic. Assumption is that the given type cannot 1.1880 - // evolve to become a CORBA abstract interface or 1.1881 - // a RMI abstract interface. 1.1882 - 1.1883 - if (type != null && type.isInterface() && 1.1884 - (vhandler.isAbstractBase(type) || 1.1885 - ObjectStreamClassCorbaExt.isAbstractInterface(type))) { 1.1886 - 1.1887 - callType = ValueHandlerImpl.kAbstractType; 1.1888 - } 1.1889 - } 1.1890 - } 1.1891 - 1.1892 - // Now that we have used the FVD of the field to determine the proper course 1.1893 - // of action, it is ok to use the type (Class) from this point forward since 1.1894 - // the rep. id for this read will also follow on the wire. 1.1895 - 1.1896 - switch (callType) { 1.1897 - case ValueHandlerImpl.kRemoteType: 1.1898 - if (type != null) 1.1899 - objectValue = Utility.readObjectAndNarrow(orbStream, type); 1.1900 - else 1.1901 - objectValue = orbStream.read_Object(); 1.1902 - break; 1.1903 - case ValueHandlerImpl.kAbstractType: 1.1904 - if (type != null) 1.1905 - objectValue = Utility.readAbstractAndNarrow(orbStream, type); 1.1906 - else 1.1907 - objectValue = orbStream.read_abstract_interface(); 1.1908 - break; 1.1909 - case ValueHandlerImpl.kValueType: 1.1910 - if (type != null) 1.1911 - objectValue = orbStream.read_value(type); 1.1912 - else 1.1913 - objectValue = orbStream.read_value(); 1.1914 - break; 1.1915 - default: 1.1916 - // XXX I18N, logging needed. 1.1917 - throw new StreamCorruptedException("Unknown callType: " + callType); 1.1918 - } 1.1919 - } 1.1920 - 1.1921 - return objectValue; 1.1922 - } 1.1923 - 1.1924 - /** 1.1925 - * Factored out of inputClassFields and reused in 1.1926 - * inputCurrentClassFieldsForReadFields. 1.1927 - * 1.1928 - * Reads the field (which of an Object type as opposed to a primitive) 1.1929 - * described by ObjectStreamField field and returns it. 1.1930 - */ 1.1931 - private Object inputObjectField(ObjectStreamField field) 1.1932 - throws InvalidClassException, StreamCorruptedException, 1.1933 - ClassNotFoundException, IndirectionException, IOException { 1.1934 - 1.1935 - if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { 1.1936 - return javax.rmi.CORBA.Util.readAny(orbStream); 1.1937 - } 1.1938 - 1.1939 - Object objectValue = null; 1.1940 - 1.1941 - // fields have an API to provide the actual class 1.1942 - // corresponding to the data type 1.1943 - // Class type = osc.forClass(); 1.1944 - Class fieldType = field.getType(); 1.1945 - Class actualType = fieldType; // This may change if stub loaded. 1.1946 - 1.1947 - // Decide what method call to make based on the fieldType. If 1.1948 - // it is a type for which we need to load a stub, convert 1.1949 - // the type to the correct stub type. 1.1950 - 1.1951 - int callType = ValueHandlerImpl.kValueType; 1.1952 - boolean narrow = false; 1.1953 - 1.1954 - if (fieldType.isInterface()) { 1.1955 - boolean loadStubClass = false; 1.1956 - 1.1957 - if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { 1.1958 - 1.1959 - // RMI Object reference... 1.1960 - callType = ValueHandlerImpl.kRemoteType; 1.1961 - 1.1962 - } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ 1.1963 - 1.1964 - // IDL Object reference... 1.1965 - callType = ValueHandlerImpl.kRemoteType; 1.1966 - loadStubClass = true; 1.1967 - 1.1968 - } else if (vhandler.isAbstractBase(fieldType)) { 1.1969 - // IDL Abstract Object reference... 1.1970 - 1.1971 - callType = ValueHandlerImpl.kAbstractType; 1.1972 - loadStubClass = true; 1.1973 - } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { 1.1974 - // RMI Abstract Object reference... 1.1975 - 1.1976 - callType = ValueHandlerImpl.kAbstractType; 1.1977 - } 1.1978 - 1.1979 - if (loadStubClass) { 1.1980 - try { 1.1981 - String codebase = Util.getCodebase(fieldType); 1.1982 - String repID = vhandler.createForAnyType(fieldType); 1.1983 - Class stubType = 1.1984 - Utility.loadStubClass(repID, codebase, fieldType); 1.1985 - actualType = stubType; 1.1986 - } catch (ClassNotFoundException e) { 1.1987 - narrow = true; 1.1988 - } 1.1989 - } else { 1.1990 - narrow = true; 1.1991 - } 1.1992 - } 1.1993 - 1.1994 - switch (callType) { 1.1995 - case ValueHandlerImpl.kRemoteType: 1.1996 - if (!narrow) 1.1997 - objectValue = (Object)orbStream.read_Object(actualType); 1.1998 - else 1.1999 - objectValue = Utility.readObjectAndNarrow(orbStream, actualType); 1.2000 - break; 1.2001 - case ValueHandlerImpl.kAbstractType: 1.2002 - if (!narrow) 1.2003 - objectValue = (Object)orbStream.read_abstract_interface(actualType); 1.2004 - else 1.2005 - objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); 1.2006 - break; 1.2007 - case ValueHandlerImpl.kValueType: 1.2008 - objectValue = (Object)orbStream.read_value(actualType); 1.2009 - break; 1.2010 - default: 1.2011 - // XXX I18N, logging needed. 1.2012 - throw new StreamCorruptedException("Unknown callType: " + callType); 1.2013 - } 1.2014 - 1.2015 - return objectValue; 1.2016 - } 1.2017 - 1.2018 - private final boolean mustUseRemoteValueMembers() { 1.2019 - return defaultReadObjectFVDMembers != null; 1.2020 - } 1.2021 - 1.2022 - void readFields(java.util.Map fieldToValueMap) 1.2023 - throws InvalidClassException, StreamCorruptedException, 1.2024 - ClassNotFoundException, IOException { 1.2025 - 1.2026 - if (mustUseRemoteValueMembers()) { 1.2027 - inputRemoteMembersForReadFields(fieldToValueMap); 1.2028 - } else 1.2029 - inputCurrentClassFieldsForReadFields(fieldToValueMap); 1.2030 - } 1.2031 - 1.2032 - private final void inputRemoteMembersForReadFields(java.util.Map fieldToValueMap) 1.2033 - throws InvalidClassException, StreamCorruptedException, 1.2034 - ClassNotFoundException, IOException { 1.2035 - 1.2036 - // Must have this local variable since defaultReadObjectFVDMembers 1.2037 - // may get mangled by recursion. 1.2038 - ValueMember fields[] = defaultReadObjectFVDMembers; 1.2039 - 1.2040 - try { 1.2041 - 1.2042 - for (int i = 0; i < fields.length; i++) { 1.2043 - 1.2044 - switch (fields[i].type.kind().value()) { 1.2045 - 1.2046 - case TCKind._tk_octet: 1.2047 - byte byteValue = orbStream.read_octet(); 1.2048 - fieldToValueMap.put(fields[i].name, new Byte(byteValue)); 1.2049 - break; 1.2050 - case TCKind._tk_boolean: 1.2051 - boolean booleanValue = orbStream.read_boolean(); 1.2052 - fieldToValueMap.put(fields[i].name, new Boolean(booleanValue)); 1.2053 - break; 1.2054 - case TCKind._tk_char: 1.2055 - // Backwards compatibility. Older Sun ORBs sent 1.2056 - // _tk_char even though they read and wrote wchars 1.2057 - // correctly. 1.2058 - // 1.2059 - // Fall through to the _tk_wchar case. 1.2060 - case TCKind._tk_wchar: 1.2061 - char charValue = orbStream.read_wchar(); 1.2062 - fieldToValueMap.put(fields[i].name, new Character(charValue)); 1.2063 - break; 1.2064 - case TCKind._tk_short: 1.2065 - short shortValue = orbStream.read_short(); 1.2066 - fieldToValueMap.put(fields[i].name, new Short(shortValue)); 1.2067 - break; 1.2068 - case TCKind._tk_long: 1.2069 - int intValue = orbStream.read_long(); 1.2070 - fieldToValueMap.put(fields[i].name, new Integer(intValue)); 1.2071 - break; 1.2072 - case TCKind._tk_longlong: 1.2073 - long longValue = orbStream.read_longlong(); 1.2074 - fieldToValueMap.put(fields[i].name, new Long(longValue)); 1.2075 - break; 1.2076 - case TCKind._tk_float: 1.2077 - float floatValue = orbStream.read_float(); 1.2078 - fieldToValueMap.put(fields[i].name, new Float(floatValue)); 1.2079 - break; 1.2080 - case TCKind._tk_double: 1.2081 - double doubleValue = orbStream.read_double(); 1.2082 - fieldToValueMap.put(fields[i].name, new Double(doubleValue)); 1.2083 - break; 1.2084 - case TCKind._tk_value: 1.2085 - case TCKind._tk_objref: 1.2086 - case TCKind._tk_value_box: 1.2087 - Object objectValue = null; 1.2088 - try { 1.2089 - objectValue = inputObjectField(fields[i], 1.2090 - cbSender); 1.2091 - 1.2092 - } catch (IndirectionException cdrie) { 1.2093 - // The CDR stream had never seen the given offset before, 1.2094 - // so check the recursion manager (it will throw an 1.2095 - // IOException if it doesn't have a reference, either). 1.2096 - objectValue = activeRecursionMgr.getObject(cdrie.offset); 1.2097 - } 1.2098 - 1.2099 - fieldToValueMap.put(fields[i].name, objectValue); 1.2100 - break; 1.2101 - default: 1.2102 - // XXX I18N, logging needed. 1.2103 - throw new StreamCorruptedException("Unknown kind: " 1.2104 - + fields[i].type.kind().value()); 1.2105 - } 1.2106 - } 1.2107 - } catch (Throwable t) { 1.2108 - StreamCorruptedException result = new StreamCorruptedException(t.getMessage()); 1.2109 - result.initCause(t); 1.2110 - throw result; 1.2111 - } 1.2112 - } 1.2113 - 1.2114 - /** 1.2115 - * Called from InputStreamHook. 1.2116 - * 1.2117 - * Reads the fields of the current class (could be the ones 1.2118 - * queried from the remote FVD) and puts them in 1.2119 - * the given Map, name to value. Wraps primitives in the 1.2120 - * corresponding java.lang Objects. 1.2121 - */ 1.2122 - private final void inputCurrentClassFieldsForReadFields(java.util.Map fieldToValueMap) 1.2123 - throws InvalidClassException, StreamCorruptedException, 1.2124 - ClassNotFoundException, IOException { 1.2125 - 1.2126 - ObjectStreamField[] fields = currentClassDesc.getFieldsNoCopy(); 1.2127 - 1.2128 - int primFields = fields.length - currentClassDesc.objFields; 1.2129 - 1.2130 - // Handle the primitives first 1.2131 - for (int i = 0; i < primFields; ++i) { 1.2132 - 1.2133 - switch (fields[i].getTypeCode()) { 1.2134 - case 'B': 1.2135 - byte byteValue = orbStream.read_octet(); 1.2136 - fieldToValueMap.put(fields[i].getName(), 1.2137 - new Byte(byteValue)); 1.2138 - break; 1.2139 - case 'Z': 1.2140 - boolean booleanValue = orbStream.read_boolean(); 1.2141 - fieldToValueMap.put(fields[i].getName(), 1.2142 - new Boolean(booleanValue)); 1.2143 - break; 1.2144 - case 'C': 1.2145 - char charValue = orbStream.read_wchar(); 1.2146 - fieldToValueMap.put(fields[i].getName(), 1.2147 - new Character(charValue)); 1.2148 - break; 1.2149 - case 'S': 1.2150 - short shortValue = orbStream.read_short(); 1.2151 - fieldToValueMap.put(fields[i].getName(), 1.2152 - new Short(shortValue)); 1.2153 - break; 1.2154 - case 'I': 1.2155 - int intValue = orbStream.read_long(); 1.2156 - fieldToValueMap.put(fields[i].getName(), 1.2157 - new Integer(intValue)); 1.2158 - break; 1.2159 - case 'J': 1.2160 - long longValue = orbStream.read_longlong(); 1.2161 - fieldToValueMap.put(fields[i].getName(), 1.2162 - new Long(longValue)); 1.2163 - break; 1.2164 - case 'F' : 1.2165 - float floatValue = orbStream.read_float(); 1.2166 - fieldToValueMap.put(fields[i].getName(), 1.2167 - new Float(floatValue)); 1.2168 - break; 1.2169 - case 'D' : 1.2170 - double doubleValue = orbStream.read_double(); 1.2171 - fieldToValueMap.put(fields[i].getName(), 1.2172 - new Double(doubleValue)); 1.2173 - break; 1.2174 - default: 1.2175 - // XXX I18N, logging needed. 1.2176 - throw new InvalidClassException(currentClassDesc.getName()); 1.2177 - } 1.2178 - } 1.2179 - 1.2180 - /* Read and set object fields from the input stream. */ 1.2181 - if (currentClassDesc.objFields > 0) { 1.2182 - for (int i = primFields; i < fields.length; i++) { 1.2183 - Object objectValue = null; 1.2184 - try { 1.2185 - objectValue = inputObjectField(fields[i]); 1.2186 - } catch(IndirectionException cdrie) { 1.2187 - // The CDR stream had never seen the given offset before, 1.2188 - // so check the recursion manager (it will throw an 1.2189 - // IOException if it doesn't have a reference, either). 1.2190 - objectValue = activeRecursionMgr.getObject(cdrie.offset); 1.2191 - } 1.2192 - 1.2193 - fieldToValueMap.put(fields[i].getName(), objectValue); 1.2194 - } 1.2195 - } 1.2196 - } 1.2197 - 1.2198 - /* 1.2199 - * Read the fields of the specified class from the input stream and set 1.2200 - * the values of the fields in the specified object. If the specified 1.2201 - * object is null, just consume the fields without setting any values. If 1.2202 - * any ObjectStreamField does not have a reflected Field, don't try to set 1.2203 - * that field in the object. 1.2204 - * 1.2205 - * REVISIT -- This code doesn't do what the comment says to when 1.2206 - * getField() is null! 1.2207 - */ 1.2208 - private void inputClassFields(Object o, Class cl, 1.2209 - ObjectStreamField[] fields, 1.2210 - com.sun.org.omg.SendingContext.CodeBase sender) 1.2211 - throws InvalidClassException, StreamCorruptedException, 1.2212 - ClassNotFoundException, IOException 1.2213 - { 1.2214 - 1.2215 - int primFields = fields.length - currentClassDesc.objFields; 1.2216 - 1.2217 - if (o != null) { 1.2218 - for (int i = 0; i < primFields; ++i) { 1.2219 - if (fields[i].getField() == null) 1.2220 - continue; 1.2221 - 1.2222 - inputPrimitiveField(o, cl, fields[i]); 1.2223 - } 1.2224 - } 1.2225 - 1.2226 - /* Read and set object fields from the input stream. */ 1.2227 - if (currentClassDesc.objFields > 0) { 1.2228 - for (int i = primFields; i < fields.length; i++) { 1.2229 - Object objectValue = null; 1.2230 - 1.2231 - try { 1.2232 - objectValue = inputObjectField(fields[i]); 1.2233 - } catch(IndirectionException cdrie) { 1.2234 - // The CDR stream had never seen the given offset before, 1.2235 - // so check the recursion manager (it will throw an 1.2236 - // IOException if it doesn't have a reference, either). 1.2237 - objectValue = activeRecursionMgr.getObject(cdrie.offset); 1.2238 - } 1.2239 - 1.2240 - if ((o == null) || (fields[i].getField() == null)) { 1.2241 - continue; 1.2242 - } 1.2243 - 1.2244 - try { 1.2245 - bridge.putObject( o, fields[i].getFieldID(), objectValue ) ; 1.2246 - // reflective code: fields[i].getField().set( o, objectValue ) ; 1.2247 - } catch (IllegalArgumentException e) { 1.2248 - ClassCastException exc = new ClassCastException("Assigning instance of class " + 1.2249 - objectValue.getClass().getName() + 1.2250 - " to field " + 1.2251 - currentClassDesc.getName() + 1.2252 - '#' + 1.2253 - fields[i].getField().getName()); 1.2254 - exc.initCause( e ) ; 1.2255 - throw exc ; 1.2256 - } 1.2257 - } // end : for loop 1.2258 - } 1.2259 - } 1.2260 - 1.2261 - /* 1.2262 - * Read the fields of the specified class from the input stream and set 1.2263 - * the values of the fields in the specified object. If the specified 1.2264 - * object is null, just consume the fields without setting any values. If 1.2265 - * any ObjectStreamField does not have a reflected Field, don't try to set 1.2266 - * that field in the object. 1.2267 - */ 1.2268 - private void inputClassFields(Object o, Class cl, 1.2269 - ObjectStreamClass osc, 1.2270 - ValueMember[] fields, 1.2271 - com.sun.org.omg.SendingContext.CodeBase sender) 1.2272 - throws InvalidClassException, StreamCorruptedException, 1.2273 - ClassNotFoundException, IOException 1.2274 - { 1.2275 - try{ 1.2276 - for (int i = 0; i < fields.length; ++i) { 1.2277 - try { 1.2278 - switch (fields[i].type.kind().value()) { 1.2279 - case TCKind._tk_octet: 1.2280 - byte byteValue = orbStream.read_octet(); 1.2281 - if ((o != null) && osc.hasField(fields[i])) 1.2282 - setByteField(o, cl, fields[i].name, byteValue); 1.2283 - break; 1.2284 - case TCKind._tk_boolean: 1.2285 - boolean booleanValue = orbStream.read_boolean(); 1.2286 - if ((o != null) && osc.hasField(fields[i])) 1.2287 - setBooleanField(o, cl, fields[i].name, booleanValue); 1.2288 - break; 1.2289 - case TCKind._tk_char: 1.2290 - // Backwards compatibility. Older Sun ORBs sent 1.2291 - // _tk_char even though they read and wrote wchars 1.2292 - // correctly. 1.2293 - // 1.2294 - // Fall through to the _tk_wchar case. 1.2295 - case TCKind._tk_wchar: 1.2296 - char charValue = orbStream.read_wchar(); 1.2297 - if ((o != null) && osc.hasField(fields[i])) 1.2298 - setCharField(o, cl, fields[i].name, charValue); 1.2299 - break; 1.2300 - case TCKind._tk_short: 1.2301 - short shortValue = orbStream.read_short(); 1.2302 - if ((o != null) && osc.hasField(fields[i])) 1.2303 - setShortField(o, cl, fields[i].name, shortValue); 1.2304 - break; 1.2305 - case TCKind._tk_long: 1.2306 - int intValue = orbStream.read_long(); 1.2307 - if ((o != null) && osc.hasField(fields[i])) 1.2308 - setIntField(o, cl, fields[i].name, intValue); 1.2309 - break; 1.2310 - case TCKind._tk_longlong: 1.2311 - long longValue = orbStream.read_longlong(); 1.2312 - if ((o != null) && osc.hasField(fields[i])) 1.2313 - setLongField(o, cl, fields[i].name, longValue); 1.2314 - break; 1.2315 - case TCKind._tk_float: 1.2316 - float floatValue = orbStream.read_float(); 1.2317 - if ((o != null) && osc.hasField(fields[i])) 1.2318 - setFloatField(o, cl, fields[i].name, floatValue); 1.2319 - break; 1.2320 - case TCKind._tk_double: 1.2321 - double doubleValue = orbStream.read_double(); 1.2322 - if ((o != null) && osc.hasField(fields[i])) 1.2323 - setDoubleField(o, cl, fields[i].name, doubleValue); 1.2324 - break; 1.2325 - case TCKind._tk_value: 1.2326 - case TCKind._tk_objref: 1.2327 - case TCKind._tk_value_box: 1.2328 - Object objectValue = null; 1.2329 - try { 1.2330 - objectValue = inputObjectField(fields[i], sender); 1.2331 - } catch (IndirectionException cdrie) { 1.2332 - // The CDR stream had never seen the given offset before, 1.2333 - // so check the recursion manager (it will throw an 1.2334 - // IOException if it doesn't have a reference, either). 1.2335 - objectValue = activeRecursionMgr.getObject(cdrie.offset); 1.2336 - } 1.2337 - 1.2338 - if (o == null) 1.2339 - continue; 1.2340 - try { 1.2341 - if (osc.hasField(fields[i])){ 1.2342 - setObjectField(o, 1.2343 - cl, 1.2344 - fields[i].name, 1.2345 - objectValue); 1.2346 - } else { 1.2347 - // REVISIT. Convert to a log message. 1.2348 - // This is a normal case when fields have 1.2349 - // been added as part of evolution, but 1.2350 - // silently skipping can make it hard to 1.2351 - // debug if there's an error 1.2352 -// System.out.println("**** warning, not setting field: " 1.2353 -// + fields[i].name 1.2354 -// + " since not on class " 1.2355 -// + osc.getName()); 1.2356 - 1.2357 - } 1.2358 - } catch (IllegalArgumentException e) { 1.2359 - // XXX I18N, logging needed. 1.2360 - ClassCastException cce = new ClassCastException("Assigning instance of class " + 1.2361 - objectValue.getClass().getName() + " to field " + fields[i].name); 1.2362 - cce.initCause(e) ; 1.2363 - throw cce ; 1.2364 - } 1.2365 - break; 1.2366 - default: 1.2367 - // XXX I18N, logging needed. 1.2368 - throw new StreamCorruptedException("Unknown kind: " 1.2369 - + fields[i].type.kind().value()); 1.2370 - } 1.2371 - } catch (IllegalArgumentException e) { 1.2372 - /* This case should never happen. If the field types 1.2373 - are not the same, InvalidClassException is raised when 1.2374 - matching the local class to the serialized ObjectStreamClass. */ 1.2375 - // XXX I18N, logging needed. 1.2376 - ClassCastException cce = new ClassCastException("Assigning instance of class " + fields[i].id + 1.2377 - " to field " + currentClassDesc.getName() + '#' + fields[i].name); 1.2378 - cce.initCause( e ) ; 1.2379 - throw cce ; 1.2380 - } 1.2381 - } 1.2382 - } catch(Throwable t){ 1.2383 - // XXX I18N, logging needed. 1.2384 - StreamCorruptedException sce = new StreamCorruptedException(t.getMessage()); 1.2385 - sce.initCause(t) ; 1.2386 - throw sce ; 1.2387 - } 1.2388 - } 1.2389 - 1.2390 - private void skipCustomUsingFVD(ValueMember[] fields, 1.2391 - com.sun.org.omg.SendingContext.CodeBase sender) 1.2392 - throws InvalidClassException, StreamCorruptedException, 1.2393 - ClassNotFoundException, IOException 1.2394 - { 1.2395 - readFormatVersion(); 1.2396 - boolean calledDefaultWriteObject = readBoolean(); 1.2397 - 1.2398 - if (calledDefaultWriteObject) 1.2399 - throwAwayData(fields, sender); 1.2400 - 1.2401 - if (getStreamFormatVersion() == 2) { 1.2402 - 1.2403 - ((ValueInputStream)getOrbStream()).start_value(); 1.2404 - ((ValueInputStream)getOrbStream()).end_value(); 1.2405 - } 1.2406 - } 1.2407 - 1.2408 - /* 1.2409 - * Read the fields of the specified class from the input stream throw data away. 1.2410 - * This must handle same switch logic as above. 1.2411 - */ 1.2412 - private void throwAwayData(ValueMember[] fields, 1.2413 - com.sun.org.omg.SendingContext.CodeBase sender) 1.2414 - throws InvalidClassException, StreamCorruptedException, 1.2415 - ClassNotFoundException, IOException 1.2416 - { 1.2417 - for (int i = 0; i < fields.length; ++i) { 1.2418 - 1.2419 - try { 1.2420 - 1.2421 - switch (fields[i].type.kind().value()) { 1.2422 - case TCKind._tk_octet: 1.2423 - orbStream.read_octet(); 1.2424 - break; 1.2425 - case TCKind._tk_boolean: 1.2426 - orbStream.read_boolean(); 1.2427 - break; 1.2428 - case TCKind._tk_char: 1.2429 - // Backwards compatibility. Older Sun ORBs sent 1.2430 - // _tk_char even though they read and wrote wchars 1.2431 - // correctly. 1.2432 - // 1.2433 - // Fall through to the _tk_wchar case. 1.2434 - case TCKind._tk_wchar: 1.2435 - orbStream.read_wchar(); 1.2436 - break; 1.2437 - case TCKind._tk_short: 1.2438 - orbStream.read_short(); 1.2439 - break; 1.2440 - case TCKind._tk_long: 1.2441 - orbStream.read_long(); 1.2442 - break; 1.2443 - case TCKind._tk_longlong: 1.2444 - orbStream.read_longlong(); 1.2445 - break; 1.2446 - case TCKind._tk_float: 1.2447 - orbStream.read_float(); 1.2448 - break; 1.2449 - case TCKind._tk_double: 1.2450 - orbStream.read_double(); 1.2451 - break; 1.2452 - case TCKind._tk_value: 1.2453 - case TCKind._tk_objref: 1.2454 - case TCKind._tk_value_box: 1.2455 - Class type = null; 1.2456 - String id = fields[i].id; 1.2457 - 1.2458 - try { 1.2459 - type = vhandler.getClassFromType(id); 1.2460 - } 1.2461 - catch(ClassNotFoundException cnfe){ 1.2462 - // Make sure type = null 1.2463 - type = null; 1.2464 - } 1.2465 - String signature = null; 1.2466 - if (type != null) 1.2467 - signature = ValueUtility.getSignature(fields[i]); 1.2468 - 1.2469 - // Read value 1.2470 - try { 1.2471 - if ((signature != null) && ( signature.equals("Ljava/lang/Object;") || 1.2472 - signature.equals("Ljava/io/Serializable;") || 1.2473 - signature.equals("Ljava/io/Externalizable;")) ) { 1.2474 - javax.rmi.CORBA.Util.readAny(orbStream); 1.2475 - } 1.2476 - else { 1.2477 - // Decide what method call to make based on the type. 1.2478 - // 1.2479 - // NOTE : Since FullValueDescription does not allow us 1.2480 - // to ask whether something is an interface we do not 1.2481 - // have the ability to optimize this check. 1.2482 - 1.2483 - int callType = ValueHandlerImpl.kValueType; 1.2484 - 1.2485 - if (!vhandler.isSequence(id)) { 1.2486 - FullValueDescription fieldFVD = sender.meta(fields[i].id); 1.2487 - if (kRemoteTypeCode == fields[i].type) { 1.2488 - 1.2489 - // RMI Object reference... 1.2490 - callType = ValueHandlerImpl.kRemoteType; 1.2491 - } else if (fieldFVD.is_abstract) { 1.2492 - // RMI Abstract Object reference... 1.2493 - 1.2494 - callType = ValueHandlerImpl.kAbstractType; 1.2495 - } 1.2496 - } 1.2497 - 1.2498 - // Now that we have used the FVD of the field to determine the proper course 1.2499 - // of action, it is ok to use the type (Class) from this point forward since 1.2500 - // the rep. id for this read will also follow on the wire. 1.2501 - 1.2502 - switch (callType) { 1.2503 - case ValueHandlerImpl.kRemoteType: 1.2504 - orbStream.read_Object(); 1.2505 - break; 1.2506 - case ValueHandlerImpl.kAbstractType: 1.2507 - orbStream.read_abstract_interface(); 1.2508 - break; 1.2509 - case ValueHandlerImpl.kValueType: 1.2510 - if (type != null) { 1.2511 - orbStream.read_value(type); 1.2512 - } else { 1.2513 - orbStream.read_value(); 1.2514 - } 1.2515 - break; 1.2516 - default: 1.2517 - // XXX I18N, logging needed. 1.2518 - throw new StreamCorruptedException("Unknown callType: " 1.2519 - + callType); 1.2520 - } 1.2521 - } 1.2522 - 1.2523 - } 1.2524 - catch(IndirectionException cdrie) { 1.2525 - // Since we are throwing this away, don't bother handling recursion. 1.2526 - continue; 1.2527 - } 1.2528 - 1.2529 - break; 1.2530 - default: 1.2531 - // XXX I18N, logging needed. 1.2532 - throw new StreamCorruptedException("Unknown kind: " 1.2533 - + fields[i].type.kind().value()); 1.2534 - 1.2535 - } 1.2536 - } catch (IllegalArgumentException e) { 1.2537 - /* This case should never happen. If the field types 1.2538 - are not the same, InvalidClassException is raised when 1.2539 - matching the local class to the serialized ObjectStreamClass. */ 1.2540 - // XXX I18N, logging needed. 1.2541 - ClassCastException cce = new ClassCastException("Assigning instance of class " + 1.2542 - fields[i].id + " to field " + currentClassDesc.getName() + 1.2543 - '#' + fields[i].name); 1.2544 - cce.initCause(e) ; 1.2545 - throw cce ; 1.2546 - } 1.2547 - } 1.2548 - 1.2549 - } 1.2550 - 1.2551 - private static void setObjectField(Object o, Class c, String fieldName, Object v) 1.2552 - { 1.2553 - try { 1.2554 - Field fld = c.getDeclaredField( fieldName ) ; 1.2555 - long key = bridge.objectFieldOffset( fld ) ; 1.2556 - bridge.putObject( o, key, v ) ; 1.2557 - } catch (Exception e) { 1.2558 - throw utilWrapper.errorSetObjectField( e, fieldName, 1.2559 - ObjectUtility.compactObjectToString( o ), 1.2560 - ObjectUtility.compactObjectToString( v )) ; 1.2561 - } 1.2562 - } 1.2563 - 1.2564 - private static void setBooleanField(Object o, Class c, String fieldName, boolean v) 1.2565 - { 1.2566 - try { 1.2567 - Field fld = c.getDeclaredField( fieldName ) ; 1.2568 - long key = bridge.objectFieldOffset( fld ) ; 1.2569 - bridge.putBoolean( o, key, v ) ; 1.2570 - } catch (Exception e) { 1.2571 - throw utilWrapper.errorSetBooleanField( e, fieldName, 1.2572 - ObjectUtility.compactObjectToString( o ), 1.2573 - new Boolean(v) ) ; 1.2574 - } 1.2575 - } 1.2576 - 1.2577 - private static void setByteField(Object o, Class c, String fieldName, byte v) 1.2578 - { 1.2579 - try { 1.2580 - Field fld = c.getDeclaredField( fieldName ) ; 1.2581 - long key = bridge.objectFieldOffset( fld ) ; 1.2582 - bridge.putByte( o, key, v ) ; 1.2583 - } catch (Exception e) { 1.2584 - throw utilWrapper.errorSetByteField( e, fieldName, 1.2585 - ObjectUtility.compactObjectToString( o ), 1.2586 - new Byte(v) ) ; 1.2587 - } 1.2588 - } 1.2589 - 1.2590 - private static void setCharField(Object o, Class c, String fieldName, char v) 1.2591 - { 1.2592 - try { 1.2593 - Field fld = c.getDeclaredField( fieldName ) ; 1.2594 - long key = bridge.objectFieldOffset( fld ) ; 1.2595 - bridge.putChar( o, key, v ) ; 1.2596 - } catch (Exception e) { 1.2597 - throw utilWrapper.errorSetCharField( e, fieldName, 1.2598 - ObjectUtility.compactObjectToString( o ), 1.2599 - new Character(v) ) ; 1.2600 - } 1.2601 - } 1.2602 - 1.2603 - private static void setShortField(Object o, Class c, String fieldName, short v) 1.2604 - { 1.2605 - try { 1.2606 - Field fld = c.getDeclaredField( fieldName ) ; 1.2607 - long key = bridge.objectFieldOffset( fld ) ; 1.2608 - bridge.putShort( o, key, v ) ; 1.2609 - } catch (Exception e) { 1.2610 - throw utilWrapper.errorSetShortField( e, fieldName, 1.2611 - ObjectUtility.compactObjectToString( o ), 1.2612 - new Short(v) ) ; 1.2613 - } 1.2614 - } 1.2615 - 1.2616 - private static void setIntField(Object o, Class c, String fieldName, int v) 1.2617 - { 1.2618 - try { 1.2619 - Field fld = c.getDeclaredField( fieldName ) ; 1.2620 - long key = bridge.objectFieldOffset( fld ) ; 1.2621 - bridge.putInt( o, key, v ) ; 1.2622 - } catch (Exception e) { 1.2623 - throw utilWrapper.errorSetIntField( e, fieldName, 1.2624 - ObjectUtility.compactObjectToString( o ), 1.2625 - new Integer(v) ) ; 1.2626 - } 1.2627 - } 1.2628 - 1.2629 - private static void setLongField(Object o, Class c, String fieldName, long v) 1.2630 - { 1.2631 - try { 1.2632 - Field fld = c.getDeclaredField( fieldName ) ; 1.2633 - long key = bridge.objectFieldOffset( fld ) ; 1.2634 - bridge.putLong( o, key, v ) ; 1.2635 - } catch (Exception e) { 1.2636 - throw utilWrapper.errorSetLongField( e, fieldName, 1.2637 - ObjectUtility.compactObjectToString( o ), 1.2638 - new Long(v) ) ; 1.2639 - } 1.2640 - } 1.2641 - 1.2642 - private static void setFloatField(Object o, Class c, String fieldName, float v) 1.2643 - { 1.2644 - try { 1.2645 - Field fld = c.getDeclaredField( fieldName ) ; 1.2646 - long key = bridge.objectFieldOffset( fld ) ; 1.2647 - bridge.putFloat( o, key, v ) ; 1.2648 - } catch (Exception e) { 1.2649 - throw utilWrapper.errorSetFloatField( e, fieldName, 1.2650 - ObjectUtility.compactObjectToString( o ), 1.2651 - new Float(v) ) ; 1.2652 - } 1.2653 - } 1.2654 - 1.2655 - private static void setDoubleField(Object o, Class c, String fieldName, double v) 1.2656 - { 1.2657 - try { 1.2658 - Field fld = c.getDeclaredField( fieldName ) ; 1.2659 - long key = bridge.objectFieldOffset( fld ) ; 1.2660 - bridge.putDouble( o, key, v ) ; 1.2661 - } catch (Exception e) { 1.2662 - throw utilWrapper.errorSetDoubleField( e, fieldName, 1.2663 - ObjectUtility.compactObjectToString( o ), 1.2664 - new Double(v) ) ; 1.2665 - } 1.2666 - } 1.2667 - 1.2668 - /** 1.2669 - * This class maintains a map of stream position to 1.2670 - * an Object currently being deserialized. It is used 1.2671 - * to handle the cases where the are indirections to 1.2672 - * an object on the recursion stack. The CDR level 1.2673 - * handles indirections to objects previously seen 1.2674 - * (and completely deserialized) in the stream. 1.2675 - */ 1.2676 - static class ActiveRecursionManager 1.2677 - { 1.2678 - private Map offsetToObjectMap; 1.2679 - 1.2680 - public ActiveRecursionManager() { 1.2681 - // A hash map is unsynchronized and allows 1.2682 - // null values 1.2683 - offsetToObjectMap = new HashMap(); 1.2684 - } 1.2685 - 1.2686 - // Called right after allocating a new object. 1.2687 - // Offset is the starting position in the stream 1.2688 - // of the object. 1.2689 - public void addObject(int offset, Object value) { 1.2690 - offsetToObjectMap.put(new Integer(offset), value); 1.2691 - } 1.2692 - 1.2693 - // If the given starting position doesn't refer 1.2694 - // to the beginning of an object currently being 1.2695 - // deserialized, this throws an IOException. 1.2696 - // Otherwise, it returns a reference to the 1.2697 - // object. 1.2698 - public Object getObject(int offset) throws IOException { 1.2699 - Integer position = new Integer(offset); 1.2700 - 1.2701 - if (!offsetToObjectMap.containsKey(position)) 1.2702 - // XXX I18N, logging needed. 1.2703 - throw new IOException("Invalid indirection to offset " 1.2704 - + offset); 1.2705 - 1.2706 - return offsetToObjectMap.get(position); 1.2707 - } 1.2708 - 1.2709 - // Called when an object has been completely 1.2710 - // deserialized, so it should no longer be in 1.2711 - // this mapping. The CDR level can handle 1.2712 - // further indirections. 1.2713 - public void removeObject(int offset) { 1.2714 - offsetToObjectMap.remove(new Integer(offset)); 1.2715 - } 1.2716 - 1.2717 - // If the given offset doesn't map to an Object, 1.2718 - // then it isn't an indirection to an object 1.2719 - // currently being deserialized. 1.2720 - public boolean containsObject(int offset) { 1.2721 - return offsetToObjectMap.containsKey(new Integer(offset)); 1.2722 - } 1.2723 - } 1.2724 -}
2.1 --- a/src/share/classes/com/sun/corba/se/impl/io/ValueHandlerImpl.java Fri Sep 24 16:38:05 2010 -0700 2.2 +++ b/src/share/classes/com/sun/corba/se/impl/io/ValueHandlerImpl.java Fri Sep 24 22:42:14 2010 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -32,32 +32,22 @@ 2.11 package com.sun.corba.se.impl.io; 2.12 2.13 import javax.rmi.CORBA.Util; 2.14 -import javax.rmi.PortableRemoteObject; 2.15 2.16 import java.util.Hashtable; 2.17 -import java.util.Stack; 2.18 import java.io.IOException; 2.19 -import java.util.EmptyStackException; 2.20 2.21 -import com.sun.corba.se.impl.util.Utility; 2.22 -import com.sun.corba.se.impl.io.IIOPInputStream; 2.23 -import com.sun.corba.se.impl.io.IIOPOutputStream; 2.24 import com.sun.corba.se.impl.util.RepositoryId; 2.25 import com.sun.corba.se.impl.util.Utility; 2.26 2.27 import org.omg.CORBA.TCKind; 2.28 2.29 -import org.omg.CORBA.MARSHAL; 2.30 -import org.omg.CORBA.BAD_PARAM; 2.31 -import org.omg.CORBA.CompletionStatus; 2.32 import org.omg.CORBA.portable.IndirectionException; 2.33 import com.sun.org.omg.SendingContext.CodeBase; 2.34 import com.sun.org.omg.SendingContext.CodeBaseHelper; 2.35 2.36 import java.security.AccessController; 2.37 import java.security.PrivilegedAction; 2.38 - 2.39 -import com.sun.corba.se.impl.io.IIOPInputStream.ActiveRecursionManager; 2.40 +import java.security.PrivilegedExceptionAction; 2.41 2.42 import com.sun.corba.se.spi.logging.CORBALogDomains; 2.43 import com.sun.corba.se.impl.logging.OMGSystemException; 2.44 @@ -809,65 +799,163 @@ 2.45 return "com.sun.corba.se.impl.io.IIOPOutputStream"; 2.46 } 2.47 2.48 - private com.sun.corba.se.impl.io.IIOPOutputStream createOutputStream() { 2.49 - return (com.sun.corba.se.impl.io.IIOPOutputStream)AccessController.doPrivileged( 2.50 - new StreamFactory(getOutputStreamClassName())); 2.51 + private IIOPOutputStream createOutputStream() { 2.52 + final String name = getOutputStreamClassName(); 2.53 + try { 2.54 + IIOPOutputStream stream = createOutputStreamBuiltIn(name); 2.55 + if (stream != null) { 2.56 + return stream; 2.57 + } 2.58 + return createCustom(IIOPOutputStream.class, name); 2.59 + } catch (Throwable t) { 2.60 + // Throw exception under the carpet. 2.61 + InternalError ie = new InternalError( 2.62 + "Error loading " + name 2.63 + ); 2.64 + ie.initCause(t); 2.65 + throw ie; 2.66 + } 2.67 + } 2.68 + 2.69 + /** 2.70 + * Construct a built in implementation with priveleges. 2.71 + * Returning null indicates a non-built is specified. 2.72 + */ 2.73 + private IIOPOutputStream createOutputStreamBuiltIn( 2.74 + final String name 2.75 + ) throws Throwable { 2.76 + try { 2.77 + return AccessController.doPrivileged( 2.78 + new PrivilegedExceptionAction<IIOPOutputStream>() { 2.79 + public IIOPOutputStream run() throws IOException { 2.80 + return createOutputStreamBuiltInNoPriv(name); 2.81 + } 2.82 + } 2.83 + ); 2.84 + } catch (java.security.PrivilegedActionException exc) { 2.85 + throw exc.getCause(); 2.86 + } 2.87 + } 2.88 + 2.89 + /** 2.90 + * Returning null indicates a non-built is specified. 2.91 + */ 2.92 + private IIOPOutputStream createOutputStreamBuiltInNoPriv( 2.93 + final String name 2.94 + ) throws IOException { 2.95 + return 2.96 + name.equals( 2.97 + IIOPOutputStream 2.98 + .class.getName() 2.99 + ) ? 2.100 + new IIOPOutputStream() : 2.101 + 2.102 + name.equals( 2.103 + com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3 2.104 + .class.getName() 2.105 + ) ? 2.106 + new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3() : 2.107 + 2.108 + name.equals( 2.109 + com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1 2.110 + .class.getName() 2.111 + ) ? 2.112 + new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1() : 2.113 + 2.114 + null; 2.115 } 2.116 2.117 protected String getInputStreamClassName() { 2.118 return "com.sun.corba.se.impl.io.IIOPInputStream"; 2.119 } 2.120 2.121 - private com.sun.corba.se.impl.io.IIOPInputStream createInputStream() { 2.122 - return (com.sun.corba.se.impl.io.IIOPInputStream)AccessController.doPrivileged( 2.123 - new StreamFactory(getInputStreamClassName())); 2.124 + private IIOPInputStream createInputStream() { 2.125 + final String name = getInputStreamClassName(); 2.126 + try { 2.127 + IIOPInputStream stream = createInputStreamBuiltIn(name); 2.128 + if (stream != null) { 2.129 + return stream; 2.130 + } 2.131 + return createCustom(IIOPInputStream.class, name); 2.132 + } catch (Throwable t) { 2.133 + // Throw exception under the carpet. 2.134 + InternalError ie = new InternalError( 2.135 + "Error loading " + name 2.136 + ); 2.137 + ie.initCause(t); 2.138 + throw ie; 2.139 + } 2.140 } 2.141 2.142 /** 2.143 - * Instantiates a class of the given name using the system ClassLoader 2.144 - * as part of a PrivilegedAction. 2.145 - * 2.146 - * It's private final so hopefully people can't grab it outside of 2.147 - * this class. 2.148 - * 2.149 - * If you're worried that someone could subclass ValueHandlerImpl, 2.150 - * install his own streams, and snoop what's on the wire: 2.151 - * Someone can do that only if he's allowed to use the feature 2.152 - * of installing his own javax.rmi.CORBA.Util delegate (via a 2.153 - * JVM property or orb.properties file, read the first time the 2.154 - * Util class is used). If he can do that, he can snoop 2.155 - * anything on the wire, anyway, without abusing the 2.156 - * StreamFactory class. 2.157 + * Construct a built in implementation with priveleges. 2.158 + * Returning null indicates a non-built is specified. 2.159 */ 2.160 - private static final class StreamFactory implements PrivilegedAction { 2.161 - private String className; 2.162 + private IIOPInputStream createInputStreamBuiltIn( 2.163 + final String name 2.164 + ) throws Throwable { 2.165 + try { 2.166 + return AccessController.doPrivileged( 2.167 + new PrivilegedExceptionAction<IIOPInputStream>() { 2.168 + public IIOPInputStream run() throws IOException { 2.169 + return createInputStreamBuiltInNoPriv(name); 2.170 + } 2.171 + } 2.172 + ); 2.173 + } catch (java.security.PrivilegedActionException exc) { 2.174 + throw exc.getCause(); 2.175 + } 2.176 + } 2.177 2.178 - public StreamFactory (String _className) { 2.179 - className = _className; 2.180 - } 2.181 + /** 2.182 + * Returning null indicates a non-built is specified. 2.183 + */ 2.184 + private IIOPInputStream createInputStreamBuiltInNoPriv( 2.185 + final String name 2.186 + ) throws IOException { 2.187 + return 2.188 + name.equals( 2.189 + IIOPInputStream 2.190 + .class.getName() 2.191 + ) ? 2.192 + new IIOPInputStream() : 2.193 2.194 - public Object run() { 2.195 - try { 2.196 - // Note: We must use the system ClassLoader here 2.197 - // since we want to load classes outside of the 2.198 - // core JDK when running J2EE Pure ORB and 2.199 - // talking to Kestrel. 2.200 + name.equals( 2.201 + com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3 2.202 + .class.getName() 2.203 + ) ? 2.204 + new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3() : 2.205 + 2.206 + name.equals( 2.207 + com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1 2.208 + .class.getName() 2.209 + ) ? 2.210 + new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1() : 2.211 + 2.212 + null; 2.213 + } 2.214 + 2.215 + /** 2.216 + * Create a custom implementation without privileges. 2.217 + */ 2.218 + private <T> T createCustom( 2.219 + final Class<T> type, final String className 2.220 + ) throws Throwable { 2.221 + // Note: We use the thread context or system ClassLoader here 2.222 + // since we want to load classes outside of the 2.223 + // core JDK when running J2EE Pure ORB and 2.224 + // talking to Kestrel. 2.225 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 2.226 if (cl == null) 2.227 cl = ClassLoader.getSystemClassLoader(); 2.228 2.229 - Class streamClass = cl.loadClass(className); 2.230 + Class<?> clazz = cl.loadClass(className); 2.231 + Class<? extends T> streamClass = clazz.asSubclass(type); 2.232 2.233 // Since the ClassLoader should cache the class, this isn't 2.234 // as expensive as it looks. 2.235 return streamClass.newInstance(); 2.236 2.237 - } catch(Throwable t) { 2.238 - InternalError ie = new InternalError( "Error loading " + className ) ; 2.239 - ie.initCause( t ) ; 2.240 - throw ie ; 2.241 - } 2.242 - } 2.243 } 2.244 2.245 /**
3.1 --- a/src/share/classes/com/sun/corba/se/impl/orb/PrefixParserAction.java Fri Sep 24 16:38:05 2010 -0700 3.2 +++ b/src/share/classes/com/sun/corba/se/impl/orb/PrefixParserAction.java Fri Sep 24 22:42:14 2010 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -110,7 +110,7 @@ 3.11 throw wrapper.couldNotSetArray( thr, 3.12 getPropertyName(), new Integer(ctr), 3.13 componentType, new Integer(size), 3.14 - ObjectUtility.compactObjectToString( obj )) ; 3.15 + obj.toString() ) ; 3.16 } 3.17 ctr++ ; 3.18 }
4.1 --- a/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectUtility.java Fri Sep 24 16:38:05 2010 -0700 4.2 +++ b/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectUtility.java Fri Sep 24 22:42:14 2010 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -50,103 +50,8 @@ 4.11 import java.math.BigDecimal ; 4.12 4.13 public final class ObjectUtility { 4.14 - private boolean useToString ; 4.15 - private boolean isIndenting ; 4.16 - private int initialLevel ; 4.17 - private int increment ; 4.18 - private ClassMap classToPrinter = new ClassMap() ; 4.19 + private ObjectUtility() {} 4.20 4.21 - private static ObjectUtility standard = new ObjectUtility( false, true, 4.22 - 0, 4 ) ; 4.23 - private static ObjectUtility compact = new ObjectUtility( true, false, 4.24 - 0, 4 ) ; 4.25 - 4.26 - private ObjectUtility( boolean useToString, boolean isIndenting, 4.27 - int initialLevel, int increment ) 4.28 - { 4.29 - this.useToString = useToString ; 4.30 - this.isIndenting = isIndenting ; 4.31 - this.initialLevel = initialLevel ; 4.32 - this.increment = increment ; 4.33 - classToPrinter.put( Properties.class, propertiesPrinter ) ; 4.34 - classToPrinter.put( Collection.class, collectionPrinter ) ; 4.35 - classToPrinter.put( Map.class, mapPrinter ) ; 4.36 - } 4.37 - 4.38 - /** Construct an Utility instance with the desired objectToString 4.39 - * behavior. 4.40 - */ 4.41 - public static ObjectUtility make( boolean useToString, boolean isIndenting, 4.42 - int initialLevel, int increment ) 4.43 - { 4.44 - return new ObjectUtility( useToString, isIndenting, initialLevel, 4.45 - increment ) ; 4.46 - } 4.47 - 4.48 - /** Construct an Utility instance with the desired objectToString 4.49 - * behavior. 4.50 - */ 4.51 - public static ObjectUtility make( boolean useToString, boolean isIndenting ) 4.52 - { 4.53 - return new ObjectUtility( useToString, isIndenting, 0, 4 ) ; 4.54 - } 4.55 - 4.56 - /** Get the standard Utility object that supports objectToString with 4.57 - * indented display and no use of toString() methods. 4.58 - */ 4.59 - public static ObjectUtility make() 4.60 - { 4.61 - return standard ; 4.62 - } 4.63 - 4.64 - /** A convenience method that gives the default behavior: use indenting 4.65 - * to display the object's structure and do not use built-in toString 4.66 - * methods. 4.67 - */ 4.68 - public static String defaultObjectToString( java.lang.Object object ) 4.69 - { 4.70 - return standard.objectToString( object ) ; 4.71 - } 4.72 - 4.73 - public static String compactObjectToString( java.lang.Object object ) 4.74 - { 4.75 - return compact.objectToString( object ) ; 4.76 - } 4.77 - 4.78 - /** objectToString handles display of arbitrary objects. It correctly 4.79 - * handles objects whose elements form an arbitrary graph. It uses 4.80 - * reflection to display the contents of any kind of object. 4.81 - * An object's toString() method may optionally be used, but the default 4.82 - * is to ignore all toString() methods except for those defined for 4.83 - * primitive types, primitive type wrappers, and strings. 4.84 - */ 4.85 - public String objectToString(java.lang.Object obj) 4.86 - { 4.87 - IdentityHashMap printed = new IdentityHashMap() ; 4.88 - ObjectWriter result = ObjectWriter.make( isIndenting, initialLevel, 4.89 - increment ) ; 4.90 - objectToStringHelper( printed, result, obj ) ; 4.91 - return result.toString() ; 4.92 - } 4.93 - 4.94 - // Perform a deep structural equality comparison of the two objects. 4.95 - // This handles all arrays, maps, and sets specially, otherwise 4.96 - // it just calls the object's equals() method. 4.97 - public static boolean equals( java.lang.Object obj1, java.lang.Object obj2 ) 4.98 - { 4.99 - // Set of pairs of objects that have been (or are being) considered for 4.100 - // equality. Such pairs are presumed to be equals. If they are not, 4.101 - // this will be detected eventually and the equals method will return 4.102 - // false. 4.103 - Set considered = new HashSet() ; 4.104 - 4.105 - // Map that gives the corresponding component of obj2 for a component 4.106 - // of obj1. This is used to check for the same aliasing and use of 4.107 - // equal objects in both objects. 4.108 - Map counterpart = new IdentityHashMap() ; 4.109 - 4.110 - return equalsHelper( counterpart, considered, obj1, obj2 ) ; 4.111 - } 4.112 4.113 /** If arr1 and arr2 are both arrays of the same component type, 4.114 * return an array of that component type that consists of the 4.115 @@ -179,544 +84,4 @@ 4.116 return result ; 4.117 } 4.118 4.119 -//=========================================================================== 4.120 -// Implementation 4.121 -//=========================================================================== 4.122 - 4.123 - private void objectToStringHelper( IdentityHashMap printed, 4.124 - ObjectWriter result, java.lang.Object obj) 4.125 - { 4.126 - if (obj==null) { 4.127 - result.append( "null" ) ; 4.128 - result.endElement() ; 4.129 - } else { 4.130 - Class cls = obj.getClass() ; 4.131 - result.startObject( obj ) ; 4.132 - 4.133 - if (printed.keySet().contains( obj )) { 4.134 - result.endObject( "*VISITED*" ) ; 4.135 - } else { 4.136 - printed.put( obj, null ) ; 4.137 - 4.138 - if (mustUseToString(cls)) { 4.139 - result.endObject( obj.toString() ) ; 4.140 - } else { 4.141 - // First, handle any classes that have special printer 4.142 - // methods defined. This is useful when the class 4.143 - // overrides toString with something that 4.144 - // is not sufficiently detailed. 4.145 - ObjectPrinter printer = (ObjectPrinter)(classToPrinter.get( 4.146 - cls )) ; 4.147 - if (printer != null) { 4.148 - printer.print( printed, result, obj ) ; 4.149 - result.endObject() ; 4.150 - } else { 4.151 - Class compClass = cls.getComponentType() ; 4.152 - 4.153 - if (compClass == null) 4.154 - // handleObject always calls endObject 4.155 - handleObject( printed, result, obj ) ; 4.156 - else { 4.157 - handleArray( printed, result, obj ) ; 4.158 - result.endObject() ; 4.159 - } 4.160 - } 4.161 - } 4.162 - } 4.163 - } 4.164 - } 4.165 - 4.166 - private static interface ObjectPrinter { 4.167 - void print( IdentityHashMap printed, ObjectWriter buff, 4.168 - java.lang.Object obj ) ; 4.169 - } 4.170 - 4.171 - private ObjectPrinter propertiesPrinter = new ObjectPrinter() { 4.172 - public void print( IdentityHashMap printed, ObjectWriter buff, 4.173 - java.lang.Object obj ) 4.174 - { 4.175 - if (!(obj instanceof Properties)) 4.176 - throw new Error() ; 4.177 - 4.178 - Properties props = (Properties)obj ; 4.179 - Enumeration keys = props.propertyNames() ; 4.180 - while (keys.hasMoreElements()) { 4.181 - String key = (String)(keys.nextElement()) ; 4.182 - String value = props.getProperty( key ) ; 4.183 - buff.startElement() ; 4.184 - buff.append( key ) ; 4.185 - buff.append( "=" ) ; 4.186 - buff.append( value ) ; 4.187 - buff.endElement() ; 4.188 - } 4.189 - } 4.190 - } ; 4.191 - 4.192 - private ObjectPrinter collectionPrinter = new ObjectPrinter() { 4.193 - public void print( IdentityHashMap printed, ObjectWriter buff, 4.194 - java.lang.Object obj ) 4.195 - { 4.196 - if (!(obj instanceof Collection)) 4.197 - throw new Error() ; 4.198 - 4.199 - Collection coll = (Collection)obj ; 4.200 - Iterator iter = coll.iterator() ; 4.201 - while (iter.hasNext()) { 4.202 - java.lang.Object element = iter.next() ; 4.203 - buff.startElement() ; 4.204 - objectToStringHelper( printed, buff, element ) ; 4.205 - buff.endElement() ; 4.206 - } 4.207 - } 4.208 - } ; 4.209 - 4.210 - private ObjectPrinter mapPrinter = new ObjectPrinter() { 4.211 - public void print( IdentityHashMap printed, ObjectWriter buff, 4.212 - java.lang.Object obj ) 4.213 - { 4.214 - if (!(obj instanceof Map)) 4.215 - throw new Error() ; 4.216 - 4.217 - Map map = (Map)obj ; 4.218 - Iterator iter = map.entrySet().iterator() ; 4.219 - while (iter.hasNext()) { 4.220 - Entry entry = (Entry)(iter.next()) ; 4.221 - buff.startElement() ; 4.222 - objectToStringHelper( printed, buff, entry.getKey() ) ; 4.223 - buff.append( "=>" ) ; 4.224 - objectToStringHelper( printed, buff, entry.getValue() ) ; 4.225 - buff.endElement() ; 4.226 - } 4.227 - } 4.228 - } ; 4.229 - 4.230 - private static class ClassMap { 4.231 - ArrayList data ; 4.232 - 4.233 - public ClassMap() 4.234 - { 4.235 - data = new ArrayList() ; 4.236 - } 4.237 - 4.238 - /** Return the first element of the ClassMap that is assignable to cls. 4.239 - * The order is determined by the order in which the put method was 4.240 - * called. Returns null if there is no match. 4.241 - */ 4.242 - public java.lang.Object get( Class cls ) 4.243 - { 4.244 - Iterator iter = data.iterator() ; 4.245 - while (iter.hasNext()) { 4.246 - java.lang.Object[] arr = (java.lang.Object[])(iter.next()) ; 4.247 - Class key = (Class)(arr[0]) ; 4.248 - if (key.isAssignableFrom( cls )) 4.249 - return arr[1] ; 4.250 - } 4.251 - 4.252 - return null ; 4.253 - } 4.254 - 4.255 - /** Add obj to the map with key cls. Note that order matters, 4.256 - * as the first match is returned. 4.257 - */ 4.258 - public void put( Class cls, java.lang.Object obj ) 4.259 - { 4.260 - java.lang.Object[] pair = { cls, obj } ; 4.261 - data.add( pair ) ; 4.262 - } 4.263 - } 4.264 - 4.265 - private boolean mustUseToString( Class cls ) 4.266 - { 4.267 - // These probably never occur 4.268 - if (cls.isPrimitive()) 4.269 - return true ; 4.270 - 4.271 - // We must use toString for all primitive wrappers, since 4.272 - // otherwise the code recurses endlessly (access value field 4.273 - // inside Integer, returns another Integer through reflection). 4.274 - if ((cls == Integer.class) || 4.275 - (cls == BigInteger.class) || 4.276 - (cls == BigDecimal.class) || 4.277 - (cls == String.class) || 4.278 - (cls == StringBuffer.class) || 4.279 - (cls == Long.class) || 4.280 - (cls == Short.class) || 4.281 - (cls == Byte.class) || 4.282 - (cls == Character.class) || 4.283 - (cls == Float.class) || 4.284 - (cls == Double.class) || 4.285 - (cls == Boolean.class)) 4.286 - return true ; 4.287 - 4.288 - if (useToString) { 4.289 - try { 4.290 - cls.getDeclaredMethod( "toString", (Class[])null ) ; 4.291 - return true ; 4.292 - } catch (Exception exc) { 4.293 - return false ; 4.294 - } 4.295 - } 4.296 - 4.297 - return false ; 4.298 - } 4.299 - 4.300 - private void handleObject( IdentityHashMap printed, ObjectWriter result, 4.301 - java.lang.Object obj ) 4.302 - { 4.303 - Class cls = obj.getClass() ; 4.304 - 4.305 - try { 4.306 - Field[] fields; 4.307 - SecurityManager security = System.getSecurityManager(); 4.308 - if (security != null && !Modifier.isPublic(cls.getModifiers())) { 4.309 - fields = new Field[0]; 4.310 - } else { 4.311 - fields = cls.getDeclaredFields(); 4.312 - } 4.313 - 4.314 - for (int ctr=0; ctr<fields.length; ctr++ ) { 4.315 - final Field fld = fields[ctr] ; 4.316 - int modifiers = fld.getModifiers() ; 4.317 - 4.318 - // Do not display field if it is static, since these fields 4.319 - // are always the same for every instances. This could 4.320 - // be made configurable, but I don't think it is 4.321 - // useful to do so. 4.322 - if (!Modifier.isStatic( modifiers )) { 4.323 - if (security != null) { 4.324 - if (!Modifier.isPublic(modifiers)) 4.325 - continue; 4.326 - } 4.327 - result.startElement() ; 4.328 - result.append( fld.getName() ) ; 4.329 - result.append( ":" ) ; 4.330 - 4.331 - try { 4.332 - // Make sure that we can read the field if it is 4.333 - // not public 4.334 - AccessController.doPrivileged( new PrivilegedAction() { 4.335 - public Object run() { 4.336 - fld.setAccessible( true ) ; 4.337 - return null ; 4.338 - } 4.339 - } ) ; 4.340 - 4.341 - java.lang.Object value = fld.get( obj ) ; 4.342 - objectToStringHelper( printed, result, value ) ; 4.343 - } catch (Exception exc2) { 4.344 - result.append( "???" ) ; 4.345 - } 4.346 - 4.347 - result.endElement() ; 4.348 - } 4.349 - } 4.350 - 4.351 - result.endObject() ; 4.352 - } catch (Exception exc2) { 4.353 - result.endObject( obj.toString() ) ; 4.354 - } 4.355 - } 4.356 - 4.357 - private void handleArray( IdentityHashMap printed, ObjectWriter result, 4.358 - java.lang.Object obj ) 4.359 - { 4.360 - Class compClass = obj.getClass().getComponentType() ; 4.361 - if (compClass == boolean.class) { 4.362 - boolean[] arr = (boolean[])obj ; 4.363 - for (int ctr=0; ctr<arr.length; ctr++) { 4.364 - result.startElement() ; 4.365 - result.append( arr[ctr] ) ; 4.366 - result.endElement() ; 4.367 - } 4.368 - } else if (compClass == byte.class) { 4.369 - byte[] arr = (byte[])obj ; 4.370 - for (int ctr=0; ctr<arr.length; ctr++) { 4.371 - result.startElement() ; 4.372 - result.append( arr[ctr] ) ; 4.373 - result.endElement() ; 4.374 - } 4.375 - } else if (compClass == short.class) { 4.376 - short[] arr = (short[])obj ; 4.377 - for (int ctr=0; ctr<arr.length; ctr++) { 4.378 - result.startElement() ; 4.379 - result.append( arr[ctr] ) ; 4.380 - result.endElement() ; 4.381 - } 4.382 - } else if (compClass == int.class) { 4.383 - int[] arr = (int[])obj ; 4.384 - for (int ctr=0; ctr<arr.length; ctr++) { 4.385 - result.startElement() ; 4.386 - result.append( arr[ctr] ) ; 4.387 - result.endElement() ; 4.388 - } 4.389 - } else if (compClass == long.class) { 4.390 - long[] arr = (long[])obj ; 4.391 - for (int ctr=0; ctr<arr.length; ctr++) { 4.392 - result.startElement() ; 4.393 - result.append( arr[ctr] ) ; 4.394 - result.endElement() ; 4.395 - } 4.396 - } else if (compClass == char.class) { 4.397 - char[] arr = (char[])obj ; 4.398 - for (int ctr=0; ctr<arr.length; ctr++) { 4.399 - result.startElement() ; 4.400 - result.append( arr[ctr] ) ; 4.401 - result.endElement() ; 4.402 - } 4.403 - } else if (compClass == float.class) { 4.404 - float[] arr = (float[])obj ; 4.405 - for (int ctr=0; ctr<arr.length; ctr++) { 4.406 - result.startElement() ; 4.407 - result.append( arr[ctr] ) ; 4.408 - result.endElement() ; 4.409 - } 4.410 - } else if (compClass == double.class) { 4.411 - double[] arr = (double[])obj ; 4.412 - for (int ctr=0; ctr<arr.length; ctr++) { 4.413 - result.startElement() ; 4.414 - result.append( arr[ctr] ) ; 4.415 - result.endElement() ; 4.416 - } 4.417 - } else { // array of object 4.418 - java.lang.Object[] arr = (java.lang.Object[])obj ; 4.419 - for (int ctr=0; ctr<arr.length; ctr++) { 4.420 - result.startElement() ; 4.421 - objectToStringHelper( printed, result, arr[ctr] ) ; 4.422 - result.endElement() ; 4.423 - } 4.424 - } 4.425 - } 4.426 - 4.427 - private static class Pair 4.428 - { 4.429 - private java.lang.Object obj1 ; 4.430 - private java.lang.Object obj2 ; 4.431 - 4.432 - Pair( java.lang.Object obj1, java.lang.Object obj2 ) 4.433 - { 4.434 - this.obj1 = obj1 ; 4.435 - this.obj2 = obj2 ; 4.436 - } 4.437 - 4.438 - public boolean equals( java.lang.Object obj ) 4.439 - { 4.440 - if (!(obj instanceof Pair)) 4.441 - return false ; 4.442 - 4.443 - Pair other = (Pair)obj ; 4.444 - return other.obj1 == obj1 && other.obj2 == obj2 ; 4.445 - } 4.446 - 4.447 - public int hashCode() 4.448 - { 4.449 - return System.identityHashCode( obj1 ) ^ 4.450 - System.identityHashCode( obj2 ) ; 4.451 - } 4.452 - } 4.453 - 4.454 - private static boolean equalsHelper( Map counterpart, Set considered, 4.455 - java.lang.Object obj1, java.lang.Object obj2 ) 4.456 - { 4.457 - if ((obj1 == null) || (obj2 == null)) 4.458 - return obj1 == obj2 ; 4.459 - 4.460 - java.lang.Object other2 = counterpart.get( obj1 ) ; 4.461 - if (other2 == null) { 4.462 - other2 = obj2 ; 4.463 - counterpart.put( obj1, other2 ) ; 4.464 - } 4.465 - 4.466 - if (obj1 == other2) 4.467 - return true ; 4.468 - 4.469 - if (obj2 != other2) 4.470 - return false ; 4.471 - 4.472 - Pair pair = new Pair( obj1, obj2 ) ; 4.473 - if (considered.contains( pair )) 4.474 - return true ; 4.475 - else 4.476 - considered.add( pair ) ; 4.477 - 4.478 - if (obj1 instanceof java.lang.Object[] && 4.479 - obj2 instanceof java.lang.Object[]) 4.480 - return equalArrays( counterpart, considered, 4.481 - (java.lang.Object[])obj1, (java.lang.Object[])obj2 ) ; 4.482 - else if (obj1 instanceof Map && obj2 instanceof Map) 4.483 - return equalMaps( counterpart, considered, 4.484 - (Map)obj1, (Map)obj2 ) ; 4.485 - else if (obj1 instanceof Set && obj2 instanceof Set) 4.486 - return equalSets( counterpart, considered, 4.487 - (Set)obj1, (Set)obj2 ) ; 4.488 - else if (obj1 instanceof List && obj2 instanceof List) 4.489 - return equalLists( counterpart, considered, 4.490 - (List)obj1, (List)obj2 ) ; 4.491 - else if (obj1 instanceof boolean[] && obj2 instanceof boolean[]) 4.492 - return Arrays.equals( (boolean[])obj1, (boolean[])obj2 ) ; 4.493 - else if (obj1 instanceof byte[] && obj2 instanceof byte[]) 4.494 - return Arrays.equals( (byte[])obj1, (byte[])obj2 ) ; 4.495 - else if (obj1 instanceof char[] && obj2 instanceof char[]) 4.496 - return Arrays.equals( (char[])obj1, (char[])obj2 ) ; 4.497 - else if (obj1 instanceof double[] && obj2 instanceof double[]) 4.498 - return Arrays.equals( (double[])obj1, (double[])obj2 ) ; 4.499 - else if (obj1 instanceof float[] && obj2 instanceof float[]) 4.500 - return Arrays.equals( (float[])obj1, (float[])obj2 ) ; 4.501 - else if (obj1 instanceof int[] && obj2 instanceof int[]) 4.502 - return Arrays.equals( (int[])obj1, (int[])obj2 ) ; 4.503 - else if (obj1 instanceof long[] && obj2 instanceof long[]) 4.504 - return Arrays.equals( (long[])obj1, (long[])obj2 ) ; 4.505 - else { 4.506 - Class cls = obj1.getClass() ; 4.507 - if (cls != obj2.getClass()) 4.508 - return obj1.equals( obj2 ) ; 4.509 - else 4.510 - return equalsObject( counterpart, considered, cls, obj1, obj2 ) ; 4.511 - } 4.512 - } 4.513 - 4.514 - private static boolean equalsObject( Map counterpart, Set considered, 4.515 - Class cls, java.lang.Object obj1, java.lang.Object obj2 ) 4.516 - { 4.517 - Class objectClass = java.lang.Object.class ; 4.518 - if (cls == objectClass) 4.519 - return true ; 4.520 - 4.521 - Class[] equalsTypes = { objectClass } ; 4.522 - try { 4.523 - Method equalsMethod = cls.getDeclaredMethod( "equals", 4.524 - equalsTypes ) ; 4.525 - return obj1.equals( obj2 ) ; 4.526 - } catch (Exception exc) { 4.527 - if (equalsObjectFields( counterpart, considered, 4.528 - cls, obj1, obj2 )) 4.529 - return equalsObject( counterpart, considered, 4.530 - cls.getSuperclass(), obj1, obj2 ) ; 4.531 - else 4.532 - return false ; 4.533 - } 4.534 - } 4.535 - 4.536 - private static boolean equalsObjectFields( Map counterpart, Set considered, 4.537 - Class cls, java.lang.Object obj1, java.lang.Object obj2 ) 4.538 - { 4.539 - Field[] fields = cls.getDeclaredFields() ; 4.540 - for (int ctr=0; ctr<fields.length; ctr++) { 4.541 - try { 4.542 - final Field field = fields[ctr] ; 4.543 - // Ignore static fields 4.544 - if (!Modifier.isStatic( field.getModifiers())) { 4.545 - AccessController.doPrivileged(new PrivilegedAction() { 4.546 - public Object run() { 4.547 - field.setAccessible( true ) ; 4.548 - return null ; 4.549 - } 4.550 - } ) ; 4.551 - 4.552 - java.lang.Object value1 = field.get( obj1 ) ; 4.553 - java.lang.Object value2 = field.get( obj2 ) ; 4.554 - if (!equalsHelper( counterpart, considered, value1, 4.555 - value2 )) 4.556 - return false ; 4.557 - } 4.558 - } catch (IllegalAccessException exc) { 4.559 - return false ; 4.560 - } 4.561 - } 4.562 - 4.563 - return true ; 4.564 - } 4.565 - 4.566 - private static boolean equalArrays( Map counterpart, Set considered, 4.567 - java.lang.Object[] arr1, java.lang.Object[] arr2 ) 4.568 - { 4.569 - int len = arr1.length ; 4.570 - if (len != arr2.length) 4.571 - return false ; 4.572 - 4.573 - for (int ctr = 0; ctr<len; ctr++ ) 4.574 - if (!equalsHelper( counterpart, considered, arr1[ctr], arr2[ctr] )) 4.575 - return false ; 4.576 - 4.577 - return true ; 4.578 - } 4.579 - 4.580 - private static boolean equalMaps( Map counterpart, Set considered, 4.581 - Map map1, Map map2 ) 4.582 - { 4.583 - if (map2.size() != map1.size()) 4.584 - return false; 4.585 - 4.586 - try { 4.587 - Iterator i = map1.entrySet().iterator(); 4.588 - while (i.hasNext()) { 4.589 - Entry e = (Entry) i.next(); 4.590 - java.lang.Object key = e.getKey(); 4.591 - java.lang.Object value = e.getValue(); 4.592 - if (value == null) { 4.593 - if (!(map2.get(key)==null && map2.containsKey(key))) 4.594 - return false; 4.595 - } else { 4.596 - if (!equalsHelper( counterpart, considered, 4.597 - value, map2.get(key))) 4.598 - return false; 4.599 - } 4.600 - } 4.601 - } catch(ClassCastException unused) { 4.602 - return false; 4.603 - } catch(NullPointerException unused) { 4.604 - return false; 4.605 - } 4.606 - 4.607 - return true; 4.608 - } 4.609 - 4.610 - // Obviously this is an inefficient quadratic algorithm. 4.611 - // This is taken pretty directly from AbstractSet and AbstractCollection 4.612 - // in the JDK. 4.613 - // For HashSet, an O(n) (with a good hash function) algorithm 4.614 - // is possible, and likewise TreeSet, since it is 4.615 - // ordered, is O(n). But this is not worth the effort here. 4.616 - // Note that the inner loop uses equals, not equalsHelper. 4.617 - // This is needed because of the searching behavior of this test. 4.618 - // However, note that this will NOT correctly handle sets that 4.619 - // contain themselves as members, or that have members that reference 4.620 - // themselves. These cases will cause infinite regress! 4.621 - private static boolean equalSets( Map counterpart, Set considered, 4.622 - Set set1, Set set2 ) 4.623 - { 4.624 - if (set1.size() != set2.size()) 4.625 - return false ; 4.626 - 4.627 - Iterator e1 = set1.iterator() ; 4.628 - while (e1.hasNext()) { 4.629 - java.lang.Object obj1 = e1.next() ; 4.630 - 4.631 - boolean found = false ; 4.632 - Iterator e2 = set2.iterator() ; 4.633 - while (e2.hasNext() && !found) { 4.634 - java.lang.Object obj2 = e2.next() ; 4.635 - found = equals( obj1, obj2 ) ; 4.636 - } 4.637 - 4.638 - if (!found) 4.639 - return false ; 4.640 - } 4.641 - 4.642 - return true ; 4.643 - } 4.644 - 4.645 - private static boolean equalLists( Map counterpart, Set considered, 4.646 - List list1, List list2 ) 4.647 - { 4.648 - ListIterator e1 = list1.listIterator(); 4.649 - ListIterator e2 = list2.listIterator(); 4.650 - while(e1.hasNext() && e2.hasNext()) { 4.651 - java.lang.Object o1 = e1.next(); 4.652 - java.lang.Object o2 = e2.next(); 4.653 - if (!(o1==null ? o2==null : equalsHelper( 4.654 - counterpart, considered, o1, o2))) 4.655 - return false; 4.656 - } 4.657 - return !(e1.hasNext() || e2.hasNext()); 4.658 - } 4.659 }
5.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java Fri Sep 24 16:38:05 2010 -0700 5.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java Fri Sep 24 22:42:14 2010 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -33,14 +33,7 @@ 5.11 import java.nio.channels.SelectionKey; 5.12 import java.nio.channels.ServerSocketChannel; 5.13 import java.nio.channels.SocketChannel; 5.14 -import java.security.AccessController; 5.15 -import java.security.PrivilegedAction; 5.16 -import java.util.Collection; 5.17 import java.util.Iterator; 5.18 -import java.util.LinkedList; 5.19 - 5.20 -import org.omg.CORBA.CompletionStatus; 5.21 -import org.omg.CORBA.INTERNAL; 5.22 5.23 import com.sun.corba.se.pept.broker.Broker; 5.24 import com.sun.corba.se.pept.encoding.InputObject; 5.25 @@ -61,18 +54,12 @@ 5.26 import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate ; 5.27 import com.sun.corba.se.spi.ior.iiop.GIOPVersion ; 5.28 import com.sun.corba.se.spi.ior.iiop.AlternateIIOPAddressComponent; 5.29 -import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo; 5.30 import com.sun.corba.se.spi.logging.CORBALogDomains; 5.31 -import com.sun.corba.se.spi.monitoring.LongMonitoredAttributeBase; 5.32 -import com.sun.corba.se.spi.monitoring.MonitoringConstants; 5.33 -import com.sun.corba.se.spi.monitoring.MonitoringFactories; 5.34 -import com.sun.corba.se.spi.monitoring.MonitoredObject; 5.35 import com.sun.corba.se.spi.orb.ORB; 5.36 import com.sun.corba.se.spi.orbutil.threadpool.Work; 5.37 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 5.38 import com.sun.corba.se.spi.transport.CorbaAcceptor; 5.39 import com.sun.corba.se.spi.transport.CorbaConnection; 5.40 -import com.sun.corba.se.spi.transport.CorbaContactInfo; 5.41 import com.sun.corba.se.spi.transport.SocketInfo; 5.42 import com.sun.corba.se.spi.transport.SocketOrChannelAcceptor; 5.43 5.44 @@ -82,7 +69,6 @@ 5.45 import com.sun.corba.se.impl.oa.poa.Policies; // REVISIT impl/poa specific 5.46 import com.sun.corba.se.impl.orbutil.ORBConstants; 5.47 import com.sun.corba.se.impl.orbutil.ORBUtility; 5.48 -import com.sun.corba.se.impl.ior.iiop.JavaSerializationComponent; 5.49 5.50 // BEGIN Legacy support. 5.51 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo; 5.52 @@ -442,12 +428,7 @@ 5.53 dprint(".doWork->: " + this); 5.54 } 5.55 if (selectionKey.isAcceptable()) { 5.56 - AccessController.doPrivileged(new PrivilegedAction() { 5.57 - public java.lang.Object run() { 5.58 accept(); 5.59 - return null; 5.60 - } 5.61 - }); 5.62 } else { 5.63 if (orb.transportDebugFlag) { 5.64 dprint(".doWork: ! selectionKey.isAcceptable: " + this);
6.1 --- a/src/share/classes/com/sun/corba/se/spi/orb/OperationFactory.java Fri Sep 24 16:38:05 2010 -0700 6.2 +++ b/src/share/classes/com/sun/corba/se/spi/orb/OperationFactory.java Fri Sep 24 22:42:14 2010 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -25,6 +25,7 @@ 6.11 package com.sun.corba.se.spi.orb ; 6.12 6.13 import java.util.StringTokenizer ; 6.14 +import java.util.Arrays ; 6.15 6.16 import java.lang.reflect.Array ; 6.17 6.18 @@ -446,7 +447,7 @@ 6.19 public String toString() { 6.20 return "sequenceAction(separator=\"" + sep + 6.21 "\",actions=" + 6.22 - ObjectUtility.compactObjectToString(actions) + ")" ; 6.23 + Arrays.toString(actions) + ")" ; 6.24 } 6.25 } 6.26 6.27 @@ -533,7 +534,7 @@ 6.28 6.29 public String toString() { 6.30 return "mapSequenceAction(" + 6.31 - ObjectUtility.compactObjectToString(op) + ")" ; 6.32 + Arrays.toString(op) + ")" ; 6.33 } 6.34 } 6.35
7.1 --- a/src/share/classes/com/sun/corba/se/spi/orb/ParserImplBase.java Fri Sep 24 16:38:05 2010 -0700 7.2 +++ b/src/share/classes/com/sun/corba/se/spi/orb/ParserImplBase.java Fri Sep 24 22:42:14 2010 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -125,7 +125,7 @@ 7.11 // Since exc wraps the actual exception, use exc.getCause() 7.12 // instead of exc. 7.13 throw wrapper.errorSettingField( exc.getCause(), name, 7.14 - ObjectUtility.compactObjectToString(value) ) ; 7.15 + value.toString() ) ; 7.16 } 7.17 } 7.18