Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8275392

jdk.unsupported/sun.reflect.ReflectionFactory.readObjectNoDataForSerialization uses wrong signature

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      binary
    • Compatibility Risk:
      medium
    • Compatibility Risk Description:
      Hide
      Prior to the change, code that called this method would have always received null, regardless of the presence of the readObjectNoData method, due to the wrong parameter list used by the implementation. With the change, null is still returned if a readObjectNoData method is not present, otherwise a MethodHandle for the method is returned.

      Existing code that might have adhered to the erroneous specification and invoked the returned MethodHandle with an ObjectInputStream as parameter, will now be executed and throw java.lang.invoke.WrongMethodTypeException.
      Show
      Prior to the change, code that called this method would have always received null, regardless of the presence of the readObjectNoData method, due to the wrong parameter list used by the implementation. With the change, null is still returned if a readObjectNoData method is not present, otherwise a MethodHandle for the method is returned. Existing code that might have adhered to the erroneous specification and invoked the returned MethodHandle with an ObjectInputStream as parameter, will now be executed and throw java.lang.invoke.WrongMethodTypeException.
    • Interface Kind:
      Java API
    • Scope:
      JDK

      Description

      Summary

      Correct the method-level specification to align with the signature of the serialization method readObjectNoData,

      private void readObjectNoData() throws ObjectStreamException;

      Problem

      The method that returns the matching handle for readObjectNoData, sun.reflect.ReflectionFactory.readObjectNoDataForSerialization, assumes the erroneous signature readObjectNoData(ObjectInputStream) - note the superfluous parameter.

      Solution

      Update the specification of sun.reflect.ReflectionFactory.readObjectNoDataForSerialization to use the correct parameter list.

      Specification

      jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java

           /**
            * Returns a direct MethodHandle for the {@code readObjectNoData} method on
            * a Serializable class.
      -     * The first argument of {@link MethodHandle#invoke} is the serializable
      -     * object and the second argument is the {@code ObjectInputStream} passed to
      -     * {@code readObjectNoData}.
      +     * The only argument of {@link MethodHandle#invoke} is the serializable
      +     * object, which {@code readObjectNoData} is called on. No arguments are
      +     * passed to the {@code readObjectNoData} method.
            *
            * @param cl a Serializable class
            * @return  a direct MethodHandle for the {@code readObjectNoData} method
      public final MethodHandle readObjectForSerialization(Class<?> cl) {}

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jboes Julia Boes (Inactive)
              Reporter:
              webbuggrp Webbug Group
              Reviewed By:
              Daniel Fuchs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: