Re-fix typeCode generation
diff --git a/yoko-core/pom.xml b/yoko-core/pom.xml
index 54af256..dfe3cf7 100644
--- a/yoko-core/pom.xml
+++ b/yoko-core/pom.xml
@@ -131,8 +131,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>-Xmx128m</argLine>
- <argLine>-Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine>
+ <argLine>-Xmx128m -Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine>
<includes>
<include>**/org/apache/yoko/*Test.java</include>
</includes>
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/SimpleDescriptor.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/SimpleDescriptor.java
index f51ee0b..fe3df2c 100755
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/SimpleDescriptor.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/SimpleDescriptor.java
@@ -18,17 +18,17 @@
package org.apache.yoko.rmi.impl;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
abstract class SimpleDescriptor extends TypeDescriptor {
private final String idl_name;
- SimpleDescriptor(Class type, TypeRepository repository, String idl_name,
- org.omg.CORBA.TCKind tc) {
+ private final TCKind tc;
+ SimpleDescriptor(Class type, TypeRepository repository, String idl_name, TCKind tc) {
super(type, repository);
this.idl_name = idl_name;
-
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
- _type_code = orb.get_primitive_tc(tc);
+ this.tc = tc;
}
@Override
@@ -48,7 +48,7 @@
@Override
protected final TypeCode genTypeCode() {
- return _type_code;
+ return ORB.init().get_primitive_tc(tc);
}
@Override
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeDescriptor.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeDescriptor.java
index 3bbabf2..ed66893 100755
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeDescriptor.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeDescriptor.java
@@ -206,14 +206,21 @@
return 0L;
}
- protected TypeCode _type_code = null;
+ @Override
+ protected void init() {
+ typeCode = genTypeCode();
+ }
private volatile TypeCode typeCode = null;
protected abstract TypeCode genTypeCode();
final TypeCode getTypeCode() {
+ // typeCode should have already been set from within init(), so this is just defensive
if (null == typeCode) typeCode = genTypeCode();
return typeCode;
}
+ protected final void setTypeCode(TypeCode tc) {
+ typeCode = tc;
+ }
Object copyObject(Object value, CopyState state) {
throw new InternalError("cannot copy " + value.getClass().getName());
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
index 0d2a3e8..e6b1849 100755
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
@@ -839,21 +839,21 @@
@Override
protected TypeCode genTypeCode() {
ORB orb = ORB.init();
- TypeCode typeCode = orb.create_recursive_tc(getRepositoryID());
+ setTypeCode(orb.create_recursive_tc(getRepositoryID()));
TypeCode _base = ((_super_descriptor == null) ? null : _super_descriptor.getTypeCode());
- Class javaClass = type;
- if (javaClass.isArray()) {
- TypeDescriptor desc = repo.getDescriptor(javaClass.getComponentType());
- typeCode = desc.getTypeCode();
- typeCode = orb.create_sequence_tc(0, typeCode);
- typeCode = orb.create_value_box_tc(getRepositoryID(), "Sequence", typeCode);
+ TypeCode tc;
+ if (type.isArray()) {
+ TypeDescriptor desc = repo.getDescriptor(type.getComponentType());
+ tc = desc.getTypeCode();
+ tc = orb.create_sequence_tc(0, tc);
+ tc = orb.create_value_box_tc(getRepositoryID(), "Sequence", tc);
} else {
- typeCode = orb.create_value_tc(getRepositoryID(), javaClass.getSimpleName(), VM_NONE.value, _base, getValueMembers());
+ tc = orb.create_value_tc(getRepositoryID(), type.getSimpleName(), VM_NONE.value, _base, getValueMembers());
}
- return typeCode;
+ return tc;
}
private static final OperationDescription[] ZERO_OPERATIONS = {};