提交 9e77d949 编写于 作者: M msheppar

8076392: Improve IIOPInputStream consistency

Reviewed-by: rriggs, coffeys, skoivu, ahgross
上级 f6688cd1
...@@ -567,6 +567,11 @@ public class IIOPInputStream ...@@ -567,6 +567,11 @@ public class IIOPInputStream
// XXX I18N, logging needed. // XXX I18N, logging needed.
throw new NotActiveException("defaultReadObjectDelegate"); throw new NotActiveException("defaultReadObjectDelegate");
if (!currentClassDesc.forClass().isAssignableFrom(
currentObject.getClass())) {
throw new IOException("Object Type mismatch");
}
// The array will be null unless fields were retrieved // The array will be null unless fields were retrieved
// remotely because of a serializable version difference. // remotely because of a serializable version difference.
// Bug fix for 4365188. See the definition of // Bug fix for 4365188. See the definition of
...@@ -2257,6 +2262,27 @@ public class IIOPInputStream ...@@ -2257,6 +2262,27 @@ public class IIOPInputStream
try { try {
Class fieldCl = fields[i].getClazz(); Class fieldCl = fields[i].getClazz();
if ((objectValue != null)
&& (!fieldCl.isAssignableFrom(
objectValue.getClass()))) {
throw new IllegalArgumentException("Field mismatch");
}
Field classField = null;
try {
classField = cl.getDeclaredField(fields[i].getName());
} catch (NoSuchFieldException nsfEx) {
throw new IllegalArgumentException(nsfEx);
} catch (SecurityException secEx) {
throw new IllegalArgumentException(secEx.getCause());
}
Class<?> declaredFieldClass = classField.getType();
// check input field type is a declared field type
// input field is a subclass of the declared field
if (!declaredFieldClass.isAssignableFrom(fieldCl)) {
throw new IllegalArgumentException(
"Field Type mismatch");
}
if (objectValue != null && !fieldCl.isInstance(objectValue)) { if (objectValue != null && !fieldCl.isInstance(objectValue)) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册