Mercurial > hg > openjdk > bsd-port > corba
changeset 1334:be3a966e2c3e
Merge from main OpenJDK repository
author | Greg Lewis <glewis@eyesbeyond.com> |
---|---|
date | Sat, 12 Dec 2015 22:19:36 -0800 |
parents | e3a6331d136e (diff) acb37c871198 (current diff) |
children | 4d1634237e89 |
files | .hgtags |
diffstat | 4 files changed, 200 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Sun Apr 19 13:24:08 2015 -0700 +++ b/.hgtags Sat Dec 12 22:19:36 2015 -0800 @@ -597,3 +597,9 @@ 90e140a093262c0ca0b408a5997074fbd87639c0 jdk7u80-b14 52b7bbe24e490090f98bee27dbd5ec5715b31243 jdk7u80-b30 353be4a0a6ec19350d18e0e9ded5544ed5d7433f jdk7u80-b15 +a97bddc81932c9772184182297291abacccc85c0 jdk7u80-b32 +02c5cee149d94496124f794b7ef89d860b8710ee jdk7u85-b00 +a1436e2c0aa8c35b4c738004d19549df54448621 jdk7u85-b01 +7a91bf11c82bd794b7d6f63187345ebcbe07f37c jdk7u85-b02 +f9630ed441a06612f61a88bd3da39075015213a7 jdk7u91-b00 +34be12b4b6ea5f30d364a916a92effeafdce678d jdk7u91-b01
--- a/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Sun Apr 19 13:24:08 2015 -0700 +++ b/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Sat Dec 12 22:19:36 2015 -0800 @@ -567,6 +567,11 @@ // XXX I18N, logging needed. 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 // remotely because of a serializable version difference. // Bug fix for 4365188. See the definition of @@ -1063,6 +1068,9 @@ int spBase = spClass; // current top of stack + if (currentClass.getName().equals("java.lang.String")) { + return this.readUTF(); + } /* The object's classes should be processed from supertype to subtype * Push all the clases of the current object onto a stack. * Note that only the serializable classes are represented @@ -2244,6 +2252,27 @@ try { 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)) { throw new IllegalArgumentException(); } @@ -2417,8 +2446,8 @@ private void throwAwayData(ValueMember[] fields, com.sun.org.omg.SendingContext.CodeBase sender) throws InvalidClassException, StreamCorruptedException, - ClassNotFoundException, IOException - { + ClassNotFoundException, IOException { + for (int i = 0; i < fields.length; ++i) { try { @@ -2553,8 +2582,7 @@ } - private static void setObjectField(Object o, Class c, String fieldName, Object v) - { + private static void setObjectField(Object o, Class c, String fieldName, Object v) { try { Field fld = c.getDeclaredField( fieldName ) ; Class fieldCl = fld.getType(); @@ -2564,9 +2592,15 @@ long key = bridge.objectFieldOffset( fld ) ; bridge.putObject( o, key, v ) ; } catch (Exception e) { - throw utilWrapper.errorSetObjectField( e, fieldName, - o.toString(), - v.toString() ) ; + if (o != null) { + throw utilWrapper.errorSetObjectField( e, fieldName, + o.toString(), + v.toString() ) ; + } else { + throw utilWrapper.errorSetObjectField( e, fieldName, + "null " + c.getName() + " object", + v.toString() ) ; + } } } @@ -2574,12 +2608,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putBoolean( o, key, v ) ; + if ((fld != null) && (fld.getType() == Boolean.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putBoolean( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { + if (o != null) { throw utilWrapper.errorSetBooleanField( e, fieldName, o.toString(), new Boolean(v) ) ; + } else { + throw utilWrapper.errorSetBooleanField( e, fieldName, + "null " + c.getName() + " object", + new Boolean(v) ) ; + } } } @@ -2587,12 +2631,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putByte( o, key, v ) ; + if ((fld != null) && (fld.getType() == Byte.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putByte( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { - throw utilWrapper.errorSetByteField( e, fieldName, - o.toString(), - new Byte(v) ) ; + if (o != null) { + throw utilWrapper.errorSetByteField( e, fieldName, + o.toString(), + new Byte(v) ) ; + } else { + throw utilWrapper.errorSetByteField( e, fieldName, + "null " + c.getName() + " object", + new Byte(v) ) ; + } } } @@ -2600,12 +2654,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putChar( o, key, v ) ; + if ((fld != null) && (fld.getType() == Character.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putChar( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { - throw utilWrapper.errorSetCharField( e, fieldName, - o.toString(), - new Character(v) ) ; + if (o != null) { + throw utilWrapper.errorSetCharField( e, fieldName, + o.toString(), + new Character(v) ) ; + } else { + throw utilWrapper.errorSetCharField( e, fieldName, + "null " + c.getName() + " object", + new Character(v) ) ; + } } } @@ -2613,12 +2677,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putShort( o, key, v ) ; + if ((fld != null) && (fld.getType() == Short.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putShort( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { + if (o != null) { throw utilWrapper.errorSetShortField( e, fieldName, o.toString(), new Short(v) ) ; + } else { + throw utilWrapper.errorSetShortField( e, fieldName, + "null " + c.getName() + " object", + new Short(v) ) ; + } } } @@ -2626,12 +2700,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putInt( o, key, v ) ; + if ((fld != null) && (fld.getType() == Integer.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putInt( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { - throw utilWrapper.errorSetIntField( e, fieldName, - o.toString(), - new Integer(v) ) ; + if (o != null) { + throw utilWrapper.errorSetIntField( e, fieldName, + o.toString(), + new Integer(v) ) ; + } else { + throw utilWrapper.errorSetIntField( e, fieldName, + "null " + c.getName() + " object", + new Integer(v) ) ; + } } } @@ -2639,12 +2723,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putLong( o, key, v ) ; + if ((fld != null) && (fld.getType() == Long.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putLong( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { - throw utilWrapper.errorSetLongField( e, fieldName, - o.toString(), - new Long(v) ) ; + if (o != null) { + throw utilWrapper.errorSetLongField( e, fieldName, + o.toString(), + new Long(v) ) ; + } else { + throw utilWrapper.errorSetLongField( e, fieldName, + "null " + c.getName() + " object", + new Long(v) ) ; + } } } @@ -2652,12 +2746,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putFloat( o, key, v ) ; + if ((fld != null) && (fld.getType() == Float.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putFloat( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { - throw utilWrapper.errorSetFloatField( e, fieldName, - o.toString(), - new Float(v) ) ; + if (o != null) { + throw utilWrapper.errorSetFloatField( e, fieldName, + o.toString(), + new Float(v) ) ; + } else { + throw utilWrapper.errorSetFloatField( e, fieldName, + "null " + c.getName() + " object", + new Float(v) ) ; + } } } @@ -2665,12 +2769,22 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; - long key = bridge.objectFieldOffset( fld ) ; - bridge.putDouble( o, key, v ) ; + if ((fld != null) && (fld.getType() == Double.TYPE)) { + long key = bridge.objectFieldOffset( fld ) ; + bridge.putDouble( o, key, v ) ; + } else { + throw new InvalidObjectException("Field Type mismatch"); + } } catch (Exception e) { - throw utilWrapper.errorSetDoubleField( e, fieldName, - o.toString(), - new Double(v) ) ; + if (o != null) { + throw utilWrapper.errorSetDoubleField( e, fieldName, + o.toString(), + new Double(v) ) ; + } else { + throw utilWrapper.errorSetDoubleField( e, fieldName, + "null " + c.getName() + " object", + new Double(v) ) ; + } } }
--- a/src/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java Sun Apr 19 13:24:08 2015 -0700 +++ b/src/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java Sat Dec 12 22:19:36 2015 -0800 @@ -559,6 +559,10 @@ * Push all the clases of the current object onto a stack. * Remember the stack pointer where this set of classes is being pushed. */ + if (currentClassDesc.forClass().getName().equals("java.lang.String")) { + this.writeUTF((String)obj); + return; + } int stackMark = classDescStack.size(); try { ObjectStreamClass next;
--- a/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Sun Apr 19 13:24:08 2015 -0700 +++ b/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Sat Dec 12 22:19:36 2015 -0800 @@ -446,6 +446,9 @@ if (emitPermissionCheck) { // produce the following generated code + // + // private transient boolean _instantiated = false; + // // private static Void checkPermission() { // SecurityManager sm = System.getSecurityManager(); // if (sm != null) { @@ -460,10 +463,21 @@ // // public _XXXXXX_Stub() { // this(checkPermission()); + // _instantiated = true; // } + // + // private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { + // checkPermission(); + // s.defaultReadObject(); + // _instantiated = true; + // } + // // where XXXXXX is the name of the remote interface p.pln(); + p.plnI("private transient boolean _instantiated = false;"); + p.pln(); + p.pO(); p.plnI("private static Void checkPermission() {"); p.plnI("SecurityManager sm = System.getSecurityManager();"); p.pln("if (sm != null) {"); @@ -480,13 +494,23 @@ p.pO(); p.pI(); - p.pln("private " + currentClass + "(Void ignore) { }"); + p.plnI("private " + currentClass + "(Void ignore) { }"); p.pln(); - - p.plnI("public " + currentClass + "() { "); + p.pO(); + + p.plnI("public " + currentClass + "() {"); p.pln("this(checkPermission());"); + p.pln("_instantiated = true;"); p.pOln("}"); p.pln(); + p.plnI("private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {"); + p.plnI("checkPermission();"); + p.pO(); + p.pln("s.defaultReadObject();"); + p.pln("_instantiated = true;"); + p.pOln("}"); + p.pln(); + //p.pO(); } if (!emitPermissionCheck) { @@ -893,6 +917,7 @@ String paramNames[] = method.getArgumentNames(); Type returnType = method.getReturnType(); ValueType[] exceptions = getStubExceptions(method,false); + boolean hasIOException = false; addNamesInUse(method); addNameInUse("_type_ids"); @@ -920,6 +945,13 @@ p.plnI(" {"); // Now create the method body... + if (emitPermissionCheck) { + p.pln("if ((System.getSecurityManager() != null) && (!_instantiated)) {"); + p.plnI(" throw new java.io.IOError(new java.io.IOException(\"InvalidObject \"));"); + p.pOln("}"); + p.pln(); + } + if (localStubs) { writeLocalStubMethodBody(p,method,theType);