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

AsVarargsCollector::asCollectorCache incorrectly marked @Stable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 19
    • 19
    • core-libs
    • None

      The AsVarargsCollector::asCollectorCache field is marked as `@Stable` but doesn't follow the contract for Stable fields.

      The contract for Stable, as described in [1], states:
      > A field may be annotated as stable if all of its component variables
      > changes value at most once.
      ...
      > Since all fields begin with a default value of null for references
      > (resp., zero for primitives), it follows that this annotation indicates
      > that the first non-null (resp., non-zero) value stored in the field
      > will never be changed.

      The AsVarargsCollector::asTypeUncached method updates the `asCollectorCache` field.

      This was discovered by the OpenJ9 project while investigating a test issue in the CatchExceptionTest.java [2] test case related to the `getCatcher` method.

      [1] https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
      [2] https://github.com/openjdk/jdk/blob/master/test/jdk/java/lang/invoke/MethodHandles/CatchExceptionTest.java

            heidinga Dan Heidinga
            heidinga Dan Heidinga
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: