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

(ref) Exceptions while processing Reference pending list

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      The java.lang.ref.Reference class has a private Lock class and static lock instance of that class. It is documented as providing synchronization with the garbage collector, with a warning that one must not allocate any new objects while holding this lock.

      The Reference class has a tryHandlePending member function containing a synchronized block on that lock object.

      Within that synchronized block is a comment indicating some of the code therein is written in a particular way because the instanceof operator might throw OutOfMemoryError. That would seem to imply that instanceof can allocate new objects, which is contrary to the requirement on holders of the lock object.

      The Reference class also contains a static initialization to ensure the relevant class for that instanceof (java.lang.misc.Cleaner) has been loaded, with the apparent intent of ensuring that instanceof does *not* need to allocate memory. But if that's so, then it would seem that any code contortions to account for that possibility are unnecessary.

      I'm not sure whether there is a bug in the code or not. At the very least, there are problems with the comments.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kbarrett Kim Barrett
                Reporter:
                kbarrett Kim Barrett
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: