565 try { |
565 try { |
566 if (currentObject == null || currentClassDesc == null) |
566 if (currentObject == null || currentClassDesc == null) |
567 // XXX I18N, logging needed. |
567 // XXX I18N, logging needed. |
568 throw new NotActiveException("defaultReadObjectDelegate"); |
568 throw new NotActiveException("defaultReadObjectDelegate"); |
569 |
569 |
|
570 if (!currentClassDesc.forClass().isAssignableFrom( |
|
571 currentObject.getClass())) { |
|
572 throw new IOException("Object Type mismatch"); |
|
573 } |
|
574 |
570 // The array will be null unless fields were retrieved |
575 // The array will be null unless fields were retrieved |
571 // remotely because of a serializable version difference. |
576 // remotely because of a serializable version difference. |
572 // Bug fix for 4365188. See the definition of |
577 // Bug fix for 4365188. See the definition of |
573 // defaultReadObjectFVDMembers for more information. |
578 // defaultReadObjectFVDMembers for more information. |
574 if (defaultReadObjectFVDMembers != null && |
579 if (defaultReadObjectFVDMembers != null && |
2255 continue; |
2260 continue; |
2256 } |
2261 } |
2257 |
2262 |
2258 try { |
2263 try { |
2259 Class fieldCl = fields[i].getClazz(); |
2264 Class fieldCl = fields[i].getClazz(); |
|
2265 if ((objectValue != null) |
|
2266 && (!fieldCl.isAssignableFrom( |
|
2267 objectValue.getClass()))) { |
|
2268 throw new IllegalArgumentException("Field mismatch"); |
|
2269 } |
|
2270 Field classField = null; |
|
2271 try { |
|
2272 classField = cl.getDeclaredField(fields[i].getName()); |
|
2273 } catch (NoSuchFieldException nsfEx) { |
|
2274 throw new IllegalArgumentException(nsfEx); |
|
2275 } catch (SecurityException secEx) { |
|
2276 throw new IllegalArgumentException(secEx.getCause()); |
|
2277 } |
|
2278 Class<?> declaredFieldClass = classField.getType(); |
|
2279 |
|
2280 // check input field type is a declared field type |
|
2281 // input field is a subclass of the declared field |
|
2282 if (!declaredFieldClass.isAssignableFrom(fieldCl)) { |
|
2283 throw new IllegalArgumentException( |
|
2284 "Field Type mismatch"); |
|
2285 } |
2260 if (objectValue != null && !fieldCl.isInstance(objectValue)) { |
2286 if (objectValue != null && !fieldCl.isInstance(objectValue)) { |
2261 throw new IllegalArgumentException(); |
2287 throw new IllegalArgumentException(); |
2262 } |
2288 } |
2263 bridge.putObject( o, fields[i].getFieldID(), objectValue ) ; |
2289 bridge.putObject( o, fields[i].getFieldID(), objectValue ) ; |
2264 // reflective code: fields[i].getField().set( o, objectValue ) ; |
2290 // reflective code: fields[i].getField().set( o, objectValue ) ; |