You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2008/02/29 16:28:44 UTC
svn commit: r632352 - in /geronimo/yoko/trunk:
core/src/main/java/org/apache/yoko/orb/CORBA/
core/src/main/java/org/apache/yoko/orb/OB/
core/src/main/java/org/apache/yoko/orb/OCI/ core/src/test/java/test/rmi/
rmi-impl/src/main/java/org/apache/yoko/rmi/...
Author: rickmcguire
Date: Fri Feb 29 07:28:38 2008
New Revision: 632352
URL: http://svn.apache.org/viewvc?rev=632352&view=rev
Log:
YOKO-418 Multiple problems marshalling object fields defined as java.util.List
Modified:
geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/Any.java
geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java
geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java
geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueFactoryManager.java
geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java
geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java
geronimo/yoko/trunk/core/src/test/java/test/rmi/ClientMain.java
geronimo/yoko/trunk/core/src/test/java/test/rmi/SampleSerializable.java
geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java
geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java
geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java
geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueHandlerImpl.java
geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/CompletionStatus.java
Modified: geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/Any.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/Any.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/Any.java (original)
+++ geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/Any.java Fri Feb 29 07:28:38 2008
@@ -17,11 +17,16 @@
package org.apache.yoko.orb.CORBA;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
import org.apache.yoko.orb.OB.MinorCodes;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.Object;
final public class Any extends org.omg.CORBA.Any {
+ static final Logger logger = Logger.getLogger(Any.class.getName());
+
private org.apache.yoko.orb.OB.ORBInstance orbInstance_;
private org.omg.CORBA.TypeCode type_;
@@ -93,6 +98,7 @@
private void readValue(org.omg.CORBA.portable.InputStream in) {
int kind = origType_.kind().value();
+ logger.fine("Reading ANY value of kind " + kind);
//
// Spec says that calling read_value when a Streamable has
// previously been inserted will update the Streamable
@@ -196,6 +202,11 @@
case org.omg.CORBA.TCKind._tk_abstract_interface: {
try {
InputStream is = (InputStream) in;
+// this is a useful tracepoint, but produces a lot of data, so turn on only
+// if really needed.
+// if (logger.isLoggable(Level.FINEST)) {
+// logger.finest("Reading value from \n\n" + is.dumpData());
+// }
is.read_value(this, type_);
} catch (ClassCastException ex) {
try {
Modified: geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java (original)
+++ geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java Fri Feb 29 07:28:38 2008
@@ -18,12 +18,14 @@
package org.apache.yoko.orb.CORBA;
import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.rmi.CORBA.Util;
import org.omg.SendingContext.CodeBase;
final public class InputStream extends org.omg.CORBA_2_3.portable.InputStream {
+ static final Logger logger = Logger.getLogger(InputStream.class.getName());
org.apache.yoko.orb.OB.ORBInstance orbInstance_;
public org.apache.yoko.orb.OCI.Buffer buf_;
@@ -81,6 +83,7 @@
java.util.Hashtable history, boolean isTopLevel) {
int kind = read_ulong();
int oldPos = buf_.pos_ - 4;
+ logger.finest("Reading a TypeCode of kind " + kind + " from position " + oldPos);
TypeCode tc = null;
if (kind == -1) {
@@ -135,6 +138,9 @@
case org.omg.CORBA.TCKind._tk_objref: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -160,6 +166,9 @@
case org.omg.CORBA.TCKind._tk_except: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -201,6 +210,9 @@
case org.omg.CORBA.TCKind._tk_union: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -291,6 +303,9 @@
case org.omg.CORBA.TCKind._tk_enum: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -357,6 +372,9 @@
case org.omg.CORBA.TCKind._tk_alias: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -383,6 +401,9 @@
case org.omg.CORBA.TCKind._tk_value: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -431,6 +452,9 @@
case org.omg.CORBA.TCKind._tk_value_box: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -456,11 +480,16 @@
case org.omg.CORBA.TCKind._tk_abstract_interface: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
String id = read_string();
+
+ logger.fine("Abstract interface typecode encapsulaton length=" + length + " id=" + id);
if (isTopLevel && cache_ != null)
tc = checkCache(id, typePos, length); // may advance pos
@@ -480,6 +509,9 @@
case org.omg.CORBA.TCKind._tk_native: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -504,6 +536,9 @@
case org.omg.CORBA_2_4.TCKind._tk_local_interface: {
int length = read_ulong(); // encapsulation length
// save this position after the read, since we might be on a chunk boundary.
+ // however, we do an explicit check for the chunk boundary before doing the
+ // read.
+ checkChunk();
int typePos = buf_.pos_;
boolean swap = swap_;
_OB_readEndian();
@@ -544,8 +579,7 @@
// reads wide-characters using the old non-compliant method
//
private char _OB_read_wchar_old() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
if (wCharConversionRequired_) {
final org.apache.yoko.orb.OB.CodeConverterBase converter = codeConverters_.inputWcharConverter;
@@ -631,9 +665,8 @@
// reads wide-characters using compliant method
//
private char _OB_read_wchar_new(boolean partOfString) {
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
+
char value;
final org.apache.yoko.orb.OB.CodeConverterBase converter = codeConverters_.inputWcharConverter;
@@ -778,9 +811,7 @@
private String _OB_read_wstring_old() {
String s = "";
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
int len = read_ulong();
//
@@ -900,9 +931,7 @@
//
private String _OB_read_wstring_new() {
String s = "";
-
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
final org.apache.yoko.orb.OB.CodeConverterBase converter = codeConverters_.inputWcharConverter;
@@ -911,6 +940,7 @@
// GIOP 1.0/1.1 and in octets for GIOP 1.2+)
//
int len = read_ulong();
+ logger.fine("Reading wstring of length " + len);
switch (GIOPVersion_) {
@@ -920,21 +950,23 @@
// it is not legal in GIOP 1.0/1.1 for a string to be 0 in
// length... it MUST have a null terminator
//
- if (len == 0)
+ if (len == 0) {
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorReadWStringZeroLength),
org.apache.yoko.orb.OB.MinorCodes.MinorReadWStringZeroLength,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+ }
char[] tmp = new char[len];
- if (wCharReaderRequired_)
- converter
- .set_reader_flags(org.apache.yoko.orb.OB.CodeSetReader.FIRST_CHAR);
+ if (wCharReaderRequired_) {
+ converter.set_reader_flags(org.apache.yoko.orb.OB.CodeSetReader.FIRST_CHAR);
+ }
- for (int i = 0; i < len; i++)
+ for (int i = 0; i < len; i++) {
tmp[i] = read_wchar(true);
+ }
//
// Check for terminating null wchar
@@ -1077,9 +1109,7 @@
}
public int read() throws java.io.IOException {
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
if (buf_.pos_ + 1 > buf_.len_)
return -1;
@@ -1093,23 +1123,22 @@
}
public boolean read_boolean() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
- if (buf_.pos_ + 1 > buf_.len_)
+ if (buf_.pos_ + 1 > buf_.len_) {
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorReadBooleanOverflow),
org.apache.yoko.orb.OB.MinorCodes.MinorReadBooleanOverflow,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+ }
+ logger.finest("Boolean value is " + buf_.data_[buf_.pos_] + " from position " + buf_.pos_);
return buf_.data_[buf_.pos_++] != (byte) 0;
}
public char read_char() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
if (buf_.pos_ + 1 > buf_.len_)
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
@@ -1146,9 +1175,7 @@
}
public byte read_octet() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
if (buf_.pos_ + 1 > buf_.len_)
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
@@ -1160,9 +1187,7 @@
}
public short read_short() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
buf_.pos_ += (buf_.pos_ & 0x1);
if (buf_.pos_ + 2 > buf_.len_)
@@ -1183,9 +1208,7 @@
}
public int read_long() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
return _OB_readLongUnchecked();
}
@@ -1194,9 +1217,7 @@
}
public long read_longlong() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
final int pmod8 = buf_.pos_ & 0x7;
if (pmod8 != 0)
buf_.pos_ += 8 - pmod8;
@@ -1241,8 +1262,7 @@
}
public String read_string() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
//
// Number of octets (i.e. bytes) in the string (including
@@ -1251,20 +1271,23 @@
//
int length = read_ulong();
- if (length == 0)
+ if (length == 0) {
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorReadStringZeroLength),
org.apache.yoko.orb.OB.MinorCodes.MinorReadStringZeroLength,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+ }
int newPos = buf_.pos_ + length;
- if (newPos < buf_.pos_ || newPos > buf_.len_)
+ if (newPos < buf_.pos_ || newPos > buf_.len_) {
+ logger.fine("String length=" + length + " newPos=" + newPos + " buf_.pos=" + buf_.pos_ + " buf_.len=" + buf_.len_);
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorReadStringOverflow),
org.apache.yoko.orb.OB.MinorCodes.MinorReadStringOverflow,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+ }
length--;
@@ -1367,8 +1390,7 @@
public void read_boolean_array(boolean[] value, int offset, int length) {
if (length > 0) {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
if (buf_.pos_ + length < buf_.pos_
|| buf_.pos_ + length > buf_.len_)
@@ -1385,8 +1407,7 @@
public void read_char_array(char[] value, int offset, int length) {
if (length > 0) {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
if (buf_.pos_ + length < buf_.pos_
|| buf_.pos_ + length > buf_.len_)
@@ -1448,8 +1469,7 @@
public void read_octet_array(byte[] value, int offset, int length) {
if (length > 0) {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
int newPos = buf_.pos_ + length;
if (newPos < buf_.pos_ || newPos > buf_.len_)
@@ -1469,9 +1489,7 @@
if (length <= 0)
return;
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
buf_.pos_ += (buf_.pos_ & 0x1);
int newPos = buf_.pos_ + length * 2;
@@ -1497,10 +1515,7 @@
public void read_long_array(int[] value, int offset, int length) {
if (length <= 0)
return;
-
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
final int pmod4 = buf_.pos_ & 0x3;
if (pmod4 != 0)
buf_.pos_ += 4 - pmod4;
@@ -1535,9 +1550,8 @@
if (length <= 0)
return;
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
+
final int pmod8 = buf_.pos_ & 0x7;
if (pmod8 != 0)
buf_.pos_ += 8 - pmod8;
@@ -1578,8 +1592,7 @@
public void read_float_array(float[] value, int offset, int length) {
if (length > 0) {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
final int pmod4 = buf_.pos_ & 0x3;
if (pmod4 != 0)
@@ -1618,9 +1631,7 @@
if (length <= 0)
return;
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
final int pmod8 = buf_.pos_ & 0x7;
if (pmod8 != 0)
buf_.pos_ += 8 - pmod8;
@@ -1662,8 +1673,7 @@
}
public org.omg.CORBA.Object read_Object() {
- if (valueReader_ != null)
- valueReader_.checkChunk();
+ checkChunk();
org.omg.IOP.IOR ior = org.omg.IOP.IORHelper.read(this);
@@ -1685,8 +1695,6 @@
//
org.omg.CORBA.Object obj = read_Object();
- org.apache.yoko.orb.OB.Logger logger = orbInstance_.getLogger();
-
if (obj != null) {
// OK, we have two possibilities here. The usual possibility is we're asked to load
// an object using a specified Stub class. We just create an instance of the stub class,
@@ -1787,9 +1795,7 @@
// encapsulation in a separate buffer.
//
- if (valueReader_ != null)
- valueReader_.checkChunk();
-
+ checkChunk();
java.util.Hashtable history = new java.util.Hashtable(11);
return readTypeCodeImpl(history, true);
}
@@ -2109,5 +2115,15 @@
public String __getCodeBase() {
return codebase_;
}
+
+ public String dumpData() {
+ return buf_.dumpData();
+ }
+
+ private void checkChunk() {
+ if (valueReader_ != null) {
+ valueReader_.checkChunk();
+ }
+ }
}
Modified: geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java (original)
+++ geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java Fri Feb 29 07:28:38 2008
@@ -17,7 +17,12 @@
package org.apache.yoko.orb.CORBA;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
final public class OutputStream extends org.omg.CORBA_2_3.portable.OutputStream {
+ static final Logger logger = Logger.getLogger(OutputStream.class.getName());
+
private org.apache.yoko.orb.OB.ORBInstance orbInstance_; // Java only
public org.apache.yoko.orb.OCI.Buffer buf_;
@@ -55,6 +60,7 @@
// Write a gap of four bytes (ulong aligned), avoids byte shifts
private int writeGap() {
+ logger.finest("Writing a gap value");
addCapacity(4, 4);
int result = buf_.pos_;
buf_.pos_ += 4;
@@ -63,6 +69,7 @@
private void writeLength(int start) {
int length = buf_.pos_ - (start + 4);
+ logger.finest("Writing a length value of " + length + " at offset " + start);
buf_.data_[start++] = (byte) (length >>> 24);
buf_.data_[start++] = (byte) (length >>> 16);
@@ -95,6 +102,8 @@
return;
}
}
+
+ logger.finest("Writing a type code of type " + tc.kind().value());
//
// For performance reasons, handle the primitive TypeCodes first
@@ -129,6 +138,7 @@
if (indirectionPos != null) {
write_long(-1);
int offs = indirectionPos.intValue() - buf_.pos_;
+ logger.finest("Writing an indirect type code for offset " + offs);
write_long(offs);
} else {
write_ulong(tc.kind().value());
@@ -410,15 +420,17 @@
// to write new data. We must first check if we need to start a
// chunk, which may result in a recursive call to addCapacity().
//
- if (buf_.pos_ == buf_.len_ && valueWriter_ != null)
+ if (buf_.pos_ == buf_.len_ && valueWriter_ != null) {
checkBeginChunk();
+ }
//
// If there isn't enough room, then reallocate the buffer
//
final int len = buf_.pos_ + size;
- if (len > buf_.len_)
+ if (len > buf_.len_) {
buf_.realloc(len);
+ }
}
}
@@ -431,8 +443,9 @@
// to write new data. We must first check if we need to start a
// chunk, which may result in a recursive call to addCapacity().
//
- if (buf_.pos_ == buf_.len_ && valueWriter_ != null)
+ if (buf_.pos_ == buf_.len_ && valueWriter_ != null) {
checkBeginChunk();
+ }
//
// If alignNext_ is set, then use the larger of alignNext_ and align
@@ -453,8 +466,9 @@
// If there isn't enough room, then reallocate the buffer
//
final int len = newPos + size;
- if (len > buf_.len_)
+ if (len > buf_.len_) {
buf_.realloc(len);
+ }
}
//
@@ -715,6 +729,7 @@
final char[] arr = value.toCharArray();
final int len = arr.length;
+ logger.finest("Writing wstring value " + value);
//
// get converter/writer instance
//
@@ -843,6 +858,12 @@
buf_.len_);
if (buf_.len_ > 0)
System.arraycopy(buf_.data_, 0, buf.data_, 0, buf_.len_);
+
+// this is a useful tracepoint, but produces a lot of data, so turn on only
+// if really needed.
+// if (logger.isLoggable(Level.FINEST)) {
+// logger.fine("new input stream created:\n" + buf.dumpData());
+// }
InputStream in = new InputStream(buf, 0, false, codeConverters_,
GIOPVersion_);
@@ -937,6 +958,7 @@
}
public void write_string(String value) {
+ logger.finest("Writing string value " + value);
final char[] arr = value.toCharArray();
int len = arr.length;
int capacity = len + 1;
@@ -1165,6 +1187,7 @@
public void write_Object(org.omg.CORBA.Object value) {
if (value == null) {
+ logger.finest("Writing a null CORBA object value");
org.omg.IOP.IOR ior = new org.omg.IOP.IOR();
ior.type_id = "";
ior.profiles = new org.omg.IOP.TaggedProfile[0];
@@ -1201,6 +1224,7 @@
}
public void write_any(org.omg.CORBA.Any value) {
+ logger.finest("Writing an ANY value of type " + value.type().kind());
write_TypeCode(value.type());
value.write_value(this);
}
@@ -1297,6 +1321,8 @@
}
try {
+ logger.fine("writing a value of type " + tc.kind().value());
+
switch (tc.kind().value()) {
case org.omg.CORBA.TCKind._tk_null:
case org.omg.CORBA.TCKind._tk_void:
@@ -1355,12 +1381,13 @@
//
// An indirection is not permitted at this level
//
- if (kind == -1)
+ if (kind == -1) {
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorReadInvTypeCodeIndirection),
org.apache.yoko.orb.OB.MinorCodes.MinorReadInvTypeCodeIndirection,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+ }
write_ulong(kind);
Modified: geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java (original)
+++ geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java Fri Feb 29 07:28:38 2008
@@ -304,39 +304,42 @@
// Convert an octet buffer into human-friendly data dump
//
public static String dump_octets(byte[] oct, int offset, int count) {
- final int inc = 8;
+ final int inc = 16;
+
+ if (count <= 0) {
+ return "";
+ }
- StringBuffer result = new StringBuffer((count - offset) * 8);
+ StringBuffer result = new StringBuffer(count * 8);
for (int i = offset; i < offset + count; i += inc) {
for (int j = i; j - i < inc; j++) {
if (j < offset + count) {
- int n = (int) oct[j];
- if (n < 0)
- n += 256;
- if (n < 10)
- result.append(" ");
- else if (n < 100)
- result.append(' ');
- result.append(n);
+ int n = ((int) oct[j]) & 0xff;
+ String hex = Integer.toHexString(n);
+ if (hex.length() == 1) {
+ result.append('0');
+ }
+ result.append(hex);
result.append(' ');
- } else
- result.append(" ");
+ } else {
+ result.append(" ");
+ }
}
result.append('"');
for (int j = i; j < offset + count && j - i < inc; j++) {
- if (oct[j] >= (byte) 32 && oct[j] < (byte) 127)
+ if (oct[j] >= (byte) 32 && oct[j] < (byte) 127) {
result.append((char) oct[j]);
- else
+ }
+ else {
result.append('.');
+ }
}
-
result.append('"');
result.append('\n');
}
-
return result.toString();
}
@@ -351,8 +354,11 @@
// Convert an octet buffer into a single-line readable data dump.
//
public static String format_octets(byte[] oct, int offset, int count) {
+ if (count <= 0) {
+ return "";
+ }
- StringBuffer result = new StringBuffer((count - offset) * 8);
+ StringBuffer result = new StringBuffer(count * 8);
result.append('"');
for (int i = offset; i < offset + count; i++) {
Modified: geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueFactoryManager.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueFactoryManager.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueFactoryManager.java (original)
+++ geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueFactoryManager.java Fri Feb 29 07:28:38 2008
@@ -17,7 +17,11 @@
package org.apache.yoko.orb.OB;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
public final class ValueFactoryManager {
+ static final Logger logger = Logger.getLogger(ValueFactoryManager.class.getName());
//
// The set of registered valuetype factories
//
@@ -149,19 +153,24 @@
org.omg.CORBA.portable.ValueFactory result;
+ logger.fine("Looking up value factory for class " + id);
//
// Check the registered factories
//
result = (org.omg.CORBA.portable.ValueFactory) factories_.get(id);
- if (result != null)
+ if (result != null) {
+ logger.finer("Returning registered value factory " + result.getClass().getName());
return result;
+ }
//
// Check the cached factories
//
result = (org.omg.CORBA.portable.ValueFactory) classFactories_.get(id);
- if (result != null)
+ if (result != null) {
+ logger.finer("Returning cached value factory " + result.getClass().getName());
return result;
+ }
//
// Try to convert the repository ID into a class name.
@@ -169,6 +178,7 @@
Class c = Util.idToClass(id, "DefaultFactory");
if (c != null) {
try {
+ logger.finer("Attempting to create value factory from class " + c.getName());
//
// Instantiate the factory
//
Modified: geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java (original)
+++ geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java Fri Feb 29 07:28:38 2008
@@ -1,10 +1,10 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -18,14 +18,19 @@
package org.apache.yoko.orb.OB;
import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.rmi.CORBA.ValueHandler;
+import org.omg.CORBA.TCKind;
import org.omg.CORBA.WStringValueHelper;
import org.omg.CORBA.portable.IndirectionException;
import org.omg.SendingContext.CodeBase;
final public class ValueReader {
+ static final Logger logger = Logger.getLogger(ValueReader.class.getName());
//
// Chunk data
//
@@ -162,10 +167,11 @@
}
java.io.Serializable create(Header h) {
+ logger.fine("Creating a value object with tag value " + Integer.toHexString(h.tag));
Assert._OB_assert(h.tag >= 0x7fffff00 && h.tag != -1);
if (h.isRMIValue()) {
- return reader_.readRMIValue(h, clz_, h.ids[0]);
+ return reader_.readRMIValue(h, clz_, h.ids[0]);
}
java.io.Serializable result = null;
@@ -357,6 +363,8 @@
}
private void readHeader(Header h) {
+ logger.fine("Reading header with tag value " + Integer.toHexString(h.tag));
+
//
// Special cases are handled elsewhere
//
@@ -365,8 +373,9 @@
//
// Check if the value is chunked
//
- if ((h.tag & 0x00000008) == 8)
+ if ((h.tag & 0x00000008) == 8) {
h.state.chunked = true;
+ }
//
// Check for presence of codebase URL
@@ -399,16 +408,19 @@
buf_.pos_ = save;
h.codebase = in_.read_string();
}
+ logger.finer("Value header codebase value is " + h.codebase);
}
//
// Extract repository ID information
//
if ((h.tag & 0x00000006) == 0) {
+ logger.finer("No type information was included");
//
// No type information was marshalled
//
} else if ((h.tag & 0x00000006) == 6) {
+ logger.finer("Multiple types included in header");
//
// Extract a list of repository IDs, representing the
// truncatable types for this value
@@ -471,6 +483,7 @@
buf_.pos_ = saveRep;
h.ids[i] = in_.read_string();
}
+ logger.finer("Value header respoitory id added " + h.ids[i]);
}
//
@@ -514,6 +527,7 @@
h.ids = new String[1];
h.ids[0] = id;
+ logger.finer("Single header repository id read " + id);
}
//
@@ -532,6 +546,7 @@
// Check for a chunk size
//
int size = in_._OB_readLongUnchecked();
+ logger.finest("Reading new chunk. Size value is " + Integer.toHexString(size) + " current nest is " + state.nestingLevel + " current position=" + buf_.pos_);
if (size >= 0 && size < 0x7fffff00) // chunk size
{
state.chunkStart = buf_.pos_;
@@ -546,6 +561,7 @@
state.chunkStart = 0;
state.chunkSize = 0;
}
+ logger.finest("Chunk read. start=" + state.chunkStart + ", size=" + state.chunkSize + " buffer position=" + buf_.pos_);
}
private void initHeader(Header h) {
@@ -567,13 +583,16 @@
// Increment our nesting level if we are chunked
//
if (chunkState_.chunked) {
+// logger.finest("Reading chunk for chunked value. Header tag=" + Integer.toHexString(h.tag) + " current position=" + buf_.pos_);
readChunk(chunkState_);
chunkState_.nestingLevel++;
+// logger.fine("Chunk nesting level is " + chunkState_.nestingLevel + " current position=" + buf_.pos_ + " chunk size=" + chunkState_.chunkSize);
}
}
private void skipChunk() {
if (chunkState_.chunked) {
+ logger.fine("Skipping a chunked value. nesting level=" + chunkState_.nestingLevel + " current position is " + buf_.pos_ + " chunk end is " + (chunkState_.chunkStart + chunkState_.chunkSize));
//
// At this point, the unmarshalling code has finished. However,
// we may have a truncated value, or we may have unmarshalled a
@@ -591,6 +610,7 @@
if (chunkState_.chunkStart > 0) {
buf_.pos_ = chunkState_.chunkStart;
in_._OB_skip(chunkState_.chunkSize);
+ logger.finest("Skipping to end of current chunk. New position is " + buf_.pos_);
}
chunkState_.chunkStart = 0;
@@ -602,8 +622,10 @@
//
int level = chunkState_.nestingLevel;
int tag = in_._OB_readLongUnchecked();
+ logger.finest("Skipping chunk: read tag value =" + tag);
while (tag >= 0 || (tag < 0 && tag < -chunkState_.nestingLevel)) {
if (tag >= 0x7fffff00) {
+ logger.finest("Skipping chunk: reading a nested chunk value");
//
// This indicates a nested value. We read the header
// information and store it away, in case a subsequent
@@ -616,22 +638,26 @@
nest.state.nestingLevel = level;
readHeader(nest);
} else if (tag >= 0) {
+ logger.finest("Skipping chunk: skipping over a chunk for length " +tag);
//
// Chunk size - advance the stream past the chunk
//
in_._OB_skip(tag);
} else {
+ logger.finest("Skipping chunk: chunk end tag=" + Integer.toHexString(tag) + " current level=" + level);
//
// tag is less than 0, so this is an end tag for a nested
// value
//
- level--;
+ // this can terminate more than a single level.
+ level = (-tag) - 1;
}
//
// Read the next tag
//
tag = in_._OB_readLongUnchecked();
+ logger.finest("Skipping chunk: read tag value =" + tag);
}
//
@@ -639,20 +665,26 @@
// value coterminates with an outer value. We rewind the
// stream so that the outer value can read this tag.
//
- if (tag > -chunkState_.nestingLevel)
+ if (tag > -chunkState_.nestingLevel) {
buf_.pos_ -= 4;
+ }
chunkState_.nestingLevel--;
- if (chunkState_.nestingLevel == 0)
+ logger.finest("New chunk nesting level is " + chunkState_.nestingLevel);
+ if (chunkState_.nestingLevel == 0) {
chunkState_.chunked = false;
+ }
else {
//
// We're chunked and still processing nested values, so
// another chunk may follow
//
+ logger.finest("Reading chunk for skipping to end of a chunk");
readChunk(chunkState_);
}
+
+ logger.finest("Final chunk state is nesting level=" + chunkState_.nestingLevel + " current position is " + buf_.pos_ + " chunk end is " + (chunkState_.chunkStart + chunkState_.chunkSize));
}
}
@@ -736,6 +768,7 @@
ChunkState saveState = new ChunkState(chunkState_);
chunkState_.copyFrom(nest.state);
if (chunkState_.chunked)
+// logger.finest("Reading chunk in readIndirection()");
readChunk(chunkState_);
try {
@@ -756,6 +789,7 @@
Header h = new Header();
h.tag = in_.read_long();
+// logger.fine("Read tag value " + Integer.toHexString(h.tag));
if (h.tag == 0) {
return null;
} else if (h.tag == -1) {
@@ -774,26 +808,30 @@
//
// Remarshal each valuetype member
//
- private void copyValueState(org.omg.CORBA.TypeCode tc,
- org.apache.yoko.orb.CORBA.OutputStream out) {
+ private void copyValueState(org.omg.CORBA.TypeCode tc, org.apache.yoko.orb.CORBA.OutputStream out) {
try {
if (tc.kind() == org.omg.CORBA.TCKind.tk_value) {
//
// First copy the state of the concrete base type, if any
//
org.omg.CORBA.TypeCode base = tc.concrete_base_type();
- if (base != null)
+ if (base != null) {
copyValueState(base, out);
+ }
- for (int i = 0; i < tc.member_count(); i++)
+ for (int i = 0; i < tc.member_count(); i++) {
+// logger.fine("writing member of typecode " + tc.member_type(i).kind().value());
out.write_InputStream(in_, tc.member_type(i));
+ }
} else if (tc.kind() == org.omg.CORBA.TCKind.tk_value_box) {
out.write_InputStream(in_, tc.content_type());
} else
Assert._OB_assert(false);
} catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
+ logger.log(Level.FINER, "Invalid type kind", ex);
Assert._OB_assert(ex);
} catch (org.omg.CORBA.TypeCodePackage.Bounds ex) {
+ logger.log(Level.FINER, "Invalid type kind", ex);
Assert._OB_assert(ex);
}
}
@@ -819,15 +857,18 @@
org.omg.CORBA.TypeCode tc) {
org.omg.CORBA.TypeCode result = null;
org.omg.CORBA.TypeCode t = tc;
+// logger.finer("Locating type code for id " + id);
while (result == null) {
try {
org.omg.CORBA.TypeCode t2 = org.apache.yoko.orb.CORBA.TypeCode
._OB_getOrigType(t);
+// logger.finer("Checking typecode " + id + " against " + t2.id());
if (id.equals(t2.id())) {
result = t;
} else if (t2.kind() == org.omg.CORBA.TCKind.tk_value
&& t2.type_modifier() == org.omg.CORBA.VM_TRUNCATABLE.value) {
t = t2.concrete_base_type();
+// logger.finer("Iterating with concrete type " + t.id());
} else {
break;
}
@@ -851,19 +892,18 @@
headerTable_ = new java.util.Hashtable(131);
}
- java.io.Serializable
- readRMIValue(Header h, Class clz, String repid)
+ java.io.Serializable readRMIValue(Header h, Class clz, String repid)
{
- if (valueHandler == null)
+ logger.fine("Reading RMI value of type " + repid);
+ if (valueHandler == null) {
valueHandler = javax.rmi.CORBA.Util.createValueHandler ();
+ }
- if (repid == null)
- {
+ if (repid == null) {
repid = h.ids[0];
-
- if (repid == null)
- {
- throw new org.omg.CORBA.MARSHAL("missing repository id");
+
+ if (repid == null) {
+ throw new org.omg.CORBA.MARSHAL("missing repository id");
}
}
@@ -875,78 +915,124 @@
codebase = in_.__getCodeBase ();
}
- try
- {
- repoClass = javax.rmi.CORBA.Util.loadClass
- (className,
- codebase,
- Util.getContextClassLoader ());
- }
- catch (ClassNotFoundException ex)
- {
- if (codebase == null || codebase.length () == 0) {
- // ignore, we'll try to grab the codebase, and then
- // call loadClass again.
- } else {
- // TODO: Add minor code
- throw new org.omg.CORBA.MARSHAL
- ("class "+className
- +" not found (cannot load from "+codebase+")" );
+ repoClass = resolveRepoClass(className, codebase);
- }
+ // if we have a non-null codebase and can't resolve this, throw an
+ // exception now. Otherwise, we'll try again after grabbing the remote
+ // codebase.
+ if (repoClass == null && codebase != null && codebase.length() > 0) {
+ throw new org.omg.CORBA.MARSHAL("class "+className
+ +" not found (cannot load from "+codebase+")");
}
-
- if (remoteCodeBase == null)
- {
+
+ if (remoteCodeBase == null) {
remoteCodeBase = in_.__getSendingContextRuntime ();
}
+ if (repoClass == null) {
+ if (codebase == null && remoteCodeBase != null) {
+ try {
+ codebase = remoteCodeBase.implementation (repid);
+ } catch (org.omg.CORBA.SystemException ex) {
+ // ignore
+ }
- if (repoClass == null) {
- if (codebase == null && remoteCodeBase != null)
- {
- try {
- codebase = remoteCodeBase.implementation (repid);
- } catch (org.omg.CORBA.SystemException ex) {
- // ignore
- }
-
- }
+ }
- if (codebase == null) {
- // TODO: add minor code
- throw new org.omg.CORBA.MARSHAL
- ("class "+className+" not found (no codebase provided)");
- }
-
- try
- {
- repoClass = javax.rmi.CORBA.Util.loadClass
- (className,
- codebase,
- Util.getContextClassLoader ());
- }
- catch (ClassNotFoundException ex)
- {
- // TODO: add minor code
- throw new org.omg.CORBA.MARSHAL
- ("class "+className+" not found (cannot load from codebase)");
+ if (codebase == null) {
+ // TODO: add minor code
+ throw new org.omg.CORBA.MARSHAL
+ ("class "+className+" not found (no codebase provided)");
+ } else {
+ repoClass = resolveRepoClass(className, codebase);
+ if (repoClass == null) {
+ throw new org.omg.CORBA.MARSHAL("class "+className+" not found (cannot load from " + codebase+ ")");
}
+ }
+ }
+ /* Suns crappy ValueHandler implementation narrows the remote CodeBase
+ * to a com.sun.org.omg.SendingContext.CodeBase.
+ * Narrowing CodeBaseProxy is not possible, we
+ * need a stub.
+ */
+ if (remoteCodeBase instanceof CodeBaseProxy) {
+ remoteCodeBase = ((CodeBaseProxy) remoteCodeBase).getCodeBase();
+ }
+ return valueHandler.readValue(in_, h.headerPos, repoClass, repid, remoteCodeBase);
+ }
+
+ private Class resolveRepoClass(String name, String codebase)
+ {
+ logger.fine("Attempting to resolve class " + name + " from codebase " + codebase);
+ if (name.startsWith("[")) {
+ int levels = 0;
+ for (int i = 0; name.charAt(i) == '['; i++) {
+ levels++;
}
+ Class elementClass = null;
- /* Suns crappy ValueHandler implementation narrows the remote CodeBase
- * to a com.sun.org.omg.SendingContext.CodeBase.
- * Narrowing CodeBaseProxy is not possible, we
- * need a stub.
- */
- if(remoteCodeBase instanceof CodeBaseProxy) {
- remoteCodeBase = ((CodeBaseProxy) remoteCodeBase).getCodeBase();
+ // now resolve the element descriptor to a class
+ switch (name.charAt(levels)) {
+ case 'Z':
+ elementClass = Boolean.TYPE;
+ break;
+ case 'B':
+ elementClass = Byte.TYPE;
+ break;
+ case 'S':
+ elementClass = Short.TYPE;
+ break;
+ case 'C':
+ elementClass = Character.TYPE;
+ break;
+ case 'I':
+ elementClass = Integer.TYPE;
+ break;
+ case 'J':
+ elementClass = Long.TYPE;
+ break;
+ case 'F':
+ elementClass = Float.TYPE;
+ break;
+ case 'D':
+ elementClass = Double.TYPE;
+ break;
+ case 'L':
+ // extract the class from the name and resolve that.
+ elementClass = resolveRepoClass(name.substring(levels + 1, name.indexOf(';')), codebase);
+ if (elementClass == null) {
+ return null;
+ }
+ break;
}
-
- return valueHandler.readValue (in_, h.headerPos, repoClass,
- repid, remoteCodeBase);
-
+
+ // ok, we need to recurse and resolve the base array element class
+ Object arrayInstance = null;
+ // this is easier with a single level
+ if (levels == 1) {
+ arrayInstance = Array.newInstance(elementClass, 0);
+ }
+ else {
+ // all elements will be zero
+ int[] dimensions = new int[levels];
+ arrayInstance = Array.newInstance(elementClass, dimensions);
+ }
+ // return the class associated with this array
+ return arrayInstance.getClass();
+ }
+ else {
+ try
+ {
+ return javax.rmi.CORBA.Util.loadClass(name, codebase,
+ Util.getContextClassLoader());
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // this will be sorted out later
+ return null;
+ }
+ }
}
public java.io.Serializable readValue() {
@@ -1040,12 +1126,12 @@
// wasn't being used anywhere except to determine when the table should
// be reset.
//
-
//
// Create a new Hashtable for each top-level call to remarshalValue
//
- if (positionTable_ == null)
+ if (positionTable_ == null) {
positionTable_ = new java.util.Hashtable(131);
+ }
org.omg.CORBA.TypeCode origTC = org.apache.yoko.orb.CORBA.TypeCode
._OB_getOrigType(tc);
@@ -1054,6 +1140,8 @@
Header h = new Header();
h.tag = in_.read_long();
+
+ logger.fine("Read tag value " + Integer.toHexString(h.tag));
h.headerPos = buf_.pos_ - 4; // adjust for alignment
h.state.copyFrom(chunkState_);
@@ -1098,6 +1186,12 @@
throw new org.omg.CORBA.MARSHAL(
"Cannot find value for indirection");
} else {
+ if (h.tag < 0x7fffff00) {
+ throw new org.omg.CORBA.MARSHAL("Illegal valuetype tag 0x" + Integer.toHexString(h.tag));
+ }
+
+ logger.fine("Remarshalling header with tag value " + h.tag);
+
//
// Add valuetype to position map
//
@@ -1113,6 +1207,7 @@
chunkState_.copyFrom(h.state);
if (chunkState_.chunked) {
+ logger.finest("Reading chunk in remarshal value()");
readChunk(chunkState_);
chunkState_.nestingLevel++;
}
@@ -1145,16 +1240,40 @@
// OutputStream.
//
+ logger.fine("Attempting to resolve typeId " + tcId);
//
// See if the TypeCode ID matches any of the valuetype's IDs -
// stop at the first match
//
String id = null;
- for (idPos = 0; idPos < h.ids.length; idPos++)
+ for (idPos = 0; idPos < h.ids.length; idPos++) {
+ logger.finer("Comparing type id " + tcId + " against " + h.ids[idPos]);
if (tcId.equals(h.ids[idPos])) {
id = h.ids[idPos];
break;
}
+ }
+
+ // if this is null, then try again to see if we can find a class in the ids list
+ // that is compatible with the base type. This will require resolving the classes.
+ if (id == null) {
+ // see if we can resolve the type for the stored type code
+ Class baseType = Util.idToClass(tcId, "");
+ if (baseType != null) {
+ for (idPos = 0; idPos < h.ids.length; idPos++) {
+ logger.finer("Comparing type id " + tcId + " against " + h.ids[idPos]);
+ Class idType = Util.idToClass(h.ids[idPos], "");
+ if (idType != null) {
+ // if these classes are assignment compatible, go with that as the type.
+ logger.finer("Comparing type id " + baseType.getName() + " against " + idType.getName());
+ if (baseType.isAssignableFrom(idType)) {
+ id = h.ids[idPos];
+ break;
+ }
+ }
+ }
+ }
+ }
//
// See if a factory exists for any of the valuetype's IDs -
@@ -1181,23 +1300,26 @@
// If no ID matched the TypeCode, and no factory was found,
// then we have no way to remarshal the data
//
- if (h.ids.length > 0 && id == null && factoryId == null)
+ if (h.ids.length > 0 && id == null && factoryId == null) {
+ logger.fine("Unable to resolve a factory for type " + tcId);
throw new org.omg.CORBA.MARSHAL(org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorNoValueFactory)
+ ": insufficient information to copy valuetype",
org.apache.yoko.orb.OB.MinorCodes.MinorNoValueFactory,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+ }
//
// If value is custom and there is no factory, then we have
// no way to remarshal the data
//
- if (mod == org.omg.CORBA.VM_CUSTOM.value && factoryId == null)
+ if (mod == org.omg.CORBA.VM_CUSTOM.value && factoryId == null) {
throw new org.omg.CORBA.MARSHAL(org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorNoValueFactory)
+ ": unable to copy custom valuetype",
org.apache.yoko.orb.OB.MinorCodes.MinorNoValueFactory,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+ }
//
// If the TypeCode is more descriptive than any available
@@ -1221,6 +1343,7 @@
for (i = idPos; i < h.ids.length; i++)
ids[i - idPos] = h.ids[i];
+ logger.fine("Copying value state of object using truncated type");
out._OB_beginValue(h.tag, ids, h.state.chunked);
copyValueState(origTC, out);
out._OB_endValue();
@@ -1233,6 +1356,7 @@
try {
pushHeader(h);
java.io.Serializable vb = factory.read_value(in_);
+ logger.fine("Creating a temporary copy of the object for marshalling");
try {
out.write_value(vb);
} finally {
@@ -1286,6 +1410,7 @@
org.omg.CORBA.TypeCode origTC = org.apache.yoko.orb.CORBA.TypeCode
._OB_getOrigType(tc);
+ logger.fine("Reading an Any value of kind=" + origTC.kind().value() + " from position " + buf_.pos_);
//
// Check if the Any contains an abstract interface
@@ -1293,12 +1418,14 @@
if (origTC.kind() == org.omg.CORBA.TCKind.tk_abstract_interface) {
boolean b = in_.read_boolean();
if (b) {
+ logger.fine("Reading an object reference for an abstract interface");
//
// The abstract interface represents an object reference
//
any.insert_Object(in_.read_Object(), tc);
return;
} else {
+ logger.fine("Reading an object value for an abstract interface");
//
// The abstract interface represents a valuetype. The
// readValue() method will raise an exception if an
@@ -1323,6 +1450,7 @@
//
try {
String id = origTC.id();
+ logger.fine("Reading an Any value of id=" + id);
if (id.equals("IDL:omg.org/CORBA/ValueBase:1.0")) {
any.insert_Value(readValue(), tc);
return;
@@ -1366,6 +1494,7 @@
.create_input_stream();
Assert._OB_assert(obAny != null);
obAny.replace(tc, in);
+ return;
} catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
Assert._OB_assert(ex);
}
@@ -1375,6 +1504,7 @@
//
Header h = new Header();
h.tag = in_.read_long();
+ logger.fine("Read tag value " + Integer.toHexString(h.tag));
//
// Check tag for special cases
@@ -1401,12 +1531,14 @@
// Fixing this probably requires maintaining a
// map of stream position to TypeCode.
//
+ logger.fine("Handling a value type indirection value");
any.insert_Value(readIndirection(strategy), tc);
return;
} else {
initHeader(h);
org.omg.CORBA.StringHolder idH = new org.omg.CORBA.StringHolder();
java.io.Serializable vb = strategy.create(h, idH);
+ logger.fine("Obtained a value of type " + vb.getClass().getName());
skipChunk();
//
@@ -1424,15 +1556,19 @@
// the valuetype was truncated.
//
org.omg.CORBA.TypeCode t = null;
- if(idH.value != null)
+ if(idH.value != null) {
t = findTypeCode(idH.value, tc);
- if (t != null)
+ }
+ if (t != null) {
any.insert_Value(vb, t);
- else
+ }
+ else {
any.insert_Value(vb, tc);
+ }
return;
}
} catch (org.omg.CORBA.MARSHAL ex) {
+ logger.log(Level.FINE, "Marshaling exception occurred, attempting to remarshal", ex);
//
// Creation failed - restore our state and try remarshalling
//
@@ -1458,6 +1594,7 @@
public void beginValue() {
Header h = new Header();
h.tag = in_.read_long();
+ logger.fine("Read tag value " + Integer.toHexString(h.tag));
Assert._OB_assert(h.tag != 0 && h.tag != -1);
initHeader(h);
@@ -1470,13 +1607,16 @@
public void checkChunk() {
if (!chunkState_.chunked)
return;
-
+
+// logger.finest("Checking chunk position. end=" + (chunkState_.chunkStart + chunkState_.chunkSize) + " buffer position=" + buf_.pos_);
//
// If we've reached the end of the current chunk, then check
// for the start of a new chunk
//
- if (chunkState_.chunkStart > 0
- && chunkState_.chunkStart + chunkState_.chunkSize == buf_.pos_)
+ if (chunkState_.chunkStart > 0 && chunkState_.chunkStart + chunkState_.chunkSize == buf_.pos_)
+ {
+// logger.finest("Reading chunk from check chunk");
readChunk(chunkState_);
+ }
}
}
Modified: geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java (original)
+++ geronimo/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java Fri Feb 29 07:28:38 2008
@@ -57,6 +57,25 @@
public boolean is_full() {
return pos_ >= len_;
}
+
+ /**
+ * Return the data in the buffer as a formatted string suitable for
+ * logging.
+ *
+ * @return The string value of the data.
+ */
+ public String dumpData()
+ {
+ StringBuffer dump = new StringBuffer();
+ dump.append("Buffer pos=");
+ dump.append(pos_);
+ dump.append(" Buffer len=");
+ dump.append(len_);
+ dump.append(" Remaining buffer data=\n\n");
+
+ dump.append(org.apache.yoko.orb.OB.IORUtil.dump_octets(data_, pos_, rest_length()));
+ return dump.toString();
+ }
// ------------------------------------------------------------------
// Additional Yoko specific functions
Modified: geronimo/yoko/trunk/core/src/test/java/test/rmi/ClientMain.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/test/java/test/rmi/ClientMain.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/test/java/test/rmi/ClientMain.java (original)
+++ geronimo/yoko/trunk/core/src/test/java/test/rmi/ClientMain.java Fri Feb 29 07:28:38 2008
@@ -25,6 +25,7 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.HashMap;
+import java.util.Vector;
import javax.rmi.CORBA.Stub;
import javax.rmi.CORBA.Util;
@@ -139,12 +140,13 @@
SampleSerializable ser2 = (SampleSerializable)sample.sendReceiveSerializable(ser);
assertEquals(10, ser2.getInt());
+
Serializable[] sA = new Serializable[] { ser };
sA = sample.sendReceiveSerializable(sA);
ser2 = (SampleSerializable)sA[0];
assertEquals(10, ser2.getInt());
-
+
Remote r = sample.sendReceiveRemote(sample);
Sample sample2 = (Sample) PortableRemoteObject.narrow(r, Sample.class);
assertEquals(sample, sample2);
@@ -161,6 +163,22 @@
assertEquals("hello", sample.getString());
}
+ // Make sure that a field definition for a value-type interface
+ // gets marshaled correctly. The SampleSerializable object defines a
+ // List field into which we'll place a Vector object. This should properly
+ // be processed as a value type rather than an abstract interface.
+ public void testVector() throws RemoteException {
+ Vector v = new Vector(10);
+ v.add("This is a test");
+ SampleSerializable ser = new SampleSerializable();
+ ser.setList(v);
+ SampleSerializable ser2 = (SampleSerializable)sample.sendReceiveSerializable(ser);
+ Vector v2 = (Vector)ser2.getList();
+ assertEquals(10, v2.capacity());
+ assertEquals(1, v2.size());
+ assertEquals("This is a test", v2.elementAt(0));
+ }
+
public void testIntArray() throws RemoteException {
int[] intArray = new int[] {1, 2, 3};
sample.setIntArray(intArray);
@@ -300,6 +318,7 @@
// Run RMI tests
Test test = new Test(sample);
+ test.testVector();
test.testPrimitive();
test.testArray();
test.testString();
@@ -316,5 +335,6 @@
test.testComplexCorbaAttribute(SampleCorbaHelper.narrow(sampleCorbaRef));
test.testHashMap();
//myORB.destroy();
+ System.out.println("Testing complete");
}
}
Modified: geronimo/yoko/trunk/core/src/test/java/test/rmi/SampleSerializable.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/core/src/test/java/test/rmi/SampleSerializable.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/core/src/test/java/test/rmi/SampleSerializable.java (original)
+++ geronimo/yoko/trunk/core/src/test/java/test/rmi/SampleSerializable.java Fri Feb 29 07:28:38 2008
@@ -19,6 +19,7 @@
import java.io.Serializable;
import java.rmi.Remote;
+import java.util.List;
public class SampleSerializable implements Serializable {
private org.omg.CORBA.Object corbaObj;
@@ -29,6 +30,7 @@
private Object serializableObj1, serializableObj2;
private Serializable serializable;
private int i = 0;
+ private List aVector;
public void setInt(int i) { this.i = i; }
public int getInt() { return i; }
@@ -71,6 +73,14 @@
throw new Error("Expected serializable objects to be == identical");
}
}
+
+ public void setList(List l) {
+ aVector = l;
+ }
+
+ public List getList() {
+ return aVector;
+ }
public void setSerializable(Serializable s) {
this.serializable = s;
Modified: geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java (original)
+++ geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java Fri Feb 29 07:28:38 2008
@@ -81,6 +81,7 @@
protected ArrayDescriptor(Class type, Class elemType, TypeRepository rep) {
super(type, rep);
+ logger.fine("Creating an array descriptor for type " + type.getName() + " holding elements of " + elemType.getName());
this.elementType = elemType;
order = 1;
@@ -128,6 +129,7 @@
}
static ArrayDescriptor get(final Class type, TypeRepository rep) {
+ logger.fine("retrieving an array descriptor for class " + type.getName());
if (!type.isArray()) {
throw new IllegalArgumentException("type is not an array");
}
@@ -178,8 +180,17 @@
*/
public Object read(org.omg.CORBA.portable.InputStream in) {
org.omg.CORBA_2_3.portable.InputStream _in = (org.omg.CORBA_2_3.portable.InputStream) in;
-
- return _in.read_value(getRepositoryID());
+ logger.fine("Reading an array value with repository id " + getRepositoryID() + " java class is " + getJavaClass());
+
+ // if we have a resolved class, read using that, otherwise fall back on the
+ // repository id.
+ Class clz = getJavaClass();
+ if (clz == null) {
+ return _in.read_value(getRepositoryID());
+ }
+ else {
+ return _in.read_value(clz);
+ }
}
/** Write an instance of this value to a CDR stream */
@@ -259,6 +270,12 @@
for (int i = 0; i < length; i++) {
try {
arr[i] = reader.readAny();
+ if (arr[i] != null) {
+ logger.finer("Array item " + i + " is of type " + arr[i].getClass().getName());
+ }
+ else {
+ logger.finer("Array item " + i + " is null");
+ }
} catch (org.omg.CORBA.portable.IndirectionException ex) {
arr[i] = offsetMap.get(new Integer(ex.offset));
// reader.addValueBox (ex.offset, new ArrayBox (i, arr));
Modified: geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java (original)
+++ geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/FieldDescriptor.java Fri Feb 29 07:28:38 2008
@@ -177,7 +177,9 @@
} else if (java.io.Serializable.class.isAssignableFrom(type)) {
return new ValueFieldDescriptor(owner, type, name, f);
-
+ } else if (type.isInterface() && type.getMethods().length > 0) {
+ // interface classes that define methods
+ return new ValueFieldDescriptor(owner, type, name, f);
} else {
return new ObjectFieldDescriptor(owner, type, name, f);
}
@@ -862,6 +864,7 @@
}
try {
int value = reader.readInt();
+ logger.finest("Read int field value " + value);
field.setInt(obj, value);
} catch (IllegalAccessException ex) {
throw (IOException)new IOException(ex.getMessage()).initCause(ex);
@@ -934,6 +937,7 @@
}
try {
long value = reader.readLong();
+ logger.finest("Read long field value " + value);
field.setLong(obj, value);
} catch (IllegalAccessException ex) {
throw (IOException)new IOException(ex.getMessage()).initCause(ex);
Modified: geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java (original)
+++ geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java Fri Feb 29 07:28:38 2008
@@ -88,7 +88,6 @@
desc.init();
repidMap.put(desc.getRepositoryID(), desc);
}
-
desc = new AnyDescriptor(java.io.Externalizable.class, this);
synchronized (desc) {
classMap.put(java.io.Externalizable.class, desc);
@@ -102,7 +101,6 @@
desc.init();
repidMap.put(desc.getRepositoryID(), desc);
}
-
desc = new AnyDescriptor(java.rmi.Remote.class, this);
synchronized (desc) {
classMap.put(java.rmi.Remote.class, desc);
@@ -145,6 +143,7 @@
}
public TypeDescriptor getDescriptor(Class type) {
+ logger.fine("Requesting type descriptor for class " + type.getName());
TypeDescriptor desc = (TypeDescriptor) classMap.get(type);
if (desc != null) {
@@ -325,11 +324,11 @@
*/
public ValueDescriptor getDescriptor(Class clz, String repid,
RunTime runtime) throws ClassNotFoundException {
-
// ValueDescriptor desc = null;
ValueDescriptor clzdesc = null;
if (clz != null) {
+ logger.fine("Requesting type descriptor for class " + clz.getName() + " with repid " + repid);
ValueDescriptor desc = (ValueDescriptor)classMap.get(clz);
if (desc != null) {
return desc;
@@ -351,23 +350,25 @@
return clzdesc;
}
- String localHash = localID.substring(localID.lastIndexOf(':'));
- String remoteHash = repid.substring(repid.lastIndexOf(':'));
+ // we have a mismatch. We'll accept this if the class name and the
+ // serial version id are the same (ignoring the hash portion of the id);
+ String localClassName = localID.substring(0, localID.indexOf(':'));
+ String remoteClassName = repid.substring(0, repid.indexOf(':'));
+
+ String localSUID = localID.substring(localID.lastIndexOf(':'));
+ String remoteSUID = repid.substring(repid.lastIndexOf(':'));
// compare the CORBA hash codes, and allow this to work
- if (localHash == null ? localHash == remoteHash : localHash
- .equals(remoteHash)) {
-
- if (Boolean.getBoolean("trifork.rmi.ignoreSerialVersionUID")) {
- return clzdesc;
- }
-
+ if (localClassName.equals(remoteClassName) && localSUID.equals(remoteSUID)) {
+ logger.fine("mismatching repository ids accepted because of matching name and SUID. local: " + clzdesc.getRepositoryID() + "; remote: " + repid);
+ return clzdesc;
}
logger.fine("mismatching repository ids. local: "
+ clzdesc.getRepositoryID() + "; remote: " + repid);
}
+ logger.fine("Requesting type descriptor for repid " + repid);
if (repid != null) {
clzdesc = (ValueDescriptor) repidMap.get(repid);
if (clzdesc != null) {
Modified: geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java (original)
+++ geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java Fri Feb 29 07:28:38 2008
@@ -417,7 +417,7 @@
throw (MARSHAL)new MARSHAL("unable to export object").initCause(ex);
}
}
-
+ obj = objref;
}
org.omg.CORBA_2_3.portable.OutputStream out_ = (org.omg.CORBA_2_3.portable.OutputStream) out;
Modified: geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java (original)
+++ geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java Fri Feb 29 07:28:38 2008
@@ -572,7 +572,6 @@
protected void defaultWriteValue(ObjectWriter writer,
java.io.Serializable val) throws java.io.IOException {
logger.finer("writing fields for " + getJavaClass());
-
FieldDescriptor[] fields = _fields;
if (fields == null) {
@@ -738,7 +737,7 @@
for (int i = 0; i < _fields.length; i++) {
- logger.fine("reading field " + _fields[i].getJavaName());
+ logger.fine("reading field " + _fields[i].getJavaName() + " of type " + _fields[i].getType().getName() + " using " + _fields[i].getClass().getName());
try {
_fields[i].read(reader, value);
Modified: geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueHandlerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueHandlerImpl.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueHandlerImpl.java (original)
+++ geronimo/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueHandlerImpl.java Fri Feb 29 07:28:38 2008
@@ -75,8 +75,10 @@
try {
return readValue0(in, offset, clz, repid, codebase);
} catch (Error ex) {
+ logger.log(Level.FINE, "Exception reading value of type " + repid, ex);
throw ex;
} catch (RuntimeException ex) {
+ logger.log(Level.FINE, "Exception reading value of type " + repid, ex);
throw ex;
}
}
Modified: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/CompletionStatus.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/CompletionStatus.java?rev=632352&r1=632351&r2=632352&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/CompletionStatus.java (original)
+++ geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/CompletionStatus.java Fri Feb 29 07:28:38 2008
@@ -24,6 +24,9 @@
public final class CompletionStatus implements org.omg.CORBA.portable.IDLEntity
{
+ // force compatibility with Sun version for interop.
+ static final long serialVersionUID = -9047319660881406859L;
+
private static CompletionStatus [] values_ = new CompletionStatus[3];
private int value_;