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

(spec) Precisely specify bytes generated by Random.nextBytes

XMLWordPrintable

    • b61
    • generic
    • generic

      Name: rlT66838 Date: 08/09/99


      java.util.Random.nextBytes() stuffs bytes into an array by
      grabbing random integers, then breaking the integers into
      respective bytes and placing each into the array four at
      a time. This comes form being too clever :-)

      This is a BIG RANDOM NUMBER GENERATOR NO-NO.
      One of the canonical rules of random number generators is
      Thou Shalt Never Split A Random Number Into N Pieces And
      Use Each One Independently. This places far too much
      faith in the n-dimensional correctness of the Knuth
      generator. See Numerical Recipies in C for more discussion
      on why this is a really really bad idea.

      I discovered this bug while doing testing for a replacement
      random number generator based on the Mersenne Twister (a FAR
      superior random number generator than the Knuth one the JDK is
      using, and faster too -- if you want it let me know).


      (Review ID: 93712)
      ======================================================================

            martin Martin Buchholz
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: