Merge branch 're-add_idl_entity_check' into 'ibm-trunk'
Restore isIDLEntity check
I previously misread the isIDLEntity() check as being redundant compared to IDLEntity.class.isAssignableFrom(), so removed it.
However, isIDLEntity() only compares the interfaces directly declared on the class (not in its class hierarchy), and only compares those interface class for equality with IDLEntity (not merely if they're assignable to IDLEntity).
Thus, isIDLEntity() is a stronger check, which I now understand needs to be there.
See merge request !43
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java
index 38567e3..c50d141 100755
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/TypeRepository.java
@@ -105,7 +105,7 @@
return new DateValueDescriptor(repo);
} else if (staticAnyTypes.contains(type)) {
return new AnyDescriptor(type, repo);
- } else if (IDLEntity.class.isAssignableFrom(type)) {
+ } else if ((IDLEntity.class.isAssignableFrom(type)) && isIDLEntity(type)) {
return new IDLEntityDescriptor(type, repo);
} else if (Throwable.class.isAssignableFrom(type)) {
return new ExceptionDescriptor(type, repo);
@@ -157,18 +157,24 @@
}
}
+ private static boolean isIDLEntity(Class<?> type) {
+ for (Class<?> intf : type.getInterfaces()) {
+ if (intf.equals(IDLEntity.class))
+ return true;
+ }
+ return false;
+ }
+
private static boolean isAbstractInterface(Class<?> type) {
if (!type.isInterface())
return false;
- Class<?>[] interfaces = type.getInterfaces();
- for (Class<?> anInterface : interfaces) {
- if (!isAbstractInterface(anInterface))
+ for (Class<?> intf : type.getInterfaces()) {
+ if (!isAbstractInterface(intf))
return false;
}
- java.lang.reflect.Method[] methods = type.getDeclaredMethods();
- for (Method method : methods) {
+ for (Method method : type.getDeclaredMethods()) {
if (!isRemoteMethod(method))
return false;
}
@@ -177,10 +183,8 @@
}
private static boolean isRemoteMethod(java.lang.reflect.Method m) {
- Class<?>[] ex = m.getExceptionTypes();
-
- for (Class<?> anEx : ex) {
- if (anEx.isAssignableFrom(RemoteException.class))
+ for (Class<?> exceptionType : m.getExceptionTypes()) {
+ if (exceptionType.isAssignableFrom(RemoteException.class))
return true;
}