The following code should produce random numbers between 0..2^5-1:

import java.math.BigInteger;
import java.security.SecureRandom;

class RndTest {
   public static void main(String[] args) {
      SecureRandom rnd = new SecureRandom();
      for (int i = 0; i < 10; i++)
         System.out.print(new BigInteger(5,rnd) + " ");
   }
}

[EMAIL PROTECTED] junit]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.0.0 20050519 (Red Hat 4.0.0-8)
[EMAIL PROTECTED] src]$ java RndTest
0 31 12 21 21 16 8 24 15 20
[EMAIL PROTECTED] src]$ java RndTest
0 31 12 21 21 16 8 24 15 20
[EMAIL PROTECTED] src]$ java -Djava.security.egd=file:/dev/random RndTest
0 31 12 21 21 16 8 24 15 20


[EMAIL PROTECTED] ~]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.0.1 20050727 (Red Hat 4.0.1-5)

Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[EMAIL PROTECTED] ~]$ java RndTest
0 31 12 21 21 16 8 24 15 20
[EMAIL PROTECTED] ~]$ java RndTest
0 31 12 21 21 16 8 24 15 20 



In addition the following fails (one would expect an 8):
import java.math.BigInteger;
import java.security.SecureRandom;

public class BigIntTest {
   public static void main(String[] args) {
      System.out.println(BigInteger.probablePrime(8,new
SecureRandom()).bitLength());
   }
}

[EMAIL PROTECTED] junit]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.0.0 20050519 (Red Hat 4.0.0-8)
[EMAIL PROTECTED] ~]$ java BigIntTest
2
[EMAIL PROTECTED] ~]$ java BigIntTest
2



See also: http://forums.java.sun.com/thread.jspa?messageID=3960085


-- 
           Summary: Failure to produce random values.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: smythe70 at hotmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24642

Reply via email to