Skip to content
Permalink
Browse files
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
  • Loading branch information
ngmr committed May 23, 2015
2 parents 1cb8167 + 026747d commit 06b73e296ed98c3eced65582d93237893e9e4543
Showing 1 changed file with 14 additions and 10 deletions.
@@ -105,7 +105,7 @@ protected TypeDescriptor computeValue(Class<?> type) {
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 TypeDescriptor primitiveDescriptor(Class<?> type) {
}
}

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 isAbstractInterface(Class<?> type) {
}

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;
}

0 comments on commit 06b73e2

Please sign in to comment.