rt/emul/compact/src/main/java/java/lang/invoke/MethodType.java
branchjdk8
changeset 1651 5c990ed353e9
parent 1646 c880a8a8803b
     1.1 --- a/rt/emul/compact/src/main/java/java/lang/invoke/MethodType.java	Sat Aug 09 11:11:13 2014 +0200
     1.2 +++ b/rt/emul/compact/src/main/java/java/lang/invoke/MethodType.java	Sun Aug 10 06:13:36 2014 +0200
     1.3 @@ -948,60 +948,60 @@
     1.4       */
     1.5      private static final java.io.ObjectStreamField[] serialPersistentFields = { };
     1.6  
     1.7 -    /**
     1.8 -     * Save the {@code MethodType} instance to a stream.
     1.9 -     *
    1.10 -     * @serialData
    1.11 -     * For portability, the serialized format does not refer to named fields.
    1.12 -     * Instead, the return type and parameter type arrays are written directly
    1.13 -     * from the {@code writeObject} method, using two calls to {@code s.writeObject}
    1.14 -     * as follows:
    1.15 -     * <blockquote><pre>{@code
    1.16 -s.writeObject(this.returnType());
    1.17 -s.writeObject(this.parameterArray());
    1.18 -     * }</pre></blockquote>
    1.19 -     * <p>
    1.20 -     * The deserialized field values are checked as if they were
    1.21 -     * provided to the factory method {@link #methodType(Class,Class[]) methodType}.
    1.22 -     * For example, null values, or {@code void} parameter types,
    1.23 -     * will lead to exceptions during deserialization.
    1.24 -     * @param s the stream to write the object to
    1.25 -     * @throws java.io.IOException if there is a problem writing the object
    1.26 -     */
    1.27 -    private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
    1.28 -        s.defaultWriteObject();  // requires serialPersistentFields to be an empty array
    1.29 -        s.writeObject(returnType());
    1.30 -        s.writeObject(parameterArray());
    1.31 -    }
    1.32 -
    1.33 -    /**
    1.34 -     * Reconstitute the {@code MethodType} instance from a stream (that is,
    1.35 -     * deserialize it).
    1.36 -     * This instance is a scratch object with bogus final fields.
    1.37 -     * It provides the parameters to the factory method called by
    1.38 -     * {@link #readResolve readResolve}.
    1.39 -     * After that call it is discarded.
    1.40 -     * @param s the stream to read the object from
    1.41 -     * @throws java.io.IOException if there is a problem reading the object
    1.42 -     * @throws ClassNotFoundException if one of the component classes cannot be resolved
    1.43 -     * @see #MethodType()
    1.44 -     * @see #readResolve
    1.45 -     * @see #writeObject
    1.46 -     */
    1.47 -    private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
    1.48 -        s.defaultReadObject();  // requires serialPersistentFields to be an empty array
    1.49 -
    1.50 -        Class<?>   returnType     = (Class<?>)   s.readObject();
    1.51 -        Class<?>[] parameterArray = (Class<?>[]) s.readObject();
    1.52 -
    1.53 -        // Probably this object will never escape, but let's check
    1.54 -        // the field values now, just to be sure.
    1.55 -        checkRtype(returnType);
    1.56 -        checkPtypes(parameterArray);
    1.57 -
    1.58 -        parameterArray = parameterArray.clone();  // make sure it is unshared
    1.59 -        MethodType_init(returnType, parameterArray);
    1.60 -    }
    1.61 +//    /**
    1.62 +//     * Save the {@code MethodType} instance to a stream.
    1.63 +//     *
    1.64 +//     * @serialData
    1.65 +//     * For portability, the serialized format does not refer to named fields.
    1.66 +//     * Instead, the return type and parameter type arrays are written directly
    1.67 +//     * from the {@code writeObject} method, using two calls to {@code s.writeObject}
    1.68 +//     * as follows:
    1.69 +//     * <blockquote><pre>{@code
    1.70 +//s.writeObject(this.returnType());
    1.71 +//s.writeObject(this.parameterArray());
    1.72 +//     * }</pre></blockquote>
    1.73 +//     * <p>
    1.74 +//     * The deserialized field values are checked as if they were
    1.75 +//     * provided to the factory method {@link #methodType(Class,Class[]) methodType}.
    1.76 +//     * For example, null values, or {@code void} parameter types,
    1.77 +//     * will lead to exceptions during deserialization.
    1.78 +//     * @param s the stream to write the object to
    1.79 +//     * @throws java.io.IOException if there is a problem writing the object
    1.80 +//     */
    1.81 +//    private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
    1.82 +//        s.defaultWriteObject();  // requires serialPersistentFields to be an empty array
    1.83 +//        s.writeObject(returnType());
    1.84 +//        s.writeObject(parameterArray());
    1.85 +//    }
    1.86 +//
    1.87 +//    /**
    1.88 +//     * Reconstitute the {@code MethodType} instance from a stream (that is,
    1.89 +//     * deserialize it).
    1.90 +//     * This instance is a scratch object with bogus final fields.
    1.91 +//     * It provides the parameters to the factory method called by
    1.92 +//     * {@link #readResolve readResolve}.
    1.93 +//     * After that call it is discarded.
    1.94 +//     * @param s the stream to read the object from
    1.95 +//     * @throws java.io.IOException if there is a problem reading the object
    1.96 +//     * @throws ClassNotFoundException if one of the component classes cannot be resolved
    1.97 +//     * @see #MethodType()
    1.98 +//     * @see #readResolve
    1.99 +//     * @see #writeObject
   1.100 +//     */
   1.101 +//    private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
   1.102 +//        s.defaultReadObject();  // requires serialPersistentFields to be an empty array
   1.103 +//
   1.104 +//        Class<?>   returnType     = (Class<?>)   s.readObject();
   1.105 +//        Class<?>[] parameterArray = (Class<?>[]) s.readObject();
   1.106 +//
   1.107 +//        // Probably this object will never escape, but let's check
   1.108 +//        // the field values now, just to be sure.
   1.109 +//        checkRtype(returnType);
   1.110 +//        checkPtypes(parameterArray);
   1.111 +//
   1.112 +//        parameterArray = parameterArray.clone();  // make sure it is unshared
   1.113 +//        MethodType_init(returnType, parameterArray);
   1.114 +//    }
   1.115  
   1.116      /**
   1.117       * For serialization only.
   1.118 @@ -1011,27 +1011,27 @@
   1.119          this.rtype = null;
   1.120          this.ptypes = null;
   1.121      }
   1.122 -    private void MethodType_init(Class<?> rtype, Class<?>[] ptypes) {
   1.123 -        // In order to communicate these values to readResolve, we must
   1.124 -        // store them into the implementation-specific final fields.
   1.125 -        checkRtype(rtype);
   1.126 -        checkPtypes(ptypes);
   1.127 -        UNSAFE.putObject(this, rtypeOffset, rtype);
   1.128 -        UNSAFE.putObject(this, ptypesOffset, ptypes);
   1.129 -    }
   1.130 +//    private void MethodType_init(Class<?> rtype, Class<?>[] ptypes) {
   1.131 +//        // In order to communicate these values to readResolve, we must
   1.132 +//        // store them into the implementation-specific final fields.
   1.133 +//        checkRtype(rtype);
   1.134 +//        checkPtypes(ptypes);
   1.135 +//        UNSAFE.putObject(this, rtypeOffset, rtype);
   1.136 +//        UNSAFE.putObject(this, ptypesOffset, ptypes);
   1.137 +//    }
   1.138  
   1.139      // Support for resetting final fields while deserializing
   1.140 -    private static final long rtypeOffset, ptypesOffset;
   1.141 -    static {
   1.142 -        try {
   1.143 -            rtypeOffset = UNSAFE.objectFieldOffset
   1.144 -                (MethodType.class.getDeclaredField("rtype"));
   1.145 -            ptypesOffset = UNSAFE.objectFieldOffset
   1.146 -                (MethodType.class.getDeclaredField("ptypes"));
   1.147 -        } catch (Exception ex) {
   1.148 -            throw new Error(ex);
   1.149 -        }
   1.150 -    }
   1.151 +//    private static final long rtypeOffset, ptypesOffset;
   1.152 +//    static {
   1.153 +//        try {
   1.154 +//            rtypeOffset = UNSAFE.objectFieldOffset
   1.155 +//                (MethodType.class.getDeclaredField("rtype"));
   1.156 +//            ptypesOffset = UNSAFE.objectFieldOffset
   1.157 +//                (MethodType.class.getDeclaredField("ptypes"));
   1.158 +//        } catch (Exception ex) {
   1.159 +//            throw new Error(ex);
   1.160 +//        }
   1.161 +//    }
   1.162  
   1.163      /**
   1.164       * Resolves and initializes a {@code MethodType} object