without jit it generates the desired output.
attached are scalarsignature.java testing.java files.
[5/17 sadhana]
:::::::::::::
hydra_diff_output
::::::::::::::
3a4,15
> Failure: INT1 VALUE AT m( int ) yields 0
> expected 1
> Failure: INT1 VALUE AT m( int ) yields 0
> expected 1
> Failure: INT1 VALUE AT m( int, float ) first parameter yiel
ds -2147483648
> expected 1
> Failure: INT1 VALUE AT m( float, int) second parameter yiel
ds -2147483648
> expected 1
> Failure: INT1 VALUE AT m( int, int) first parameter yields
-2147483648
> expected 1
> Failure: INT1 VALUE AT m( int, int) second parameter yields
-2147483648
> expected 1
6a19,22
> Failure: FLOAT VALUE AT m( float, int) first parameter yiel
ds 0.25
> expected 4
> Failure: FLOAT VALUE AT m( int, float ) second parameter yi
elds 0.25
> expected 4
8c24
< Overloading member function with scalar signatures: 65 passed, 0
failed
---
> Overloading member function with scalar signatures: 57 passed, 8
failed
$ m *tlog
##### ScalarSignature java_run.sh
hydra_javac.sh
f:/jdk1.0.2_jit/build/win32/bin/javac_g scalarsignature.java
testing.java > ScalarSignature.javac.out 2>&1
f:/jdk1.0.2_jit/build/win32/bin/jitc_g -xarch=x86 scalarsignature
.class
testing.class > ScalarSignature.jitc.out 2 >& 1
hydra_resolve
f:/jdk1.0.2_jit/build/win32/bin/java_g -Djava.compiler=JIT Scala
rSignature >> ScalarSignature.java.out 2>&1
Const members
Local variables
Cast variables
Failure: INT1 VALUE AT m( int ) yields 0
expected 1
Failure: INT1 VALUE AT m( int ) yields 0
expected 1
Failure: INT1 VALUE AT m( int, float ) first parameter yiel
ds -2147483648
expected 1
Failure: INT1 VALUE AT m( float, int) second parameter yiel
ds -2147483648
expected 1
Failure: INT1 VALUE AT m( int, int) first parameter yields
-2147483648
expected 1
Failure: INT1 VALUE AT m( int, int) second parameter yields
-2147483648
expected 1
Array elements
Arrays
Expressions
Failure: FLOAT VALUE AT m( float, int) first parameter yiel
ds 0.25
expected 4
Failure: FLOAT VALUE AT m( int, float ) second parameter yi
elds 0.25
expected 4
Overloading member function with scalar signatures: 57 passed, 8 failed
hydra_resolve
$ more scalarsignature.java
/*
* @(#)ScalarSignature.java 1.4 95/01/31
*
* Simple overloading test, using scalars and arrays of scalars.
* The member function "m" is obscenely overloaded. Make sure the
* right "m" gets called using a variety of arguments.
*
* Some tests are currently commented out, due to known compiler b
rokenness.
* The nskipped variable is incremented by the number of arguments
for each
* of these cases. When the compiler works, these tests should be
un-commented
* and the incrementing of nkipped deleted.
*/
class ScalarSignature {
/*
* A variable passed as parameters will be self-identifying:
* its value will be a type code.
*/
static final int INT = 1;
static final byte BYTE = 2;
static final char CHAR = 3;
static final float FLOAT = 4;
testing t = new testing();
int nskipped = 0;
void checkAnyIntValue( int v, String legend ){
switch( v ){
case INT:
case BYTE:
case CHAR:
// succeed
t.isit(" INT VALUE AT "+legend, v, v);
return;
}
// fail
t.isit(" INT1 VALUE AT "+legend, v, INT);
}
void checkIntValue( int v, String legend ){
t.isit(" INT2 VALUE AT "+legend, v, INT);
}
void checkByteValue( int v, String legend ){
t.isit(" BYTE VALUE AT "+legend, v, BYTE);
}
void checkCharValue( int v, String legend ){
t.isit(" CHAR VALUE AT "+legend, v, CHAR);
}
void checkFloatValue( float v, String legend ){
t.isit(" FLOAT VALUE AT "+legend, v, FLOAT);
}
/*
* The overloaded member function.
*/
void m( int v ){
checkAnyIntValue( v, "m( int )" );
}
/*
* The compiler does not seem to distinguish between int
* and small-int when resolving. This is a reported "bug".
* But, like C, Java promotes all integers to int for expressi
on
* evaluation, so this may not even be a bug!
*
* static void m( byte v ){
* System.out.println(" byte of value "+v);
* }
*
* static void m( char v ){
* System.out.println(" char of value "+v);
* }
* }
*
*/
void m( float v ){
checkFloatValue( v, "m( float )" );
}
void m( int v, int u ){
checkAnyIntValue( v, "m( int, int) first parameter" );
checkAnyIntValue( u, "m( int, int) second parameter" );
}
void m( float v, float u ){
checkFloatValue( v, "m( float, float ) first parameter" );
checkFloatValue( u, "m( float, float ) second parameter" )
;
}
void m( int v, float u ){
checkAnyIntValue( v, "m( int, float ) first parameter" );
checkFloatValue( u, "m( int, float ) second parameter" );
}
void m( float v, int u ){
checkFloatValue( v, "m( float, int) first parameter" );
checkAnyIntValue( u, "m( float, int) second parameter" );
}
void m( int v[] ){
checkIntValue( v[0], "m( int v[] )");
}
void m( byte v[] ){
checkByteValue( v[0], "m( byte v[] )");
}
void m( char v[] ){
checkCharValue( v[0], "m( char v[] )");
}
void m( float v[] ){
checkFloatValue( v[0], "m( float v[] )");
}
/*
* Calls to the overloaded member function.
*/
void callWithConstMembers(){
System.out.println("Const members");
m( INT );
m( BYTE );
m( CHAR );
m( FLOAT );
m( INT, INT); //Compiler was broken
//nskipped+=2;
m( FLOAT, INT);
m( INT, FLOAT);
m( FLOAT, FLOAT); //Compiler was broken
//nskipped+=2;
}
void callWithLocalScalars(){
int i = INT;
byte b = BYTE;
char c = CHAR;
float f = FLOAT;
System.out.println("Local variables");
m( i );
m( b );
m( c );
m( f );
m( i, i); //Compiler was broken
//nskipped+=2;
m( f, i);
m( i, f);
m( f, f); //Compiler was broken
//nskipped+=2;
}
void callWithArrayElements(){
int i[] = { INT };
byte b[] = { BYTE };
char c[] = { CHAR };
float f[] = { FLOAT };
System.out.println("Array elements");
m( i[0] );
m( b[0] );
m( c[0] );
m( f[0] );
m( i[0], i[0]); //Compiler was broken
//nskipped+=2;
m( f[0], i[0]);
m( i[0], f[0]);
m( f[0], f[0]); //Compiler was broken
//nskipped+=2;
}
void callWithCastScalars(){
int i = INT;
int j = (int)FLOAT;
float f = FLOAT;
float g = (float)INT;
System.out.println("Cast variables");
m( (byte)i );
m( (char)i );
m( (float)j );
m( (int)g );
m( (byte)g );
m( (char)g );
m( (float)j, (float)j); //Compiler was broken
//nskipped+=2;
m( (int)g, (float)j);
m( (float)j, (int)g);
m( (int)g, (int)g); //Compiler was broken
//nskipped+=2;
}
void callWithArrays(){
int i[] = { INT };
byte b[] = { BYTE };
char c[] = { CHAR };
float f[] = { FLOAT };
System.out.println("Arrays");
m( i );
m( b );
m( c );
m( f );
}
void callWithExpressions(){
int i = INT;
float f = FLOAT;
float g = (float)2.0;
System.out.println("Expressions");
m( i/i );
m( i*f );
m( f*g-f );
m( f/i, i+i);
m( i+i, f/i);
m( f+f-2*g, i*f); // COMPILER was BROKEN
//nskipped+=2;
m( i*f, 2*f/g); // COMPILER was BROKEN
//nskipped+=2;
}
public static void main( String x[] ){
ScalarSignature S = new ScalarSignature();
S.callWithConstMembers();
S.callWithLocalScalars();
S.callWithCastScalars();
S.callWithArrayElements();
S.callWithArrays();
S.callWithExpressions();
S.t.summary("Overloading member function with scalar signa
tures");
if (S.nskipped!=0){
System.out.println(" and "+S.nskipped+"
skipped due to known compiler bugs");
}
}
}
$ more testing.java
/*
* @(#)testing.java 1.3 95/01/31
* class used for counting up test successes and failures
*/
import java.lang.Thread;
public class testing{
public int success;
public int failure;
public
testing()
{
success = 0;
failure = 0;
}
public void
isit( String testexpression, boolean actual, boolean expected
)
{
if ( actual == expected ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual?"true":"false" );
failure++;
}
}
public void
isit( String testexpression, int actual, int expected )
{
if ( actual == expected ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
isit( String testexpression, float actual, float expected )
{
if ( actual == expected ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
isit( String testexpression, String actual, String expected )
{
if ( actual.equals( expected ) ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
isit( String testexpression, String actual, String expected )
{
if ( actual.equals( expected ) ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
summary( String legend )
{
System.out.println("");
System.out.print( legend );
System.out.print( ": " );
System.out.print( success );
System.out.print( " passed, " );
System.out.print( failure );
System.out.println( " failed\\n" );
}
};
attached are scalarsignature.java testing.java files.
[5/17 sadhana]
:::::::::::::
hydra_diff_output
::::::::::::::
3a4,15
> Failure: INT1 VALUE AT m( int ) yields 0
> expected 1
> Failure: INT1 VALUE AT m( int ) yields 0
> expected 1
> Failure: INT1 VALUE AT m( int, float ) first parameter yiel
ds -2147483648
> expected 1
> Failure: INT1 VALUE AT m( float, int) second parameter yiel
ds -2147483648
> expected 1
> Failure: INT1 VALUE AT m( int, int) first parameter yields
-2147483648
> expected 1
> Failure: INT1 VALUE AT m( int, int) second parameter yields
-2147483648
> expected 1
6a19,22
> Failure: FLOAT VALUE AT m( float, int) first parameter yiel
ds 0.25
> expected 4
> Failure: FLOAT VALUE AT m( int, float ) second parameter yi
elds 0.25
> expected 4
8c24
< Overloading member function with scalar signatures: 65 passed, 0
failed
---
> Overloading member function with scalar signatures: 57 passed, 8
failed
$ m *tlog
##### ScalarSignature java_run.sh
hydra_javac.sh
f:/jdk1.0.2_jit/build/win32/bin/javac_g scalarsignature.java
testing.java > ScalarSignature.javac.out 2>&1
f:/jdk1.0.2_jit/build/win32/bin/jitc_g -xarch=x86 scalarsignature
.class
testing.class > ScalarSignature.jitc.out 2 >& 1
hydra_resolve
f:/jdk1.0.2_jit/build/win32/bin/java_g -Djava.compiler=JIT Scala
rSignature >> ScalarSignature.java.out 2>&1
Const members
Local variables
Cast variables
Failure: INT1 VALUE AT m( int ) yields 0
expected 1
Failure: INT1 VALUE AT m( int ) yields 0
expected 1
Failure: INT1 VALUE AT m( int, float ) first parameter yiel
ds -2147483648
expected 1
Failure: INT1 VALUE AT m( float, int) second parameter yiel
ds -2147483648
expected 1
Failure: INT1 VALUE AT m( int, int) first parameter yields
-2147483648
expected 1
Failure: INT1 VALUE AT m( int, int) second parameter yields
-2147483648
expected 1
Array elements
Arrays
Expressions
Failure: FLOAT VALUE AT m( float, int) first parameter yiel
ds 0.25
expected 4
Failure: FLOAT VALUE AT m( int, float ) second parameter yi
elds 0.25
expected 4
Overloading member function with scalar signatures: 57 passed, 8 failed
hydra_resolve
$ more scalarsignature.java
/*
* @(#)ScalarSignature.java 1.4 95/01/31
*
* Simple overloading test, using scalars and arrays of scalars.
* The member function "m" is obscenely overloaded. Make sure the
* right "m" gets called using a variety of arguments.
*
* Some tests are currently commented out, due to known compiler b
rokenness.
* The nskipped variable is incremented by the number of arguments
for each
* of these cases. When the compiler works, these tests should be
un-commented
* and the incrementing of nkipped deleted.
*/
class ScalarSignature {
/*
* A variable passed as parameters will be self-identifying:
* its value will be a type code.
*/
static final int INT = 1;
static final byte BYTE = 2;
static final char CHAR = 3;
static final float FLOAT = 4;
testing t = new testing();
int nskipped = 0;
void checkAnyIntValue( int v, String legend ){
switch( v ){
case INT:
case BYTE:
case CHAR:
// succeed
t.isit(" INT VALUE AT "+legend, v, v);
return;
}
// fail
t.isit(" INT1 VALUE AT "+legend, v, INT);
}
void checkIntValue( int v, String legend ){
t.isit(" INT2 VALUE AT "+legend, v, INT);
}
void checkByteValue( int v, String legend ){
t.isit(" BYTE VALUE AT "+legend, v, BYTE);
}
void checkCharValue( int v, String legend ){
t.isit(" CHAR VALUE AT "+legend, v, CHAR);
}
void checkFloatValue( float v, String legend ){
t.isit(" FLOAT VALUE AT "+legend, v, FLOAT);
}
/*
* The overloaded member function.
*/
void m( int v ){
checkAnyIntValue( v, "m( int )" );
}
/*
* The compiler does not seem to distinguish between int
* and small-int when resolving. This is a reported "bug".
* But, like C, Java promotes all integers to int for expressi
on
* evaluation, so this may not even be a bug!
*
* static void m( byte v ){
* System.out.println(" byte of value "+v);
* }
*
* static void m( char v ){
* System.out.println(" char of value "+v);
* }
* }
*
*/
void m( float v ){
checkFloatValue( v, "m( float )" );
}
void m( int v, int u ){
checkAnyIntValue( v, "m( int, int) first parameter" );
checkAnyIntValue( u, "m( int, int) second parameter" );
}
void m( float v, float u ){
checkFloatValue( v, "m( float, float ) first parameter" );
checkFloatValue( u, "m( float, float ) second parameter" )
;
}
void m( int v, float u ){
checkAnyIntValue( v, "m( int, float ) first parameter" );
checkFloatValue( u, "m( int, float ) second parameter" );
}
void m( float v, int u ){
checkFloatValue( v, "m( float, int) first parameter" );
checkAnyIntValue( u, "m( float, int) second parameter" );
}
void m( int v[] ){
checkIntValue( v[0], "m( int v[] )");
}
void m( byte v[] ){
checkByteValue( v[0], "m( byte v[] )");
}
void m( char v[] ){
checkCharValue( v[0], "m( char v[] )");
}
void m( float v[] ){
checkFloatValue( v[0], "m( float v[] )");
}
/*
* Calls to the overloaded member function.
*/
void callWithConstMembers(){
System.out.println("Const members");
m( INT );
m( BYTE );
m( CHAR );
m( FLOAT );
m( INT, INT); //Compiler was broken
//nskipped+=2;
m( FLOAT, INT);
m( INT, FLOAT);
m( FLOAT, FLOAT); //Compiler was broken
//nskipped+=2;
}
void callWithLocalScalars(){
int i = INT;
byte b = BYTE;
char c = CHAR;
float f = FLOAT;
System.out.println("Local variables");
m( i );
m( b );
m( c );
m( f );
m( i, i); //Compiler was broken
//nskipped+=2;
m( f, i);
m( i, f);
m( f, f); //Compiler was broken
//nskipped+=2;
}
void callWithArrayElements(){
int i[] = { INT };
byte b[] = { BYTE };
char c[] = { CHAR };
float f[] = { FLOAT };
System.out.println("Array elements");
m( i[0] );
m( b[0] );
m( c[0] );
m( f[0] );
m( i[0], i[0]); //Compiler was broken
//nskipped+=2;
m( f[0], i[0]);
m( i[0], f[0]);
m( f[0], f[0]); //Compiler was broken
//nskipped+=2;
}
void callWithCastScalars(){
int i = INT;
int j = (int)FLOAT;
float f = FLOAT;
float g = (float)INT;
System.out.println("Cast variables");
m( (byte)i );
m( (char)i );
m( (float)j );
m( (int)g );
m( (byte)g );
m( (char)g );
m( (float)j, (float)j); //Compiler was broken
//nskipped+=2;
m( (int)g, (float)j);
m( (float)j, (int)g);
m( (int)g, (int)g); //Compiler was broken
//nskipped+=2;
}
void callWithArrays(){
int i[] = { INT };
byte b[] = { BYTE };
char c[] = { CHAR };
float f[] = { FLOAT };
System.out.println("Arrays");
m( i );
m( b );
m( c );
m( f );
}
void callWithExpressions(){
int i = INT;
float f = FLOAT;
float g = (float)2.0;
System.out.println("Expressions");
m( i/i );
m( i*f );
m( f*g-f );
m( f/i, i+i);
m( i+i, f/i);
m( f+f-2*g, i*f); // COMPILER was BROKEN
//nskipped+=2;
m( i*f, 2*f/g); // COMPILER was BROKEN
//nskipped+=2;
}
public static void main( String x[] ){
ScalarSignature S = new ScalarSignature();
S.callWithConstMembers();
S.callWithLocalScalars();
S.callWithCastScalars();
S.callWithArrayElements();
S.callWithArrays();
S.callWithExpressions();
S.t.summary("Overloading member function with scalar signa
tures");
if (S.nskipped!=0){
System.out.println(" and "+S.nskipped+"
skipped due to known compiler bugs");
}
}
}
$ more testing.java
/*
* @(#)testing.java 1.3 95/01/31
* class used for counting up test successes and failures
*/
import java.lang.Thread;
public class testing{
public int success;
public int failure;
public
testing()
{
success = 0;
failure = 0;
}
public void
isit( String testexpression, boolean actual, boolean expected
)
{
if ( actual == expected ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual?"true":"false" );
failure++;
}
}
public void
isit( String testexpression, int actual, int expected )
{
if ( actual == expected ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
isit( String testexpression, float actual, float expected )
{
if ( actual == expected ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
isit( String testexpression, String actual, String expected )
{
if ( actual.equals( expected ) ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
isit( String testexpression, String actual, String expected )
{
if ( actual.equals( expected ) ){
success++;
} else {
System.out.print( "Failure: " );
System.out.print( testexpression );
System.out.print( " yields " );
System.out.println( actual );
System.out.print( " expected " );
System.out.println( expected );
failure++;
}
}
public void
summary( String legend )
{
System.out.println("");
System.out.print( legend );
System.out.print( ": " );
System.out.print( success );
System.out.print( " passed, " );
System.out.print( failure );
System.out.println( " failed\\n" );
}
};