Initial revision
From-SVN: r26263
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// Test of array stuff. Technically this probably isn't in java.lang.
|
||||
|
||||
public class Array_1
|
||||
{
|
||||
public static void main (String[] args)
|
||||
{
|
||||
int x[][] = { { 1, 2}, null };
|
||||
|
||||
System.out.println(Cloneable.class.isInstance(x));
|
||||
|
||||
// This example is from the Java Spec book.
|
||||
int y[][] = (int[][]) x.clone();
|
||||
System.out.println(x == y);
|
||||
System.out.println(x[0] == y[0] && x[1] == y[1]);
|
||||
|
||||
System.out.println(x.getClass().getSuperclass());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
true
|
||||
false
|
||||
true
|
||||
class java.lang.Object
|
||||
@@ -0,0 +1,28 @@
|
||||
// Finalize.java - Test code for finalizers.
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.lang.Runtime;
|
||||
|
||||
public final class Finalize_1
|
||||
{
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Finalize_1 f;
|
||||
Runtime t;
|
||||
|
||||
t = Runtime.getRuntime ();
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
f = new Finalize_1 ();
|
||||
f = null;
|
||||
|
||||
t.gc ();
|
||||
t.runFinalization ();
|
||||
}
|
||||
|
||||
public void finalize () throws Throwable
|
||||
{
|
||||
System.out.print ("Finalize ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Finalize Finalize Finalize
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
|
||||
Date: 25 Aug 1998 16:04:00 -0000
|
||||
From: Andrew Haley <aph@pasanda.cygnus.co.uk>
|
||||
To: java-project@cygnus.com
|
||||
Subject: Help: vtable problem?
|
||||
|
||||
My little program:
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
import java.lang.*;
|
||||
|
||||
public class widget
|
||||
{
|
||||
public static void main (String argv[])
|
||||
{
|
||||
int test = Float.floatToIntBits((float)2.0);
|
||||
String s = Integer.toHexString(test);
|
||||
|
||||
System.out.print (s+"\n");
|
||||
}
|
||||
|
||||
}
|
||||
-----------------------------------------------------------------------
|
||||
prints out
|
||||
|
||||
40000000
|
||||
|
||||
with Sun's interpreter, but prints out
|
||||
|
||||
true
|
||||
|
||||
when compiled with gcj; PrintStream dispatches a string arg as a
|
||||
boolean rather than as a String. I've tried to rebuild everything.
|
||||
|
||||
?
|
||||
|
||||
Thanks,
|
||||
Andrew.
|
||||
|
||||
*/
|
||||
|
||||
public class Float_1
|
||||
{
|
||||
public static void main (String argv[])
|
||||
{
|
||||
int test = Float.floatToIntBits((float)2.0);
|
||||
String s = Integer.toHexString(test);
|
||||
|
||||
System.out.print (s+"\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
40000000
|
||||
@@ -0,0 +1,27 @@
|
||||
// Test of failing method invocation.
|
||||
|
||||
public class Invoke_1
|
||||
{
|
||||
public void call_me ()
|
||||
{
|
||||
System.out.println ("no");
|
||||
}
|
||||
|
||||
public static Invoke_1 get_i ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Invoke_1 i = get_i ();
|
||||
try
|
||||
{
|
||||
i.call_me ();
|
||||
}
|
||||
catch (NullPointerException ok)
|
||||
{
|
||||
System.out.println ("ok");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ok
|
||||
@@ -0,0 +1,17 @@
|
||||
public class Synch
|
||||
{
|
||||
public synchronized void s()
|
||||
{
|
||||
// This call to notify() isn't supposed to cause a
|
||||
// java.lang.IllegalMonitorStateException.
|
||||
notify ();
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
(new Synch()).s();
|
||||
System.out.println ("Ok");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Ok
|
||||
@@ -0,0 +1,182 @@
|
||||
// Various thread tests.
|
||||
|
||||
public class Thread_1 extends Thread
|
||||
{
|
||||
// The group for the workers.
|
||||
static ThreadGroup subgroup;
|
||||
|
||||
// Which piece of test code to try.
|
||||
static int test_case;
|
||||
|
||||
// Names of the tests.
|
||||
static final int JOIN_GOOD = 0;
|
||||
static final int JOIN_TIMEOUT = 1;
|
||||
static final int JOIN_INTERRUPTED = 2;
|
||||
static final int THREAD_EXIT = 3;
|
||||
|
||||
// True if this is normal; false if daemon.
|
||||
boolean normal;
|
||||
// The other thread in the test.
|
||||
Thread_1 other;
|
||||
// True when the thread has entered run().
|
||||
boolean started;
|
||||
|
||||
public void run ()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (normal)
|
||||
{
|
||||
System.out.println ("test " + test_case);
|
||||
// Tell the main thread to start the daemon thread.
|
||||
synchronized (this)
|
||||
{
|
||||
started = true;
|
||||
notify ();
|
||||
}
|
||||
// Now wait for daemon to start.
|
||||
synchronized (other)
|
||||
{
|
||||
while (! other.started)
|
||||
other.wait ();
|
||||
}
|
||||
switch (test_case)
|
||||
{
|
||||
case JOIN_GOOD:
|
||||
other.join ();
|
||||
System.out.println ("joined");
|
||||
break;
|
||||
case JOIN_TIMEOUT:
|
||||
other.join (10);
|
||||
System.out.println (other.isAlive());
|
||||
other.join ();
|
||||
break;
|
||||
case JOIN_INTERRUPTED:
|
||||
other.join ();
|
||||
System.out.println ("joined");
|
||||
break;
|
||||
case THREAD_EXIT:
|
||||
// Nothing.
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println ("failure");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let the normal thread start first.
|
||||
synchronized (other)
|
||||
{
|
||||
while (! other.started)
|
||||
other.wait();
|
||||
}
|
||||
// Tell normal thread that we've started.
|
||||
synchronized (this)
|
||||
{
|
||||
started = true;
|
||||
notify ();
|
||||
}
|
||||
switch (test_case)
|
||||
{
|
||||
case JOIN_GOOD:
|
||||
System.out.println ("daemon done");
|
||||
break;
|
||||
case JOIN_TIMEOUT:
|
||||
sleep (50);
|
||||
break;
|
||||
case JOIN_INTERRUPTED:
|
||||
other.interrupt ();
|
||||
break;
|
||||
case THREAD_EXIT:
|
||||
// Wait for a while. However, don't wait indefinitely
|
||||
// -- we want this thread to terminate so that the
|
||||
// process won't hang if there is a bug.
|
||||
sleep (10000);
|
||||
System.out.println ("daemon still alive");
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println ("failure");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
System.out.println ("interrupted");
|
||||
}
|
||||
}
|
||||
|
||||
public void setOther (Thread_1 x)
|
||||
{
|
||||
other = x;
|
||||
}
|
||||
|
||||
Thread_1 (String name, boolean x)
|
||||
{
|
||||
super (subgroup, name);
|
||||
normal = x;
|
||||
started = false;
|
||||
setDaemon (! normal);
|
||||
}
|
||||
|
||||
// Run a single test.
|
||||
static Thread_1 doit (int what)
|
||||
{
|
||||
// FIXME: we used to just use the same threads each time. That
|
||||
// didn't work -- must debug.
|
||||
Thread_1 dt = new Thread_1 ("daemon", false);
|
||||
Thread_1 nt = new Thread_1 ("normal", true);
|
||||
|
||||
dt.setOther(nt);
|
||||
nt.setOther(dt);
|
||||
|
||||
test_case = what;
|
||||
try
|
||||
{
|
||||
nt.start();
|
||||
dt.start();
|
||||
|
||||
// Don't wait for the threads if we're doing the exit test.
|
||||
if (what != THREAD_EXIT)
|
||||
{
|
||||
nt.join ();
|
||||
dt.join ();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
System.out.println ("caught bad exception");
|
||||
}
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
subgroup = new ThreadGroup ("sub");
|
||||
|
||||
doit (JOIN_GOOD);
|
||||
|
||||
System.out.println ("active count = " + subgroup.activeCount ());
|
||||
|
||||
Thread_1 dt = doit (JOIN_TIMEOUT);
|
||||
// Make sure that joining a dead thread works.
|
||||
System.out.println ("still alive: " + dt.isAlive ());
|
||||
try
|
||||
{
|
||||
dt.join ();
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
System.out.println ("exception caught");
|
||||
}
|
||||
|
||||
doit (JOIN_INTERRUPTED);
|
||||
|
||||
// This test must come last.
|
||||
doit (THREAD_EXIT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
test 0
|
||||
daemon done
|
||||
joined
|
||||
active count = 2
|
||||
test 1
|
||||
true
|
||||
still alive: false
|
||||
test 2
|
||||
interrupted
|
||||
test 3
|
||||
@@ -0,0 +1,25 @@
|
||||
// Some tests of `throw'.
|
||||
|
||||
public class Throw_1
|
||||
{
|
||||
public static Throwable get ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Throwable t = get ();
|
||||
try
|
||||
{
|
||||
throw t;
|
||||
}
|
||||
catch (NullPointerException y)
|
||||
{
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
System.out.println ("no");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
global srcdir subdir
|
||||
|
||||
catch "glob -nocomplain ${srcdir}/${subdir}/*.out" srcfiles
|
||||
verbose "srcfiles are $srcfiles"
|
||||
|
||||
set prefix ""
|
||||
foreach x $srcfiles {
|
||||
regsub "\\.out$" $x "" prefix
|
||||
set bname [file tail $prefix]
|
||||
set args ""
|
||||
if [file exists $srcdir/$subdir/${bname}.arg] {
|
||||
set id [open "$srcdir/$subdir/${bname}.arg" r];
|
||||
set args [read -nonewline $id];
|
||||
close $id;
|
||||
}
|
||||
if [file exists $srcdir/$subdir/${bname}.xpo] {
|
||||
set resfile "$srcdir/$subdir/${bname}.xpo"
|
||||
set options "regexp_match"
|
||||
} else {
|
||||
set resfile "${prefix}.out"
|
||||
set options ""
|
||||
}
|
||||
|
||||
if [file exists ${prefix}.inp] {
|
||||
set inpfile ${prefix}.inp
|
||||
} else {
|
||||
set inpfile ""
|
||||
}
|
||||
|
||||
verbose "inpfile is $inpfile"
|
||||
|
||||
test_libjava $options "${prefix}.java" "" $inpfile $resfile $args
|
||||
test_libjava $options "${prefix}.java" "-O" $inpfile $resfile $args
|
||||
}
|
||||
Reference in New Issue
Block a user