-
Bug
-
Resolution: Fixed
-
P3
-
1.1.1
-
1.1.1
-
sparc
-
solaris_2.5.1
-
Verified
allan.jacobs@Eng 1997-04-04
The JCK-111a BigInteger tests
api/java_math/BigInteger/EquivClass.html#BigInteger0061
api/java_math/BigInteger/EquivClass.html#BigInteger0063
api/java_math/BigInteger/EquivClass.html#BigInteger0065
api/java_math/BigInteger/EquivClass.html#BigInteger0067
are failing when JIT'ed on sparc. The JDK is jvm111_14 native
threads.
algol% javac BitwiseTests.java
algol% java -Djava.compiler=none BitwiseTests -TestCaseID BigInteger0061
STATUS:Passed. OKAY
algol% java -Djava.compiler=none BitwiseTests -TestCaseID BigInteger0063
STATUS:Passed. OKAY
algol% java -Djava.compiler=none BitwiseTests -TestCaseID BigInteger0065
STATUS:Passed. OKAY
algol% java -Djava.compiler=none BitwiseTests -TestCaseID BigInteger0067
STATUS:Passed. OKAY
algol% java -Djava.compiler=sunwjit BitwiseTests -TestCaseID BigInteger0061
STATUS:Failed. Unexpected java.lang.ArrayIndexOutOfBoundsException: 87( 87 )
algol% java -Djava.compiler=sunwjit BitwiseTests -TestCaseID BigInteger0063
STATUS:Failed. Unexpected java.lang.ArrayIndexOutOfBoundsException: 20( 20 )
algol% java -Djava.compiler=sunwjit BitwiseTests -TestCaseID BigInteger0065
STATUS:Failed. Unexpected java.lang.ArrayIndexOutOfBoundsException: 33( 33 )
algol% java -Djava.compiler=sunwjit BitwiseTests -TestCaseID BigInteger0067
STATUS:Failed. Unexpected java.lang.ArrayIndexOutOfBoundsException: 71( 71 )
algol% echo $CLASSPATH
.:/net/mulder/export/mulder3/JCK-111a/classes
algol% cat BitwiseTests.java
/* *****************************************************
* @(#)BitwiseTests.java 1.2 02/28/97 14:03:49
* @author Michael A. Gorshenev
* BigInteger and, or, xor, not, andNot tests
* Testing BigInteger and, or, xor, not, andNot methods
* ***************************************************** */
//package javasoft.sqe.tests.api.java.math.BigInteger;
import java.io.PrintStream;
import javasoft.sqe.harness.Test;
import javasoft.sqe.harness.Status;
import java.math.*;
public class BitwiseTests implements Test {
private PrintStream log, out;
private String testCaseID = "",
workdir="",
testdir="";
final int MAX_LENGTH=255;
final int MAX_SIZE=15;
final int MIN_SIZE=5;
public BigInteger[] randomArray(int maxSize) {
String s[]=randomStringArray(maxSize);
BigInteger[] ar=new BigInteger[s.length];
for (int i=0; i<s.length; i++)
ar[i]=new BigInteger(s[i]);
return ar;
}
public BigInteger[] randomArray() {
return randomArray(MAX_SIZE);
}
public String[] randomStringArray(int maxSize) {
int seed=(new Integer(testCaseID.substring(testCaseID.length()-4))).intValue();
java.util.Random r= new java.util.Random(seed);
// int size=Math.abs(r.nextInt())%maxSize+1+MIN_SIZE;
int size=maxSize+1+MIN_SIZE;
int length;
String s;
String[] ar=new String[size];
for (int i=MIN_SIZE; i<size; i++) {
length=Math.abs(r.nextInt())%MAX_LENGTH+1;
s="";
for (int j=0; j<length; j++)
s+=(0+(char)(Math.abs(r.nextInt()%10)));
if (r.nextInt()<0)
s="-"+s;
ar[i]=s;
}
ar[0]="0";
ar[1]="1";
ar[2]="-1";
ar[3]="2";
ar[4]="-2";
return ar;
}
public String[] randomStringArray() {
return randomStringArray(MAX_SIZE);
}
public BigInteger testAnd(BigInteger d1, BigInteger d2) {
byte[] d1Ar=d1.toByteArray();
byte[] d2Ar=d2.toByteArray();
byte[] result;
if (d1Ar.length<d2Ar.length)
result = d2Ar;
else
result = d1Ar;
for (int i=1; i<Math.min(d1Ar.length,d2Ar.length)+1; i++)
result[result.length-i] = (byte) (d1Ar[d1Ar.length-i] & d2Ar[d2Ar.length-i]) ;
if (d1Ar.length<d2Ar.length?d1.signum()>=0:d2.signum()>=0)
for (int i=Math.min(d1Ar.length,d2Ar.length)+1; i<result.length+1; i++)
result[result.length-i] = 0;
return new BigInteger(result);
}
public BigInteger testOr(BigInteger d1, BigInteger d2) {
byte[] d1Ar=d1.toByteArray();
byte[] d2Ar=d2.toByteArray();
byte[] result;
if (d1Ar.length<d2Ar.length)
result = d2Ar;
else
result = d1Ar;
for (int i=1; i<Math.min(d1Ar.length,d2Ar.length)+1; i++)
result[result.length-i] = (byte) (d1Ar[d1Ar.length-i] | d2Ar[d2Ar.length-i]) ;
if (d1Ar.length<d2Ar.length?d1.signum()<0:d2.signum()<0)
for (int i=Math.min(d1Ar.length,d2Ar.length)+1; i<result.length+1; i++)
result[result.length-i] = (byte)0xff;
return new BigInteger(result);
}
public BigInteger testXor(BigInteger d1, BigInteger d2) {
byte[] d1Ar=d1.toByteArray();
byte[] d2Ar=d2.toByteArray();
byte[] result;
int hiByte;
if (d1Ar.length<d2Ar.length)
result = d2Ar;
else
result = d1Ar;
for (int i=1; i<Math.min(d1Ar.length,d2Ar.length)+1; i++)
result[result.length-i] = (byte) (d1Ar[d1Ar.length-i] ^ d2Ar[d2Ar.length-i]) ;
if (d1Ar.length<d2Ar.length?d1.signum()<0:d2.signum()<0)
hiByte=0xff;
else
hiByte=0;
for (int i=Math.min(d1Ar.length,d2Ar.length)+1; i<result.length+1; i++)
result[result.length-i] = (byte) (hiByte ^ result[result.length-i]) ;
return new BigInteger(result);
}
public BigInteger testAndNot(BigInteger d1, BigInteger d2) {
byte[] d1Ar=d1.toByteArray();
byte[] d2Ar=d2.toByteArray();
byte[] result;
int hiByte;
if (d1Ar.length<d2Ar.length)
result = d2Ar;
else
result = d1Ar;
for (int i=1; i<Math.min(d1Ar.length,d2Ar.length)+1; i++)
result[result.length-i] = (byte) (d1Ar[d1Ar.length-i] &~ d2Ar[d2Ar.length-i]) ;
if (d1Ar.length<d2Ar.length?d1.signum()<0:d2.signum()<0)
hiByte=0xff;
else
hiByte=0;
for (int i=Math.min(d1Ar.length,d2Ar.length)+1; i<result.length+1; i++)
if (d1Ar.length<d2Ar.length)
result[result.length-i] = (byte) (hiByte &~ result[result.length-i]) ;
else
result[result.length-i] = (byte) (result[result.length-i] &~ hiByte) ;
return new BigInteger(result);
}
public BigInteger testNot(BigInteger d1) {
byte[] d1Ar=d1.toByteArray();
byte[] result;
for (int i=0; i<d1Ar.length; i++)
d1Ar[i] = (byte) (~d1Ar[i]) ;
return new BigInteger(d1Ar);
}
/* standalone interface */
public static void main( String argv[] ) {
BitwiseTests test = new BitwiseTests();
Status status = test.run( argv, System.err, System.out );
status.exit();
}
/* test interface */
public Status run( String argv[], PrintStream log, PrintStream out ) {
/* assign log and out streams, and other variables */
Status status = Status.notApplicable( "Could not complete test setup." );
this.out = out;
this.log = log;
int i;
/* Parse test execute arguments */
for( i = 0; i < argv.length - 1; ++i ) {
if( argv[i].equals( "-TestCaseID" ) )
if (argv[++i].charAt(0) != '-') // next parameter is not option
testCaseID = argv[i];
else --i; // step back otherwise
else if (argv[i].equals("-WorkDir"))
if (argv[++i].charAt(0) != '-') // next parameter is not option
workdir = argv[i];
else --i; // step back otherwise
else if (argv[i].equals("-Test"))
if (argv[++i].charAt(0) != '-') // next parameter is not option
testdir = (argv[i]).substring(0,(argv[i]).lastIndexOf
(System.getProperty("file.separator"))+1);
else --i; // step back otherwise
}
/* Put all tests into a try ... catch block */
try {
if( testCaseID.equals("BigInteger0060") )
status = BigInteger0060( );
else
if( testCaseID.equals("BigInteger0061") )
status = BigInteger0061( );
else
if( testCaseID.equals("BigInteger0062") )
status = BigInteger0062( );
else
if( testCaseID.equals("BigInteger0063") )
status = BigInteger0063( );
else
if( testCaseID.equals("BigInteger0064") )
status = BigInteger0064( );
else
if( testCaseID.equals("BigInteger0065") )
status = BigInteger0065( );
else
if( testCaseID.equals("BigInteger0066") )
status = BigInteger0066( );
else
if( testCaseID.equals("BigInteger0067") )
status = BigInteger0067( );
else
if( testCaseID.equals("BigInteger0068") )
status = BigInteger0068( );
else
{ if( (testCaseID == null) || ( testCaseID.equals("") ) )
testCaseID = "-TestCaseID not supplied";
status = Status.failed( "Could not find test: " + testCaseID );
}
} // end try for all tests
catch( Throwable e ) {
status = Status.failed("Unexpected " + e + "( " + e.getMessage() +" )" );
}
// End of test
return status;
}
/* Equivalence class partitioning
with input values orientation
for method and(BigInteger d),
d:: null.
*/
Status BigInteger0060() {
BigInteger b1=BigInteger.valueOf(117); //step Create a BigInteger
out.println("b1="+b1);
BigInteger b2=null; //step Create a null reference
try {
BigInteger b3=b1.and(b2); //step Try to call method
out.println("b1&null="+b3);
return Status.failed("failed");
}
catch (NullPointerException e) {
out.println(e);
}
return Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with input values orientation
for method and(BigInteger d),
d:: BigInteger.
*/
Status BigInteger0061() {
BigInteger[] b1=randomArray(10); //step Create an array
boolean failed=false;
for (int i=0; i<b1.length; i++)
for (int k=0; k<b1.length; k++) {
BigInteger result=b1[i].and(b1[k]); //step Call method
BigInteger expected=testAnd(b1[i],b1[k]); //step Create expected result
if (!(result.equals(expected))) //step Check
{ failed=true;
out.println("failed: ");
out.println("b1= "+b1[i]);
out.println("b2= "+b1[k]);
out.println("result= "+result);
out.println("expected= "+expected);
}
}
return failed ? Status.failed("failed") : Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with input values orientation
for method or(BigInteger d),
d:: null.
*/
Status BigInteger0062() {
BigInteger b1=BigInteger.valueOf(117); //step Create a BigInteger
out.println("b1="+b1);
BigInteger b2=null; //step Create a null reference
try {
BigInteger b3=b1.or(b2); //step Try to call method
out.println("b1|null="+b3);
return Status.failed("failed");
}
catch (NullPointerException e) {
out.println(e);
}
return Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with input values orientation
for method or(BigInteger d),
d:: BigInteger.
*/
Status BigInteger0063() {
BigInteger[] b1=randomArray(10); //step Create an array
boolean failed=false;
for (int i=0; i<b1.length; i++)
for (int k=0; k<b1.length; k++) {
BigInteger result=b1[i].or(b1[k]); //step Call method
BigInteger expected=testOr(b1[i],b1[k]); //step Create expected result
if (!(result.equals(expected))) //step Check
{ failed=true;
out.println("failed: ");
out.println("b1= "+b1[i]);
out.println("b2= "+b1[k]);
out.println("result= "+result);
out.println("expected= "+expected);
}
}
return failed ? Status.failed("failed") : Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with input values orientation
for method xor(BigInteger d),
d:: null.
*/
Status BigInteger0064() {
BigInteger b1=BigInteger.valueOf(117); //step Create a BigInteger
out.println("b1="+b1);
BigInteger b2=null; //step Create a null reference
try {
BigInteger b3=b1.xor(b2); //step Try to call method
out.println("b1^null="+b3);
return Status.failed("failed");
}
catch (NullPointerException e) {
out.println(e);
}
return Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with input values orientation
for method xor(BigInteger d),
d:: BigInteger.
*/
Status BigInteger0065() {
BigInteger[] b1=randomArray(10); //step Create an array
boolean failed=false;
for (int i=0; i<b1.length; i++)
for (int k=0; k<b1.length; k++) {
BigInteger result=b1[i].xor(b1[k]); //step Call method
BigInteger expected=testXor(b1[i],b1[k]); //step Create expected result
if (!(result.equals(expected))) //step Check
{ failed=true;
out.println("failed: ");
out.println("b1= "+b1[i]);
out.println("b2= "+b1[k]);
out.println("result= "+result);
out.println("expected= "+expected);
}
}
return failed ? Status.failed("failed") : Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with input values orientation
for method andNot(BigInteger d),
d:: null.
*/
Status BigInteger0066() {
BigInteger b1=BigInteger.valueOf(117); //step Create a BigInteger
out.println("b1="+b1);
BigInteger b2=null; //step Create a null reference
try {
BigInteger b3=b1.andNot(b2); //step Try to call method
out.println("b1.andNot(null)="+b3);
return Status.failed("failed");
}
catch (NullPointerException e) {
out.println(e);
}
return Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with input values orientation
for method andNot(BigInteger d),
d:: BigInteger.
*/
Status BigInteger0067() {
BigInteger[] b1=randomArray(10); //step Create an array
boolean failed=false;
for (int i=0; i<b1.length; i++)
for (int k=0; k<b1.length; k++) {
BigInteger result=b1[i].andNot(b1[k]); //step Call method
BigInteger expected=testAndNot(b1[i],b1[k]); //step Create expected result
if (!(result.equals(expected))) //step Check
{ failed=true;
out.println("failed: ");
out.println("b1= "+b1[i]);
out.println("b2= "+b1[k]);
out.println("result= "+result);
out.println("expected= "+expected);
}
}
return failed ? Status.failed("failed") : Status.passed( "OKAY" );
}
/* Equivalence class partitioning
with output values orientation
for method not(),
output:: BigInteger.
*/
Status BigInteger0068() {
BigInteger[] b1=randomArray(10); //step Create an array
boolean failed=false;
for (int i=0; i<b1.length; i++) {
BigInteger result=b1[i].not(); //step Call method
BigInteger expected=testNot(b1[i]); //step Create expected result
if (!(result.equals(expected))) //step Check
{ failed=true;
out.println("failed: ");
out.println("b1= "+b1[i]);
out.println("result= "+result);
out.println("expected= "+expected);
}
}
return failed ? Status.failed("failed") : Status.passed( "OKAY" );
}
}
allan.jacobs@Eng 1997-04-10
This bug can be reproduced using green threads, too.
- relates to
-
JDK-4051340 Dynamic link errors occur on a large number of JCK-111a tests.
-
- Closed
-