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

RandomGenerator:NextDouble() default behavior non conformant after JDK-8280550 fix

    XMLWordPrintable

Details

    • b08
    • Verified

    Backports

      Description

        The following test quoted below that validates the spec
        https://download.java.net/java/early_access/jdk19/docs/api/java.base/java/util/random/RandomGenerator.html#nextDouble(double)

        > "Implementation Requirements:
        > The default implementation checks that bound is a positive finite double. Then invokes nextDouble(), scaling the result so that the final result lies between 0.0 (inclusive) and bound (exclusive)."

        fails with JDK 19-pre08 bundles.

        This is the test which is supplying the positive finite double and expecting the results as specified :

        =============
                RandomGenerator rg = new RandomGenerator() {
                    @Override
                    public double nextDouble() {
                        return 123456789.34d;
                    }

                    @Override
                    public long nextLong() {
                        return 0;
                    }
                };
                double value = rg.nextDouble(bound); // the "bound" used by the specific test could be any value from the list of {Double.MIN_VALUE, 10.0, 1234455555.45, 10000000d}
                Assert.assertTrue(value >= 0);
                Assert.assertTrue(value < bound); // fails here
        ==========

        Attachments

          Issue Links

            Activity

              People

                darcy Joe Darcy
                kganapureddy Krushnareddy Ganapureddy
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: