This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgcj/24642] New: Failure to produce random values.
- From: "smythe70 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Nov 2005 19:38:37 -0000
- Subject: [Bug libgcj/24642] New: Failure to produce random values.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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) + " ");
}
}
[ben@localhost junit]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.0.0 20050519 (Red Hat 4.0.0-8)
[ben@localhost src]$ java RndTest
0 31 12 21 21 16 8 24 15 20
[ben@localhost src]$ java RndTest
0 31 12 21 21 16 8 24 15 20
[ben@localhost src]$ java -Djava.security.egd=file:/dev/random RndTest
0 31 12 21 21 16 8 24 15 20
[brh@jupiter ~]$ 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.
[brh@jupiter ~]$ java RndTest
0 31 12 21 21 16 8 24 15 20
[brh@jupiter ~]$ 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());
}
}
[ben@localhost junit]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.0.0 20050519 (Red Hat 4.0.0-8)
[ben@localhost ~]$ java BigIntTest
2
[ben@localhost ~]$ 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