diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/testsuite/libjava.jar | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libjava/testsuite/libjava.jar')
-rw-r--r-- | libjava/testsuite/libjava.jar/TestClosureGC.jar | bin | 0 -> 3997 bytes | |||
-rw-r--r-- | libjava/testsuite/libjava.jar/TestClosureGC.java | 116 | ||||
-rw-r--r-- | libjava/testsuite/libjava.jar/TestClosureGC.out | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.jar/TestClosureGC.xfail | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.jar/jar.exp | 67 | ||||
-rw-r--r-- | libjava/testsuite/libjava.jar/simple.jar | bin | 0 -> 666 bytes | |||
-rw-r--r-- | libjava/testsuite/libjava.jar/simple.java | 7 | ||||
-rw-r--r-- | libjava/testsuite/libjava.jar/simple.out | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.jar/simple.xfail | 1 |
9 files changed, 194 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.jar/TestClosureGC.jar b/libjava/testsuite/libjava.jar/TestClosureGC.jar Binary files differnew file mode 100644 index 000000000..60d948ad5 --- /dev/null +++ b/libjava/testsuite/libjava.jar/TestClosureGC.jar diff --git a/libjava/testsuite/libjava.jar/TestClosureGC.java b/libjava/testsuite/libjava.jar/TestClosureGC.java new file mode 100644 index 000000000..69a325a99 --- /dev/null +++ b/libjava/testsuite/libjava.jar/TestClosureGC.java @@ -0,0 +1,116 @@ +/* Verify that libffi closures aren't deallocated too early. + + Copyright (C) 2007 Free Software Foundation, Inc + Contributed by Alexandre Oliva <aoliva@redhat.com> + + If libffi closures are released too early, we lose. + */ + +import java.util.HashSet; + +public class TestClosureGC { + public static String objId (Object obj) { + return obj + "/" + + Integer.toHexString(obj.getClass().getClassLoader().hashCode()); + } + public static class cld extends java.net.URLClassLoader { + static final Object obj = new cl0(); + public cld () throws Exception { + super(new java.net.URL[] { }); + /* System.out.println (objId (this) + " created"); */ + } + public void finalize () { + /* System.out.println (objId (this) + " finalized"); */ + } + public String toString () { + return this.getClass().getName() + "@" + + Integer.toHexString (hashCode ()); + } + public Class loadClass (String name) throws ClassNotFoundException { + try { + java.io.InputStream IS = getSystemResourceAsStream + (name + ".class"); + int maxsz = 1024, readsz = 0; + byte buf[] = new byte[maxsz]; + for(;;) { + int readnow = IS.read (buf, readsz, maxsz - readsz); + if (readnow <= 0) + break; + readsz += readnow; + if (readsz == maxsz) { + byte newbuf[] = new byte[maxsz *= 2]; + System.arraycopy (buf, 0, newbuf, 0, readsz); + buf = newbuf; + } + } + return defineClass (name, buf, 0, readsz); + } catch (Exception e) { + return super.loadClass (name); + } + } + } + public static class cl0 { + public cl0 () { + /* System.out.println (objId (this) + " created"); */ + } + public void finalize () { + /* System.out.println (objId (this) + " finalized"); */ + } + } + public static class cl1 { + final HashSet hs; + static final Object obj = new cl0(); + public cl1 (final HashSet hs) { + this.hs = hs; + /* System.out.println (objId (this) + " created"); */ + } + public void finalize () { + /* System.out.println (objId (this) + " finalized"); */ + } + } + public static class cl2 { + final HashSet hs; + static final Object obj = new cl0(); + public cl2 (final HashSet hs) { + this.hs = hs; + /* System.out.println (objId (this) + " created"); */ + } + public void finalize () { + /* System.out.println (objId (this) + " finalized"); */ + hs.add(this); + hs.add(new cl0()); + } + } + static final HashSet hs = new HashSet(); + static final Object obj = new cl0(); + public static void main(String[] argv) throws Exception { + { + Class[] hscs = { HashSet.class }; + Object[] hsos = { hs }; + new cld().loadClass ("TestClosureGC$cl1"). + getConstructor (hscs).newInstance (hsos); + new cld().loadClass ("TestClosureGC$cl2"). + getConstructor (hscs).newInstance (hsos); + new cld().loadClass ("TestClosureGC$cl1"). + getConstructor (hscs).newInstance (hsos); + new cld().loadClass ("TestClosureGC$cl1"). + getConstructor (hscs).newInstance (hsos); + } + for (int i = 1; i <= 5; i++) { + /* System.out.println ("Will run GC and finalization " + i); */ + System.gc (); + Thread.sleep (100); + System.runFinalization (); + Thread.sleep (100); + if (hs.isEmpty ()) + continue; + java.util.Iterator it = hs.iterator (); + while (it.hasNext ()) { + Object obj = it.next(); + /* System.out.println (objId (obj) + " in ht, removing"); */ + it.remove (); + } + } + System.out.println ("ok"); + } +} diff --git a/libjava/testsuite/libjava.jar/TestClosureGC.out b/libjava/testsuite/libjava.jar/TestClosureGC.out new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/libjava/testsuite/libjava.jar/TestClosureGC.out @@ -0,0 +1 @@ +ok diff --git a/libjava/testsuite/libjava.jar/TestClosureGC.xfail b/libjava/testsuite/libjava.jar/TestClosureGC.xfail new file mode 100644 index 000000000..963b35a7c --- /dev/null +++ b/libjava/testsuite/libjava.jar/TestClosureGC.xfail @@ -0,0 +1 @@ +main=TestClosureGC diff --git a/libjava/testsuite/libjava.jar/jar.exp b/libjava/testsuite/libjava.jar/jar.exp new file mode 100644 index 000000000..65565832e --- /dev/null +++ b/libjava/testsuite/libjava.jar/jar.exp @@ -0,0 +1,67 @@ +# Tests for .jar files. + +# Compile a single .jar file to an executable. +# Returns 0 on failure. +proc gcj_jar_link {jarfile mainclass} { +} + +proc gcj_jar_compile_one {jarfile mainclass} { + set base [file rootname [file tail $jarfile]] + set out [file rootname $jarfile].out + + if {! [gcj_link $base $mainclass [list $jarfile]]} { + return + } + + gcj_invoke $base $out {} +} + +proc gcj_jar_interpret {jarfile} { + global INTERPRETER srcdir + + set gij [libjava_find_gij] + # libjava_find_gij will return "" if it couldn't find the + # program; in this case we want to skip the test. + if {$INTERPRETER != "yes" || $gij == ""} { + untested "$jarfile execution - gij test" + untested "$jarfile output - gij test" + return + } + + set opts(_) {} + set out [file rootname $jarfile].out + libjava_invoke $jarfile "gij test" opts $gij {} $out \ + "" -jar $jarfile +} + +proc gcj_jar_run {} { + global srcdir subdir env + foreach jar [lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar]] { + set xff [file rootname $jar].xfail + set main {} + set interp 1 + foreach item [libjava_read_xfail $xff] { + if {[string match main=* $item]} { + set main [string range $item 5 end] + break + } elseif {$item == "no-interpret"} { + set interp 0 + } + } + + gcj_jar_compile_one $jar $main + if {$interp} { + gcj_jar_interpret $jar + } + } + # When we succeed we remove all our clutter. + eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main ] + + # Reset CLASSPATH that we do not look into testsuite/libjava.jar for *.jar + # files which do not belong to the libgcj itself. + set env(CLASSPATH) "" + + return 1 +} + +gcj_jar_run diff --git a/libjava/testsuite/libjava.jar/simple.jar b/libjava/testsuite/libjava.jar/simple.jar Binary files differnew file mode 100644 index 000000000..a3359b298 --- /dev/null +++ b/libjava/testsuite/libjava.jar/simple.jar diff --git a/libjava/testsuite/libjava.jar/simple.java b/libjava/testsuite/libjava.jar/simple.java new file mode 100644 index 000000000..848ebe126 --- /dev/null +++ b/libjava/testsuite/libjava.jar/simple.java @@ -0,0 +1,7 @@ +public class simple +{ + public static void main(String[] args) + { + System.out.println("hi"); + } +} diff --git a/libjava/testsuite/libjava.jar/simple.out b/libjava/testsuite/libjava.jar/simple.out new file mode 100644 index 000000000..45b983be3 --- /dev/null +++ b/libjava/testsuite/libjava.jar/simple.out @@ -0,0 +1 @@ +hi diff --git a/libjava/testsuite/libjava.jar/simple.xfail b/libjava/testsuite/libjava.jar/simple.xfail new file mode 100644 index 000000000..478dfc794 --- /dev/null +++ b/libjava/testsuite/libjava.jar/simple.xfail @@ -0,0 +1 @@ +main=simple |