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

Numeric overflow of j.u.c.semaphore permits doesn't throw an exception

    Details

      Description

      The following core doesn't throw an Error as expected:

      import java.util.concurrent.Semaphore;

      public class PermitOverflow {

          public static void main(String[] args) throws Throwable {
              for (boolean fair : new boolean[] { true, false }) {
                  Semaphore sem = new Semaphore(Integer.MAX_VALUE - 1, fair);
                  if (sem.availablePermits() != Integer.MAX_VALUE - 1)
                      throw new RuntimeException();
                  try {
                      sem.release(2);
                  } catch (Error expected) {
                  }
      ...
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                kshiroko Kirill Shirokov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: