8076376: Enhance IIOP operations jdk8u51-b10

Mon, 20 Apr 2015 00:46:38 +0100

author
msheppar
date
Mon, 20 Apr 2015 00:46:38 +0100
changeset 984
0011162b38bf
parent 983
61b6fb01e45b
child 985
1ab54bb9f571

8076376: Enhance IIOP operations
Reviewed-by: rriggs, coffeys, ahgross, skoivu

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	Mon Apr 20 12:51:21 2015 -0700
     1.2 +++ b/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java	Mon Apr 20 00:46:38 2015 +0100
     1.3 @@ -2417,8 +2417,8 @@
     1.4      private void throwAwayData(ValueMember[] fields,
     1.5                                 com.sun.org.omg.SendingContext.CodeBase sender)
     1.6          throws InvalidClassException, StreamCorruptedException,
     1.7 -               ClassNotFoundException, IOException
     1.8 -    {
     1.9 +               ClassNotFoundException, IOException {
    1.10 +
    1.11          for (int i = 0; i < fields.length; ++i) {
    1.12  
    1.13              try {
    1.14 @@ -2553,8 +2553,7 @@
    1.15  
    1.16      }
    1.17  
    1.18 -    private static void setObjectField(Object o, Class c, String fieldName, Object v)
    1.19 -    {
    1.20 +    private static void setObjectField(Object o, Class c, String fieldName, Object v) {
    1.21          try {
    1.22              Field fld = c.getDeclaredField( fieldName ) ;
    1.23              Class fieldCl = fld.getType();
    1.24 @@ -2564,9 +2563,15 @@
    1.25              long key = bridge.objectFieldOffset( fld ) ;
    1.26              bridge.putObject( o, key, v ) ;
    1.27          } catch (Exception e) {
    1.28 -            throw utilWrapper.errorSetObjectField( e, fieldName,
    1.29 -                o.toString(),
    1.30 -                v.toString() ) ;
    1.31 +            if (o != null) {
    1.32 +                throw utilWrapper.errorSetObjectField( e, fieldName,
    1.33 +                    o.toString(),
    1.34 +                    v.toString() ) ;
    1.35 +            } else {
    1.36 +                throw utilWrapper.errorSetObjectField( e, fieldName,
    1.37 +                    "null " + c.getName() + " object",
    1.38 +                    v.toString() ) ;
    1.39 +            }
    1.40          }
    1.41      }
    1.42  
    1.43 @@ -2574,12 +2579,22 @@
    1.44      {
    1.45          try {
    1.46              Field fld = c.getDeclaredField( fieldName ) ;
    1.47 -            long key = bridge.objectFieldOffset( fld ) ;
    1.48 -            bridge.putBoolean( o, key, v ) ;
    1.49 +            if ((fld != null) && (fld.getType() == Boolean.TYPE)) {
    1.50 +                long key = bridge.objectFieldOffset( fld ) ;
    1.51 +                bridge.putBoolean( o, key, v ) ;
    1.52 +            } else {
    1.53 +                throw new InvalidObjectException("Field Type mismatch");
    1.54 +            }
    1.55          } catch (Exception e) {
    1.56 +            if (o != null) {
    1.57              throw utilWrapper.errorSetBooleanField( e, fieldName,
    1.58                  o.toString(),
    1.59                  new Boolean(v) ) ;
    1.60 +            } else {
    1.61 +                throw utilWrapper.errorSetBooleanField( e, fieldName,
    1.62 +                    "null " + c.getName() + " object",
    1.63 +                    new Boolean(v) ) ;
    1.64 +            }
    1.65          }
    1.66      }
    1.67  
    1.68 @@ -2587,12 +2602,22 @@
    1.69      {
    1.70          try {
    1.71              Field fld = c.getDeclaredField( fieldName ) ;
    1.72 -            long key = bridge.objectFieldOffset( fld ) ;
    1.73 -            bridge.putByte( o, key, v ) ;
    1.74 +            if ((fld != null) && (fld.getType() == Byte.TYPE)) {
    1.75 +                long key = bridge.objectFieldOffset( fld ) ;
    1.76 +                bridge.putByte( o, key, v ) ;
    1.77 +            } else {
    1.78 +                throw new InvalidObjectException("Field Type mismatch");
    1.79 +            }
    1.80          } catch (Exception e) {
    1.81 -            throw utilWrapper.errorSetByteField( e, fieldName,
    1.82 -                o.toString(),
    1.83 -                new Byte(v) ) ;
    1.84 +            if (o != null) {
    1.85 +                throw utilWrapper.errorSetByteField( e, fieldName,
    1.86 +                    o.toString(),
    1.87 +                    new Byte(v) ) ;
    1.88 +            } else {
    1.89 +                throw utilWrapper.errorSetByteField( e, fieldName,
    1.90 +                    "null " + c.getName() + " object",
    1.91 +                    new Byte(v) ) ;
    1.92 +            }
    1.93          }
    1.94      }
    1.95  
    1.96 @@ -2600,12 +2625,22 @@
    1.97      {
    1.98          try {
    1.99              Field fld = c.getDeclaredField( fieldName ) ;
   1.100 -            long key = bridge.objectFieldOffset( fld ) ;
   1.101 -            bridge.putChar( o, key, v ) ;
   1.102 +            if ((fld != null) && (fld.getType() == Character.TYPE)) {
   1.103 +                long key = bridge.objectFieldOffset( fld ) ;
   1.104 +                bridge.putChar( o, key, v ) ;
   1.105 +            } else {
   1.106 +                throw new InvalidObjectException("Field Type mismatch");
   1.107 +            }
   1.108          } catch (Exception e) {
   1.109 -            throw utilWrapper.errorSetCharField( e, fieldName,
   1.110 -                o.toString(),
   1.111 -                new Character(v) ) ;
   1.112 +            if (o != null) {
   1.113 +                throw utilWrapper.errorSetCharField( e, fieldName,
   1.114 +                    o.toString(),
   1.115 +                    new Character(v) ) ;
   1.116 +            } else {
   1.117 +                throw utilWrapper.errorSetCharField( e, fieldName,
   1.118 +                    "null " + c.getName() + " object",
   1.119 +                    new Character(v) ) ;
   1.120 +            }
   1.121          }
   1.122      }
   1.123  
   1.124 @@ -2613,12 +2648,22 @@
   1.125      {
   1.126          try {
   1.127              Field fld = c.getDeclaredField( fieldName ) ;
   1.128 -            long key = bridge.objectFieldOffset( fld ) ;
   1.129 -            bridge.putShort( o, key, v ) ;
   1.130 +            if ((fld != null) && (fld.getType() == Short.TYPE)) {
   1.131 +                long key = bridge.objectFieldOffset( fld ) ;
   1.132 +                bridge.putShort( o, key, v ) ;
   1.133 +            } else {
   1.134 +                throw new InvalidObjectException("Field Type mismatch");
   1.135 +            }
   1.136          } catch (Exception e) {
   1.137 +            if (o != null) {
   1.138              throw utilWrapper.errorSetShortField( e, fieldName,
   1.139                  o.toString(),
   1.140                  new Short(v) ) ;
   1.141 +            } else {
   1.142 +                throw utilWrapper.errorSetShortField( e, fieldName,
   1.143 +                    "null " + c.getName() + " object",
   1.144 +                    new Short(v) ) ;
   1.145 +            }
   1.146          }
   1.147      }
   1.148  
   1.149 @@ -2626,12 +2671,22 @@
   1.150      {
   1.151          try {
   1.152              Field fld = c.getDeclaredField( fieldName ) ;
   1.153 -            long key = bridge.objectFieldOffset( fld ) ;
   1.154 -            bridge.putInt( o, key, v ) ;
   1.155 +            if ((fld != null) && (fld.getType() == Integer.TYPE)) {
   1.156 +                long key = bridge.objectFieldOffset( fld ) ;
   1.157 +                bridge.putInt( o, key, v ) ;
   1.158 +            } else {
   1.159 +                throw new InvalidObjectException("Field Type mismatch");
   1.160 +            }
   1.161          } catch (Exception e) {
   1.162 -            throw utilWrapper.errorSetIntField( e, fieldName,
   1.163 -                o.toString(),
   1.164 -                new Integer(v) ) ;
   1.165 +            if (o != null) {
   1.166 +                throw utilWrapper.errorSetIntField( e, fieldName,
   1.167 +                    o.toString(),
   1.168 +                    new Integer(v) ) ;
   1.169 +            } else {
   1.170 +                throw utilWrapper.errorSetIntField( e, fieldName,
   1.171 +                    "null " + c.getName() + " object",
   1.172 +                    new Integer(v) ) ;
   1.173 +            }
   1.174          }
   1.175      }
   1.176  
   1.177 @@ -2639,12 +2694,22 @@
   1.178      {
   1.179          try {
   1.180              Field fld = c.getDeclaredField( fieldName ) ;
   1.181 -            long key = bridge.objectFieldOffset( fld ) ;
   1.182 -            bridge.putLong( o, key, v ) ;
   1.183 +            if ((fld != null) && (fld.getType() == Long.TYPE)) {
   1.184 +                long key = bridge.objectFieldOffset( fld ) ;
   1.185 +                bridge.putLong( o, key, v ) ;
   1.186 +            } else {
   1.187 +                throw new InvalidObjectException("Field Type mismatch");
   1.188 +            }
   1.189          } catch (Exception e) {
   1.190 -            throw utilWrapper.errorSetLongField( e, fieldName,
   1.191 -                o.toString(),
   1.192 -                new Long(v) ) ;
   1.193 +            if (o != null) {
   1.194 +                throw utilWrapper.errorSetLongField( e, fieldName,
   1.195 +                    o.toString(),
   1.196 +                    new Long(v) ) ;
   1.197 +            } else {
   1.198 +                throw utilWrapper.errorSetLongField( e, fieldName,
   1.199 +                    "null " + c.getName() + " object",
   1.200 +                    new Long(v) ) ;
   1.201 +            }
   1.202          }
   1.203      }
   1.204  
   1.205 @@ -2652,12 +2717,22 @@
   1.206      {
   1.207          try {
   1.208              Field fld = c.getDeclaredField( fieldName ) ;
   1.209 -            long key = bridge.objectFieldOffset( fld ) ;
   1.210 -            bridge.putFloat( o, key, v ) ;
   1.211 +            if ((fld != null) && (fld.getType() == Float.TYPE)) {
   1.212 +                long key = bridge.objectFieldOffset( fld ) ;
   1.213 +                bridge.putFloat( o, key, v ) ;
   1.214 +            } else {
   1.215 +                throw new InvalidObjectException("Field Type mismatch");
   1.216 +            }
   1.217          } catch (Exception e) {
   1.218 -            throw utilWrapper.errorSetFloatField( e, fieldName,
   1.219 -                o.toString(),
   1.220 -                new Float(v) ) ;
   1.221 +            if (o != null) {
   1.222 +                throw utilWrapper.errorSetFloatField( e, fieldName,
   1.223 +                    o.toString(),
   1.224 +                    new Float(v) ) ;
   1.225 +            } else {
   1.226 +                throw utilWrapper.errorSetFloatField( e, fieldName,
   1.227 +                    "null " + c.getName() + " object",
   1.228 +                    new Float(v) ) ;
   1.229 +            }
   1.230          }
   1.231      }
   1.232  
   1.233 @@ -2665,12 +2740,22 @@
   1.234      {
   1.235          try {
   1.236              Field fld = c.getDeclaredField( fieldName ) ;
   1.237 -            long key = bridge.objectFieldOffset( fld ) ;
   1.238 -            bridge.putDouble( o, key, v ) ;
   1.239 +            if ((fld != null) && (fld.getType() == Double.TYPE)) {
   1.240 +                long key = bridge.objectFieldOffset( fld ) ;
   1.241 +                bridge.putDouble( o, key, v ) ;
   1.242 +            } else {
   1.243 +                throw new InvalidObjectException("Field Type mismatch");
   1.244 +            }
   1.245          } catch (Exception e) {
   1.246 -            throw utilWrapper.errorSetDoubleField( e, fieldName,
   1.247 -                o.toString(),
   1.248 -                new Double(v) ) ;
   1.249 +            if (o != null) {
   1.250 +                throw utilWrapper.errorSetDoubleField( e, fieldName,
   1.251 +                    o.toString(),
   1.252 +                    new Double(v) ) ;
   1.253 +            } else {
   1.254 +                throw utilWrapper.errorSetDoubleField( e, fieldName,
   1.255 +                    "null " + c.getName() + " object",
   1.256 +                    new Double(v) ) ;
   1.257 +            }
   1.258          }
   1.259      }
   1.260  

mercurial