Skip to content
Permalink
Browse files
Re-fix typeCode generation
  • Loading branch information
ngmr committed Mar 27, 2016
1 parent 022ef4c commit c4cb4e482b5bd9d7dac95ce37b9ad32172c7c2c0
Showing 4 changed files with 24 additions and 18 deletions.
@@ -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>
@@ -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 @@ protected final String genTypeName() {

@Override
protected final TypeCode genTypeCode() {
return _type_code;
return ORB.init().get_primitive_tc(tc);
}

@Override
@@ -206,14 +206,21 @@ long getHashCode() {
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());
@@ -839,21 +839,21 @@ private ValueMember[] getValueMembers() {
@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 = {};

0 comments on commit c4cb4e4

Please sign in to comment.