1. /*
  2. * @(#)ValueHandlerImpl_1_3.java 1.8 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. /*
  8. * Licensed Materials - Property of IBM
  9. * RMI-IIOP v1.0
  10. * Copyright IBM Corp. 1998 1999 All Rights Reserved
  11. *
  12. * US Government Users Restricted Rights - Use, duplication or
  13. * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  14. */
  15. package com.sun.corba.se.internal.orbutil;
  16. import javax.rmi.CORBA.Util;
  17. import javax.rmi.PortableRemoteObject;
  18. import java.util.Hashtable;
  19. import java.util.Stack;
  20. import java.io.IOException;
  21. import java.util.EmptyStackException;
  22. import com.sun.corba.se.internal.util.Utility;
  23. import com.sun.corba.se.internal.io.IIOPInputStream;
  24. import com.sun.corba.se.internal.io.IIOPOutputStream;
  25. import com.sun.corba.se.internal.util.MinorCodes;
  26. import com.sun.corba.se.internal.util.RepositoryId;
  27. import com.sun.corba.se.internal.util.Utility;
  28. import org.omg.CORBA.TCKind;
  29. import org.omg.CORBA.MARSHAL;
  30. import org.omg.CORBA.CompletionStatus;
  31. import org.omg.CORBA.portable.IndirectionException;
  32. import com.sun.org.omg.SendingContext.CodeBase;
  33. import java.security.AccessController;
  34. import java.security.PrivilegedAction;
  35. /**
  36. * This class overrides behavior of our current ValueHandlerImpl to
  37. * provide backwards compatibility with JDK 1.3.0.
  38. */
  39. public class ValueHandlerImpl_1_3 extends com.sun.corba.se.internal.io.ValueHandlerImpl {
  40. public ValueHandlerImpl_1_3(){
  41. super();
  42. }
  43. public ValueHandlerImpl_1_3(boolean isInputStream) {
  44. super(isInputStream);
  45. }
  46. /**
  47. * Writes the value to the stream using java semantics.
  48. * @param out The stream to write the value to
  49. * @param value The value to be written to the stream
  50. **/
  51. public void writeValue(org.omg.CORBA.portable.OutputStream _out, java.io.Serializable value) {
  52. super.writeValue(_out, value);
  53. }
  54. /**
  55. * Reads a value from the stream using java semantics.
  56. * @param in The stream to read the value from
  57. * @param clazz The type of the value to be read in
  58. * @param sender The sending context runtime
  59. **/
  60. public java.io.Serializable readValue(org.omg.CORBA.portable.InputStream _in,
  61. int offset,
  62. java.lang.Class clazz,
  63. String repositoryID,
  64. org.omg.SendingContext.RunTime _sender)
  65. {
  66. return super.readValue(_in, offset, clazz, repositoryID, _sender);
  67. }
  68. /**
  69. * Returns the repository ID for the given RMI value Class.
  70. * @param clz The class to return a repository ID for.
  71. * @return the repository ID of the Class.
  72. **/
  73. public java.lang.String getRMIRepositoryID(java.lang.Class clz) {
  74. return RepositoryId_1_3.createForJavaType(clz);
  75. }
  76. /**
  77. * Indicates whether the given Class performs custom or
  78. * default marshaling.
  79. * @param clz The class to test for custom marshaling.
  80. * @return True if the class performs custom marshaling, false
  81. * if it does not.
  82. **/
  83. public boolean isCustomMarshaled(java.lang.Class clz) {
  84. return super.isCustomMarshaled(clz);
  85. }
  86. /**
  87. * Returns the CodeBase for this ValueHandler. This is used by
  88. * the ORB runtime. The server sends the service context containing
  89. * the IOR for this CodeBase on the first GIOP reply. The clients
  90. * do the same on the first GIOP request.
  91. * @return the SendingContext.CodeBase of this ValueHandler.
  92. **/
  93. public org.omg.SendingContext.RunTime getRunTimeCodeBase() {
  94. return super.getRunTimeCodeBase();
  95. }
  96. /**
  97. * If the value contains a writeReplace method then the result
  98. * is returned. Otherwise, the value itself is returned.
  99. * @return the true value to marshal on the wire.
  100. **/
  101. public java.io.Serializable writeReplace(java.io.Serializable value) {
  102. return super.writeReplace(value);
  103. }
  104. // methods supported for backward compatability so that the appropriate
  105. // Rep-id calculations take place based on the ORB version
  106. /**
  107. * Returns a boolean of whether or not RepositoryId indicates
  108. * FullValueDescriptor.
  109. * used for backward compatability
  110. */
  111. public boolean useFullValueDescription(Class clazz, String repositoryID)
  112. throws IOException
  113. {
  114. return RepositoryId_1_3.useFullValueDescription(clazz, repositoryID);
  115. }
  116. public String getClassName(String id)
  117. {
  118. RepositoryId_1_3 repID = RepositoryId_1_3.cache.getId(id);
  119. return repID.getClassName();
  120. }
  121. public Class getClassFromType(String id)
  122. throws ClassNotFoundException
  123. {
  124. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  125. return repId.getClassFromType();
  126. }
  127. public Class getAnyClassFromType(String id)
  128. throws ClassNotFoundException
  129. {
  130. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  131. return repId.getAnyClassFromType();
  132. }
  133. public String createForAnyType(Class cl)
  134. {
  135. return RepositoryId_1_3.createForAnyType(cl);
  136. }
  137. public String getDefinedInId(String id)
  138. {
  139. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  140. return repId.getDefinedInId();
  141. }
  142. public String getUnqualifiedName(String id)
  143. {
  144. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  145. return repId.getUnqualifiedName();
  146. }
  147. public String getSerialVersionUID(String id)
  148. {
  149. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  150. return repId.getSerialVersionUID();
  151. }
  152. public boolean isAbstractBase(Class clazz)
  153. {
  154. return RepositoryId_1_3.isAbstractBase(clazz);
  155. }
  156. public boolean isSequence(String id)
  157. {
  158. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  159. return repId.isSequence();
  160. }
  161. /**
  162. * Preserves the incorrect 1.3 behavior which truncates Java chars in
  163. * arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
  164. * continue interoperating with our legacy ORBs. If this goes into
  165. * Ladybird, then Ladybird and Kestrel will interoperate as long as
  166. * people don't use chars greater than 8-bits.
  167. */
  168. protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
  169. char[] array,
  170. int offset,
  171. int length)
  172. {
  173. out.write_char_array(array, offset, length);
  174. }
  175. /**
  176. * Preserves the incorrect 1.3 behavior which truncates Java chars in
  177. * arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
  178. * continue interoperating with our legacy ORBs. If this goes into
  179. * Ladybird, then Ladybird and Kestrel will interoperate as long as
  180. * people don't use chars greater than 8-bits.
  181. */
  182. protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
  183. char[] array,
  184. int offset,
  185. int length)
  186. {
  187. in.read_char_array(array, offset, length);
  188. }
  189. protected final String getOutputStreamClassName() {
  190. return "com.sun.corba.se.internal.orbutil.IIOPOutputStream_1_3";
  191. }
  192. protected final String getInputStreamClassName() {
  193. return "com.sun.corba.se.internal.orbutil.IIOPInputStream_1_3";
  194. }
  195. /**
  196. * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
  197. * The correct behavior is for a Java char to map to a CORBA wchar,
  198. * but our older code mapped it to a CORBA char.
  199. */
  200. protected TCKind getJavaCharTCKind() {
  201. return TCKind.tk_char;
  202. }
  203. }