tests.java.javatests.GCTestHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython-installer Show documentation
Show all versions of jython-installer Show documentation
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
package javatests;
import org.python.core.*;
import java.util.*;
public class GCTestHelper {
/**
* NastyFinalizer is a non-PyObject class with a time-consuming
* finalizer that does not notify Jython-gc. This would cause
* some tests in test_gc_jy.py to fail.
*/
public static class NastyFinalizer {
public void finalize() {
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
}
}
}
/**
* In contrast to NastyFinalizer, this class - still equally
* time-consuming - calls {@code gc.notifyPreFinalization()}
* and {@code gc.notifyPostFinalization()} and thus lets all
* tests work as expected.
*/
public static class NotSoNastyFinalizer {
public void finalize() {
org.python.modules.gc.notifyPreFinalization();
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
}
org.python.modules.gc.notifyPostFinalization();
}
}
/**
* PyReflectionTraversed is a test-PyObject that intentionally
* violates the Traverseproc-mechanism, i.e. holds a non-static
* reference to another PyObject, but neither implements Traverseproc
* nor is marked as untraversable.
*/
public static class PyReflectionTraversed extends PyObject {
PyObject referent1;
PyObject[] refArray = new PyObject[3];
List