Пример #1
0
 private void MethodType_init(Class<?> rtype, Class<?>[] ptypes) {
   // In order to communicate these values to readResolve, we must
   // store them into the implementation-specific final fields.
   checkRtype(rtype);
   checkPtypes(ptypes);
   unsafe.putObject(this, rtypeOffset, rtype);
   unsafe.putObject(this, ptypesOffset, ptypes);
 }
Пример #2
0
  /**
   * Reconstitute the {@code MethodType} instance from a stream (that is, deserialize it). This
   * instance is a scratch object with bogus final fields. It provides the parameters to the factory
   * method called by {@link #readResolve readResolve}. After that call it is discarded.
   *
   * @param the stream to read the object from
   * @see #MethodType()
   * @see #readResolve
   * @see #writeObject
   */
  private void readObject(java.io.ObjectInputStream s)
      throws java.io.IOException, ClassNotFoundException {
    s.defaultReadObject(); // requires serialPersistentFields to be an empty array

    Class<?> returnType = (Class<?>) s.readObject();
    Class<?>[] parameterArray = (Class<?>[]) s.readObject();

    // Probably this object will never escape, but let's check
    // the field values now, just to be sure.
    checkRtype(returnType);
    checkPtypes(parameterArray);

    parameterArray = parameterArray.clone(); // make sure it is unshared
    MethodType_init(returnType, parameterArray);
  }
Пример #3
0
 /** Check the given parameters for validity and store them into the final fields. */
 private MethodType(Class<?> rtype, Class<?>[] ptypes) {
   checkRtype(rtype);
   checkPtypes(ptypes);
   this.rtype = rtype;
   this.ptypes = ptypes;
 }