8076392: Improve IIOPInputStream consistency

Tue, 14 Jul 2015 16:49:41 +0100

author
msheppar
date
Tue, 14 Jul 2015 16:49:41 +0100
changeset 1065
d185c856ef85
parent 1064
0ce82d688596
child 1066
05084f644c07

8076392: Improve IIOPInputStream consistency
Reviewed-by: rriggs, coffeys, skoivu, ahgross

src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java	Thu Jul 16 12:52:59 2015 -0700
     1.2 +++ b/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java	Tue Jul 14 16:49:41 2015 +0100
     1.3 @@ -567,6 +567,11 @@
     1.4                  // XXX I18N, logging needed.
     1.5                  throw new NotActiveException("defaultReadObjectDelegate");
     1.6  
     1.7 +            if (!currentClassDesc.forClass().isAssignableFrom(
     1.8 +                    currentObject.getClass())) {
     1.9 +                throw new IOException("Object Type mismatch");
    1.10 +            }
    1.11 +
    1.12              // The array will be null unless fields were retrieved
    1.13              // remotely because of a serializable version difference.
    1.14              // Bug fix for 4365188.  See the definition of
    1.15 @@ -2257,6 +2262,27 @@
    1.16  
    1.17                  try {
    1.18                      Class fieldCl = fields[i].getClazz();
    1.19 +                    if ((objectValue != null)
    1.20 +                            && (!fieldCl.isAssignableFrom(
    1.21 +                                    objectValue.getClass()))) {
    1.22 +                        throw new IllegalArgumentException("Field mismatch");
    1.23 +                    }
    1.24 +                   Field classField = null;
    1.25 +                    try {
    1.26 +                        classField = cl.getDeclaredField(fields[i].getName());
    1.27 +                    } catch (NoSuchFieldException nsfEx) {
    1.28 +                        throw new IllegalArgumentException(nsfEx);
    1.29 +                    } catch (SecurityException secEx) {
    1.30 +                        throw new IllegalArgumentException(secEx.getCause());
    1.31 +                    }
    1.32 +                    Class<?> declaredFieldClass = classField.getType();
    1.33 +
    1.34 +                    // check input field type is a declared field type
    1.35 +                    // input field is a subclass of the declared field
    1.36 +                    if (!declaredFieldClass.isAssignableFrom(fieldCl)) {
    1.37 +                        throw new IllegalArgumentException(
    1.38 +                                "Field Type mismatch");
    1.39 +                    }
    1.40                      if (objectValue != null && !fieldCl.isInstance(objectValue)) {
    1.41                          throw new IllegalArgumentException();
    1.42                      }

mercurial