c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This code is free software; you can redistribute it and/or modify it
c869993e79c1eafbec61a56bf6cea848fe754c71xy * under the terms of the GNU General Public License version 2 only, as
c869993e79c1eafbec61a56bf6cea848fe754c71xy * published by the Free Software Foundation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * This code is distributed in the hope that it will be useful, but WITHOUT
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c869993e79c1eafbec61a56bf6cea848fe754c71xy * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c869993e79c1eafbec61a56bf6cea848fe754c71xy * version 2 for more details (a copy is included in the LICENSE file that
c869993e79c1eafbec61a56bf6cea848fe754c71xy * accompanied this code).
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China *
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * You should have received a copy of the GNU General Public License version
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * 2 along with this work; if not, write to the Free Software Foundation,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c869993e79c1eafbec61a56bf6cea848fe754c71xy * or visit www.oracle.com if you need additional information or have any
c869993e79c1eafbec61a56bf6cea848fe754c71xy * questions.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy/**
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * @test
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China * @bug 4187412
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * @summary The FCS release of 1.2 did not special case the Random.nextInt
c869993e79c1eafbec61a56bf6cea848fe754c71xy * calculation for a power of two modulus, as mandated by the spec.
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyimport java.util.Random;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
fa25784ca4b51c206177d891a654f1d36a25d41fxypublic class NextIntPowerOfTwoMod {
c869993e79c1eafbec61a56bf6cea848fe754c71xy public static void main(String[] args) throws Exception {
c869993e79c1eafbec61a56bf6cea848fe754c71xy Random r = new Random(69);
c869993e79c1eafbec61a56bf6cea848fe754c71xy int total = 0;
c869993e79c1eafbec61a56bf6cea848fe754c71xy for (int i=0; i<1000; i++)
c869993e79c1eafbec61a56bf6cea848fe754c71xy total += r.nextInt(16);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (total != 7639)
c869993e79c1eafbec61a56bf6cea848fe754c71xy throw new RuntimeException("Not using correct algorithm.");
c869993e79c1eafbec61a56bf6cea848fe754c71xy }
c869993e79c1eafbec61a56bf6cea848fe754c71xy}
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng