1. /*
  2. * @(#)ORBUtility.java 1.18 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. package com.sun.corba.se.internal.orbutil;
  8. import java.util.Hashtable;
  9. import java.util.Enumeration;
  10. import java.util.Properties;
  11. import java.lang.reflect.Field;
  12. import javax.rmi.CORBA.ValueHandler;
  13. import javax.rmi.CORBA.Util;
  14. import org.omg.CORBA.*;
  15. import org.omg.CORBA.portable.*;
  16. import org.omg.CORBA.TypeCodePackage.*;
  17. import java.rmi.NoSuchObjectException;
  18. import java.util.NoSuchElementException;
  19. import com.sun.corba.se.internal.orbutil.MinorCodes;
  20. import com.sun.corba.se.internal.core.ORBVersion ;
  21. import com.sun.corba.se.internal.core.ORBVersionImpl ;
  22. /**
  23. * Handy class full of static functions that don't belong in util.Utility for pure ORB reasons.
  24. */
  25. public final class ORBUtility {
  26. private ORBUtility() {}
  27. private static StructMember[] members = null;
  28. private static StructMember[] systemExceptionMembers (ORB orb) {
  29. if (members == null) {
  30. members = new StructMember[3];
  31. members[0] = new StructMember("id", orb.create_string_tc(0), null);
  32. members[1] = new StructMember("minor", orb.get_primitive_tc(TCKind.tk_long), null);
  33. members[2] = new StructMember("completed", orb.get_primitive_tc(TCKind.tk_long), null);
  34. }
  35. return members;
  36. }
  37. private static TypeCode getSystemExceptionTypeCode(ORB orb, String repID, String name) {
  38. synchronized (TypeCode.class) {
  39. return orb.create_exception_tc(repID, name, systemExceptionMembers(orb));
  40. }
  41. }
  42. private static boolean isSystemExceptionTypeCode(TypeCode type, ORB orb) {
  43. StructMember[] systemExceptionMembers = systemExceptionMembers(orb);
  44. try {
  45. return (type.kind().value() == TCKind._tk_except &&
  46. type.member_count() == 3 &&
  47. type.member_type(0).equal(systemExceptionMembers[0].type) &&
  48. type.member_type(1).equal(systemExceptionMembers[1].type) &&
  49. type.member_type(2).equal(systemExceptionMembers[2].type));
  50. } catch (BadKind ex) {
  51. return false;
  52. } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) {
  53. return false;
  54. }
  55. }
  56. /**
  57. * Static method for writing a CORBA standard exception to an Any.
  58. * @param any The Any to write the SystemException into.
  59. */
  60. public static void insertSystemException(SystemException ex, Any any) {
  61. OutputStream out = any.create_output_stream();
  62. ORB orb = out.orb();
  63. String name = ex.getClass().getName();
  64. String repID = ORBUtility.repositoryIdOf(name);
  65. out.write_string(repID);
  66. out.write_long(ex.minor);
  67. out.write_long(ex.completed.value());
  68. any.read_value(out.create_input_stream(),
  69. getSystemExceptionTypeCode(orb, repID, name));
  70. }
  71. public static SystemException extractSystemException(Any any) {
  72. InputStream in = any.create_input_stream();
  73. ORB orb = in.orb();
  74. if ( ! isSystemExceptionTypeCode(any.type(), orb)) {
  75. return new org.omg.CORBA.UNKNOWN(MinorCodes.UNKNOWN_DSI_SYSEX,
  76. CompletionStatus.COMPLETED_MAYBE);
  77. }
  78. return ORBUtility.readSystemException(in);
  79. }
  80. /**
  81. * Creates the correct ValueHandler for the given ORB,
  82. * querying ORBVersion information. If the ORB or
  83. * ORBVersion is null, gets the ValueHandler from
  84. * Util.createValueHandler.
  85. */
  86. public static ValueHandler createValueHandler(com.sun.corba.se.internal.corba.ORB orb) {
  87. if (orb == null)
  88. return Util.createValueHandler();
  89. ORBVersion version = orb.getORBVersion();
  90. if (version == null)
  91. return Util.createValueHandler();
  92. if (version.equals(ORBVersionImpl.OLD))
  93. return new ValueHandlerImpl_1_3();
  94. if (version.equals(ORBVersionImpl.NEW))
  95. return new ValueHandlerImpl_1_3_1();
  96. return Util.createValueHandler();
  97. }
  98. /**
  99. * Returns true if the given ORB could accurately be determined to be a
  100. * Kestrel or earlier ORB. Note: If passed the ORBSingleton, this will return
  101. * false.
  102. */
  103. public static boolean isLegacyORB(com.sun.corba.se.internal.corba.ORB orb)
  104. {
  105. try {
  106. ORBVersion currentORB = orb.getORBVersion();
  107. return currentORB.equals( ORBVersionImpl.OLD ) ;
  108. } catch (SecurityException se) {
  109. return false;
  110. }
  111. }
  112. /**
  113. * Returns true if it was accurately determined that the remote ORB is
  114. * a foreign (non-JavaSoft) ORB. Note: If passed the ORBSingleton, this
  115. * will return false.
  116. */
  117. public static boolean isForeignORB(com.sun.corba.se.internal.corba.ORB orb)
  118. {
  119. if (orb == null)
  120. return false;
  121. try {
  122. return orb.getORBVersion().equals(ORBVersionImpl.FOREIGN);
  123. } catch (SecurityException se) {
  124. return false;
  125. }
  126. }
  127. /** Unmarshal a byte array to an integer.
  128. Assume the bytes are in BIGENDIAN order.
  129. i.e. array[offset] is the most-significant-byte
  130. and array[offset+3] is the least-significant-byte.
  131. @param array The array of bytes.
  132. @param offset The offset from which to start unmarshalling.
  133. */
  134. public static int bytesToInt(byte[] array, int offset)
  135. {
  136. int b1, b2, b3, b4;
  137. b1 = (array[offset++] << 24) & 0xFF000000;
  138. b2 = (array[offset++] << 16) & 0x00FF0000;
  139. b3 = (array[offset++] << 8) & 0x0000FF00;
  140. b4 = (array[offset++] << 0) & 0x000000FF;
  141. return (b1 | b2 | b3 | b4);
  142. }
  143. /** Marshal an integer to a byte array.
  144. The bytes are in BIGENDIAN order.
  145. i.e. array[offset] is the most-significant-byte
  146. and array[offset+3] is the least-significant-byte.
  147. @param array The array of bytes.
  148. @param offset The offset from which to start marshalling.
  149. */
  150. public static void intToBytes(int value, byte[] array, int offset)
  151. {
  152. array[offset++] = (byte)((value >>> 24) & 0xFF);
  153. array[offset++] = (byte)((value >>> 16) & 0xFF);
  154. array[offset++] = (byte)((value >>> 8) & 0xFF);
  155. array[offset++] = (byte)((value >>> 0) & 0xFF);
  156. }
  157. /** Converts an Ascii Character into Hexadecimal digit
  158. */
  159. public static int hexOf( char x )
  160. {
  161. int val;
  162. val = x - '0';
  163. if (val >=0 && val <= 9)
  164. return val;
  165. val = (x - 'a') + 10;
  166. if (val >= 10 && val <= 15)
  167. return val;
  168. val = (x - 'A') + 10;
  169. if (val >= 10 && val <= 15)
  170. return val;
  171. throw new DATA_CONVERSION(MinorCodes.BAD_HEX_DIGIT,
  172. CompletionStatus.COMPLETED_NO);
  173. }
  174. // method moved from util.Utility
  175. /**
  176. * Static method for writing a CORBA standard exception to a stream.
  177. * @param strm The OutputStream to use for marshaling.
  178. */
  179. public static void writeSystemException(SystemException ex, OutputStream strm)
  180. {
  181. String s;
  182. s = repositoryIdOf(ex.getClass().getName());
  183. strm.write_string(s);
  184. strm.write_long(ex.minor);
  185. strm.write_long(ex.completed.value());
  186. }
  187. /**
  188. * Static method for reading a CORBA standard exception from a stream.
  189. * @param strm The InputStream to use for unmarshaling.
  190. */
  191. public static SystemException readSystemException(InputStream strm)
  192. {
  193. try {
  194. String name = classNameOf(strm.read_string());
  195. SystemException ex
  196. = (SystemException)ORBClassLoader.loadClass(name).newInstance();
  197. ex.minor = strm.read_long();
  198. ex.completed = CompletionStatus.from_int(strm.read_long());
  199. return ex;
  200. } catch ( Exception ex ) {
  201. return new org.omg.CORBA.UNKNOWN(MinorCodes.UNKNOWN_SYSEX,
  202. CompletionStatus.COMPLETED_MAYBE);
  203. }
  204. }
  205. /**
  206. * Get the class name corresponding to a particular repository Id.
  207. * This is used by the system to unmarshal (instantiate) the
  208. * appropriate exception class for an marshaled as the value of
  209. * its repository Id.
  210. * @param repositoryId The repository Id for which we want a class name.
  211. */
  212. public static String classNameOf(String repositoryId)
  213. {
  214. String className=null;
  215. className = (String) exceptionClassNames.get(repositoryId);
  216. if (className == null)
  217. className = "org.omg.CORBA.UNKNOWN";
  218. return className;
  219. }
  220. /**
  221. * Return true if this repositoryId is a SystemException.
  222. * @param repositoryId The repository Id to check.
  223. */
  224. public static boolean isSystemException(String repositoryId)
  225. {
  226. String className=null;
  227. className = (String) exceptionClassNames.get(repositoryId);
  228. if (className == null)
  229. return false;
  230. else
  231. return true;
  232. }
  233. /**
  234. * Get the repository id corresponding to a particular class.
  235. * This is used by the system to write the
  236. * appropriate repository id for a system exception.
  237. * @param name The class name of the system exception.
  238. */
  239. public static String repositoryIdOf(String name)
  240. {
  241. String id;
  242. id = (String) exceptionRepositoryIds.get(name);
  243. if (id == null)
  244. id = "IDL:omg.org/CORBA/UNKNOWN:1.0";
  245. return id;
  246. }
  247. private static final Hashtable exceptionClassNames = new Hashtable();
  248. private static final Hashtable exceptionRepositoryIds = new Hashtable();
  249. static {
  250. //
  251. // construct repositoryId -> className hashtable
  252. //
  253. exceptionClassNames.put("IDL:omg.org/CORBA/BAD_CONTEXT:1.0",
  254. "org.omg.CORBA.BAD_CONTEXT");
  255. exceptionClassNames.put("IDL:omg.org/CORBA/BAD_INV_ORDER:1.0",
  256. "org.omg.CORBA.BAD_INV_ORDER");
  257. exceptionClassNames.put("IDL:omg.org/CORBA/BAD_OPERATION:1.0",
  258. "org.omg.CORBA.BAD_OPERATION");
  259. exceptionClassNames.put("IDL:omg.org/CORBA/BAD_PARAM:1.0",
  260. "org.omg.CORBA.BAD_PARAM");
  261. exceptionClassNames.put("IDL:omg.org/CORBA/BAD_TYPECODE:1.0",
  262. "org.omg.CORBA.BAD_TYPECODE");
  263. exceptionClassNames.put("IDL:omg.org/CORBA/COMM_FAILURE:1.0",
  264. "org.omg.CORBA.COMM_FAILURE");
  265. exceptionClassNames.put("IDL:omg.org/CORBA/DATA_CONVERSION:1.0",
  266. "org.omg.CORBA.DATA_CONVERSION");
  267. exceptionClassNames.put("IDL:omg.org/CORBA/IMP_LIMIT:1.0",
  268. "org.omg.CORBA.IMP_LIMIT");
  269. exceptionClassNames.put("IDL:omg.org/CORBA/INTF_REPOS:1.0",
  270. "org.omg.CORBA.INTF_REPOS");
  271. exceptionClassNames.put("IDL:omg.org/CORBA/INTERNAL:1.0",
  272. "org.omg.CORBA.INTERNAL");
  273. exceptionClassNames.put("IDL:omg.org/CORBA/INV_FLAG:1.0",
  274. "org.omg.CORBA.INV_FLAG");
  275. exceptionClassNames.put("IDL:omg.org/CORBA/INV_IDENT:1.0",
  276. "org.omg.CORBA.INV_IDENT");
  277. exceptionClassNames.put("IDL:omg.org/CORBA/INV_OBJREF:1.0",
  278. "org.omg.CORBA.INV_OBJREF");
  279. exceptionClassNames.put("IDL:omg.org/CORBA/MARSHAL:1.0",
  280. "org.omg.CORBA.MARSHAL");
  281. exceptionClassNames.put("IDL:omg.org/CORBA/NO_MEMORY:1.0",
  282. "org.omg.CORBA.NO_MEMORY");
  283. exceptionClassNames.put("IDL:omg.org/CORBA/FREE_MEM:1.0",
  284. "org.omg.CORBA.FREE_MEM");
  285. exceptionClassNames.put("IDL:omg.org/CORBA/NO_IMPLEMENT:1.0",
  286. "org.omg.CORBA.NO_IMPLEMENT");
  287. exceptionClassNames.put("IDL:omg.org/CORBA/NO_PERMISSION:1.0",
  288. "org.omg.CORBA.NO_PERMISSION");
  289. exceptionClassNames.put("IDL:omg.org/CORBA/NO_RESOURCES:1.0",
  290. "org.omg.CORBA.NO_RESOURCES");
  291. exceptionClassNames.put("IDL:omg.org/CORBA/NO_RESPONSE:1.0",
  292. "org.omg.CORBA.NO_RESPONSE");
  293. exceptionClassNames.put("IDL:omg.org/CORBA/OBJ_ADAPTER:1.0",
  294. "org.omg.CORBA.OBJ_ADAPTER");
  295. exceptionClassNames.put("IDL:omg.org/CORBA/INITIALIZE:1.0",
  296. "org.omg.CORBA.INITIALIZE");
  297. exceptionClassNames.put("IDL:omg.org/CORBA/PERSIST_STORE:1.0",
  298. "org.omg.CORBA.PERSIST_STORE");
  299. exceptionClassNames.put("IDL:omg.org/CORBA/TRANSIENT:1.0",
  300. "org.omg.CORBA.TRANSIENT");
  301. exceptionClassNames.put("IDL:omg.org/CORBA/UNKNOWN:1.0",
  302. "org.omg.CORBA.UNKNOWN");
  303. exceptionClassNames.put("IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0",
  304. "org.omg.CORBA.OBJECT_NOT_EXIST");
  305. // SystemExceptions from OMG Transactions Service Spec
  306. exceptionClassNames.put("IDL:omg.org/CORBA/INVALID_TRANSACTION:1.0",
  307. "org.omg.CORBA.INVALID_TRANSACTION");
  308. exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_REQUIRED:1.0",
  309. "org.omg.CORBA.TRANSACTION_REQUIRED");
  310. exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_ROLLEDBACK:1.0",
  311. "org.omg.CORBA.TRANSACTION_ROLLEDBACK");
  312. // from portability RTF 98-07-01.txt
  313. exceptionClassNames.put("IDL:omg.org/CORBA/INV_POLICY:1.0",
  314. "org.omg.CORBA.INV_POLICY");
  315. // from orbrev/00-09-01 (CORBA 2.4 Draft Specification)
  316. exceptionClassNames.
  317. put("IDL:omg.org/CORBA/TRANSACTION_UNAVAILABLE:1.0",
  318. "org.omg.CORBA.TRANSACTION_UNAVAILABLE");
  319. exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_MODE:1.0",
  320. "org.omg.CORBA.TRANSACTION_MODE");
  321. //
  322. // construct className -> repositoryId hashtable
  323. //
  324. Enumeration keys = exceptionClassNames.keys();
  325. java.lang.Object s;
  326. String rId;
  327. String cName;
  328. try{
  329. while (keys.hasMoreElements()) {
  330. s = keys.nextElement();
  331. rId = (String) s;
  332. cName = (String) exceptionClassNames.get(rId);
  333. exceptionRepositoryIds.put (cName, rId);
  334. }
  335. } catch (NoSuchElementException e) { }
  336. }
  337. /** Parse a version string such as "1.1.6" or "jdk1.2fcs" into
  338. a version array of integers {1, 1, 6} or {1, 2}.
  339. A string of "n." or "n..m" is equivalent to "n.0" or "n.0.m" respectively.
  340. */
  341. public static int[] parseVersion(String version) {
  342. if (version == null)
  343. return new int[0];
  344. char[] s = version.toCharArray();
  345. //find the maximum span of the string "n.n.n..." where n is an integer
  346. int start = 0;
  347. for (; start < s.length && (s[start] < '0' || s[start] > '9'); ++start)
  348. if (start == s.length) //no digit found
  349. return new int[0];
  350. int end = start + 1;
  351. int size = 1;
  352. for (; end < s.length; ++end)
  353. if (s[end] == '.')
  354. ++size;
  355. else if (s[end] < '0' || s[end] > '9')
  356. break;
  357. int[] val = new int[size];
  358. for (int i = 0; i < size; ++i) {
  359. int dot = version.indexOf('.', start);
  360. if (dot == -1 || dot > end)
  361. dot = end;
  362. if (start >= dot) //cases like "n." or "n..m"
  363. val[i] = 0; //convert equivalent to "n.0" or "n.0.m"
  364. else
  365. val[i] = Integer.parseInt(version.substring(start, dot));
  366. start = dot + 1;
  367. }
  368. return val;
  369. }
  370. /** Compare two version arrays.
  371. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.
  372. */
  373. public static int compareVersion(int[] v1, int[] v2) {
  374. if (v1 == null)
  375. v1 = new int[0];
  376. if (v2 == null)
  377. v2 = new int[0];
  378. for (int i = 0; i < v1.length; ++i) {
  379. if (i >= v2.length || v1[i] > v2[i]) //v1 is longer or greater than v2
  380. return 1;
  381. if (v1[i] < v2[i])
  382. return -1;
  383. }
  384. return v1.length == v2.length ? 0 : -1;
  385. }
  386. /** Compare two version strings.
  387. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.
  388. */
  389. public static int compareVersion(String v1, String v2) {
  390. return compareVersion(parseVersion(v1), parseVersion(v2));
  391. }
  392. /** A smarter toString that uses the built-in toString.
  393. * If obj isA:
  394. * Object that supports toString() directly: call toString
  395. * array of objects: array[length]( toString results of non-null elements )
  396. * other: print the contents of the object's public fields.
  397. * Note that this method is NOT SAFE FOR USE WITH CIRCULAR REFERENCES!
  398. * It will go into an infinite recursion if handed the top level
  399. * reference to a cyclic graph of objects.
  400. */
  401. public static String objectToString(java.lang.Object obj)
  402. {
  403. if (obj==null)
  404. return "null" ;
  405. StringBuffer result = new StringBuffer() ;
  406. Class cls = obj.getClass() ;
  407. Class compClass = cls.getComponentType() ;
  408. if (obj instanceof java.util.Properties) {
  409. Properties props = (Properties)obj ;
  410. result.append( cls.getName() ) ;
  411. result.append( "(" ) ;
  412. Enumeration keys = props.propertyNames() ;
  413. while (keys.hasMoreElements()) {
  414. String key = (String)(keys.nextElement()) ;
  415. String value = props.getProperty( key ) ;
  416. result.append( " " ) ;
  417. result.append( key ) ;
  418. result.append( "=" ) ;
  419. result.append( value ) ;
  420. }
  421. result.append( " )" ) ;
  422. return result.toString() ;
  423. }
  424. try {
  425. // If class of obj directly declares toString(), use it.
  426. cls.getDeclaredMethod( "toString", null ) ;
  427. return obj.toString() ;
  428. } catch (Exception exc) {
  429. if (compClass == null) {
  430. // Must be some reference type, so use reflection to print fields
  431. Field[] fields ;
  432. try {
  433. fields = cls.getFields() ;
  434. } catch (SecurityException sexc) {
  435. // Can't get fields, so use default toString()
  436. return obj.toString() ;
  437. }
  438. result.append( cls.getName() ) ;
  439. result.append( "(" ) ;
  440. for (int ctr=0; ctr<fields.length; ctr++ ) {
  441. Field fld = fields[ctr] ;
  442. result.append( " " ) ;
  443. result.append( fld.getName() ) ;
  444. result.append( "=" ) ;
  445. try {
  446. java.lang.Object value = fld.get( obj ) ;
  447. result.append( objectToString( value ) ) ;
  448. } catch (Exception exc2) {
  449. result.append( "???" ) ;
  450. }
  451. }
  452. result.append( " )" ) ;
  453. return result.toString() ;
  454. } else // we have an array
  455. result.append( compClass.getName() ) ;
  456. result.append( "[" ) ;
  457. if (compClass == boolean.class) {
  458. boolean[] arr = (boolean[])obj ;
  459. result.append( arr.length ) ;
  460. result.append( "](" ) ;
  461. for (int ctr=0; ctr<arr.length; ctr++) {
  462. result.append( " " ) ;
  463. result.append( arr[ctr] ) ;
  464. }
  465. } else if (compClass == byte.class) {
  466. byte[] arr = (byte[])obj ;
  467. result.append( arr.length ) ;
  468. result.append( "](" ) ;
  469. for (int ctr=0; ctr<arr.length; ctr++) {
  470. result.append( " " ) ;
  471. result.append( arr[ctr] ) ;
  472. }
  473. } else if (compClass == short.class) {
  474. short[] arr = (short[])obj ;
  475. result.append( arr.length ) ;
  476. result.append( "](" ) ;
  477. for (int ctr=0; ctr<arr.length; ctr++) {
  478. result.append( " " ) ;
  479. result.append( arr[ctr] ) ;
  480. }
  481. } else if (compClass == int.class) {
  482. int[] arr = (int[])obj ;
  483. result.append( arr.length ) ;
  484. result.append( "](" ) ;
  485. for (int ctr=0; ctr<arr.length; ctr++) {
  486. result.append( " " ) ;
  487. result.append( arr[ctr] ) ;
  488. }
  489. } else if (compClass == long.class) {
  490. long[] arr = (long[])obj ;
  491. result.append( arr.length ) ;
  492. result.append( "](" ) ;
  493. for (int ctr=0; ctr<arr.length; ctr++) {
  494. result.append( " " ) ;
  495. result.append( arr[ctr] ) ;
  496. }
  497. } else if (compClass == char.class) {
  498. char[] arr = (char[])obj ;
  499. result.append( arr.length ) ;
  500. result.append( "](" ) ;
  501. for (int ctr=0; ctr<arr.length; ctr++) {
  502. result.append( " " ) ;
  503. result.append( arr[ctr] ) ;
  504. }
  505. } else if (compClass == float.class) {
  506. float[] arr = (float[])obj ;
  507. result.append( arr.length ) ;
  508. result.append( "](" ) ;
  509. for (int ctr=0; ctr<arr.length; ctr++) {
  510. result.append( " " ) ;
  511. result.append( arr[ctr] ) ;
  512. }
  513. } else if (compClass == double.class) {
  514. double[] arr = (double[])obj ;
  515. result.append( arr.length ) ;
  516. result.append( "](" ) ;
  517. for (int ctr=0; ctr<arr.length; ctr++) {
  518. result.append( " " ) ;
  519. result.append( arr[ctr] ) ;
  520. }
  521. } else { // array of object
  522. java.lang.Object[] arr = (java.lang.Object[])obj ;
  523. result.append( arr.length ) ;
  524. result.append( "](" ) ;
  525. for (int ctr=0; ctr<arr.length; ctr++) {
  526. result.append( " " ) ;
  527. result.append( objectToString( arr[ctr] ) ) ;
  528. }
  529. }
  530. result.append( " ]" ) ;
  531. return result.toString() ;
  532. }
  533. }
  534. //
  535. // Implements all dprint calls in this package.
  536. //
  537. public static void dprint(java.lang.Object obj, String msg) {
  538. System.out.println(obj.getClass().getName() + "(" +
  539. Thread.currentThread() + "): " + msg);
  540. }
  541. public static void dprint(String className, String msg) {
  542. System.out.println(className + "(" +
  543. Thread.currentThread() + "): " + msg);
  544. }
  545. public void dprint(String msg) {
  546. ORBUtility.dprint(this, msg);
  547. }
  548. public static void dprint(java.lang.Object caller,
  549. String msg,
  550. Throwable t) {
  551. System.out.println(caller.getClass().getName() + '('
  552. + Thread.currentThread() + "): "
  553. + msg);
  554. if (t != null)
  555. t.printStackTrace();
  556. }
  557. public static String[] concatenateStringArrays( String[] arr1, String[] arr2 )
  558. {
  559. String[] result = new String[
  560. arr1.length + arr2.length ] ;
  561. for (int ctr = 0; ctr<arr1.length; ctr++)
  562. result[ctr] = arr1[ctr] ;
  563. for (int ctr = 0; ctr<arr2.length; ctr++)
  564. result[ctr + arr1.length] = arr2[ctr] ;
  565. return result ;
  566. }
  567. /**
  568. * Throws the CORBA equivalent of a java.io.NotSerializableException
  569. *
  570. * Duplicated from util/Utility for Pure ORB reasons. There are two
  571. * reasons for this:
  572. *
  573. * 1) We can't introduce dependencies on the util version from outside
  574. * of the io/util packages since it will not exist in the pure ORB
  575. * build running on JDK 1.3.x.
  576. *
  577. * 2) We need to pick up the correct minor code from orbutil.MinorCodes.
  578. * If we picked it up from util.MinorCodes, then it would have the
  579. * incorrect value when running the pure ORB on JDK 1.3.x.
  580. */
  581. public static void throwNotSerializableForCorba(String className) {
  582. throw new BAD_PARAM(className,
  583. MinorCodes.NOT_SERIALIZABLE,
  584. CompletionStatus.COMPLETED_MAYBE);
  585. }
  586. }