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

CountDownLatch.getCount returns "long" but constructor only accepts "int"

    Details

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      In the class java.util.concurrent.CountDownLatch constructor has type "int".

      public CountDownLatch(int count);

      After construction, counter can only decreasing, but method getCount returns long value.

      public long getCount()

      REPRODUCIBILITY :
      This bug can be reproduced always.

      SUPPORT :
      YES

        Activity

        Hide
        psonal Pallavi Sonal added a comment -
        Verified that CountdownLatch constructor takes an int for the count and returns a long when retrieving the count value.
        public CountDownLatch(int count)
        public long getCount()

        The issue exists in JDK 8 as well as JDK 9ea.
        https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#getCount--
        Show
        psonal Pallavi Sonal added a comment - Verified that CountdownLatch constructor takes an int for the count and returns a long when retrieving the count value. public CountDownLatch(int count) public long getCount() The issue exists in JDK 8 as well as JDK 9ea. https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#getCount--
        Hide
        martin Martin Buchholz added a comment -
        Interesting. Looks like planning for a 64-bit future from an era where 64-bit atomics were not ubiquitous. Could a constructor taking a long be provided someday, or even today in a subclass?
        Show
        martin Martin Buchholz added a comment - Interesting. Looks like planning for a 64-bit future from an era where 64-bit atomics were not ubiquitous. Could a constructor taking a long be provided someday, or even today in a subclass?
        Hide
        dl Doug Lea added a comment -
        My recollection (from jdk5) was that getCount was declared as long to conform to a never-shipped monitoring interface. It can't be compatibly changed now, and there's no reason beyond odd-looking-ness to do so.
        Show
        dl Doug Lea added a comment - My recollection (from jdk5) was that getCount was declared as long to conform to a never-shipped monitoring interface. It can't be compatibly changed now, and there's no reason beyond odd-looking-ness to do so.
        Hide
        martin Martin Buchholz added a comment -
        We are in any case in the era where we are starting to regret use of int instead of long in API signatures. Someday we may add a CountDownLatch(long) constructor.
        Show
        martin Martin Buchholz added a comment - We are in any case in the era where we are starting to regret use of int instead of long in API signatures. Someday we may add a CountDownLatch(long) constructor.

          People

          • Assignee:
            martin Martin Buchholz
            Reporter:
            webbuggrp Webbug Group
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: