1 /* 2 * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 @bug 4098742 26 @summary Test biginteger modpow method 27 @author Michael McCloskey 28 @run main/othervm ModPowPowersof2 29 */ 30 31 package test.java.math.BigInteger; 32 33 import java.math.BigInteger; 34 import java.io.BufferedReader; 35 import java.io.InputStreamReader; 36 import java.io.File; 37 import java.io.IOException; 38 39 /** 40 * This class tests to see if using modPow on a power 41 * of two crashes the vm 42 * 43 */ 44 public class ModPowPowersof2 { 45 main(String args[])46 public static void main(String args[]) throws Exception { 47 // BEGIN Android-removed: Test fails on Android. 48 // java.io.IOException: Cannot run program "<path-to-art>/bin/java": error=2, No such file or directory 49 /* 50 // Construct a command that runs the test in other vm 51 String[] command = new String[4]; 52 int n = 0; 53 54 command[n++] = System.getProperty("java.home") + File.separator + 55 "bin" + File.separator + "java"; 56 if (System.getProperty("java.class.path") != null) { 57 command[n++] = "-classpath"; 58 command[n++] = System.getProperty("java.class.path"); 59 } 60 61 command[n++] = "ModPowPowersof2$ModTester"; 62 63 // Exec another vm to run test in 64 Process p = null; 65 p = Runtime.getRuntime().exec(command); 66 67 // Read the result to determine if test failed 68 BufferedReader in = new BufferedReader(new InputStreamReader( 69 p.getInputStream())); 70 String s; 71 s = in.readLine(); 72 if (s == null) 73 throw new RuntimeException("ModPow causes vm crash"); 74 */ 75 // Android-removed Test fails on Android. 76 } 77 78 // BEGIN Android-removed: Test fails on Android. 79 // java.io.IOException: Cannot run program "<path-to-art>/bin/java": error=2, No such file or directory 80 /* 81 public static class ModTester { 82 public static void main(String [] args) { 83 BigInteger two = BigInteger.valueOf(2); 84 BigInteger four = BigInteger.valueOf(4); 85 86 two.modPow(two, BigInteger.valueOf(4)); 87 two.modPow(two, BigInteger.valueOf(8)); 88 two.modPow(four, BigInteger.valueOf(8)); 89 90 System.out.println("success"); 91 } 92 } 93 */ 94 // Android-removed Test fails on Android. 95 96 } 97