From: <cg...@us...> - 2009-01-04 22:15:14
|
Revision: 5842 http://jython.svn.sourceforge.net/jython/?rev=5842&view=rev Author: cgroves Date: 2009-01-04 22:15:09 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Split java subclassing tests out of test_java_integration into test_java_subclasses, move unduplicated bits of test_jsubclass into test_java_subclasses. Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_java_visibility.py trunk/jython/src/org/python/core/PyReflectedConstructor.java trunk/jython/tests/java/org/python/tests/Coercions.java Added Paths: ----------- trunk/jython/Lib/test/test_java_subclasses.py Removed Paths: ------------- trunk/jython/Lib/test/test_jsubclass.py trunk/jython/bugtests/classes/test288i.java trunk/jython/bugtests/classes/test288j.java trunk/jython/bugtests/test290.py trunk/jython/bugtests/test291.py trunk/jython/tests/java/javatests/MethodInvokationTest.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -5,127 +5,32 @@ from test import test_support -from java.lang import (Boolean, Class, ClassLoader, ExceptionInInitializerError, Integer, Object, - String, Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte) +from java.lang import (ExceptionInInitializerError, String, Runnable, System, Runtime, Math, Byte) from java.math import BigDecimal from java.io import (FileInputStream, FileNotFoundException, FileOutputStream, FileWriter, OutputStreamWriter, UnsupportedEncodingException) from java.util import ArrayList, Date, HashMap, Hashtable, StringTokenizer, Vector -from java.awt import Dimension, Color, Component, Container, Rectangle +from java.awt import Dimension, Color, Component, Container from java.awt.event import ComponentEvent -from javax.swing.table import AbstractTableModel from javax.swing.tree import TreePath from org.python.core.util import FileUtil -from org.python.tests import BeanImplementation, Callbacker, Listenable -from javatests import MethodInvokationTest -""" -public abstract class Abstract { - public Abstract() { - method(); - } +from org.python.tests import BeanImplementation, Listenable - public abstract void method(); -} -""" -# The following is the correspoding bytecode for Abstract compiled with javac 1.5 -ABSTRACT_CLASS = """\ -eJw1TrsKwkAQnI1nEmMe/oKdSaHYiyCClWih2F+SQyOaQDz9LxsFCz/AjxL3Am6xw8zs7O7n+3oD -GKPnQcD30ELgIHQQEexJURZ6SmgN4h1BzKtcEaJlUarV9ZyqeivTEyv2WelDlRO8TXWtM7UojBrM -0ouuZaaHR3mTPtqwfXRgE9y/Q+gZb3SS5X60To8q06LPHwiYskAmxN1hFjMSYyd5gpIHrDsT3sU9 -5IgZF4wuhCBzpnG9Ru/+AF4RJn8= -""".decode('base64').decode('zlib') - -class AbstractOnSyspathTest(unittest.TestCase): - '''Subclasses an abstract class that isn't on the startup classpath. - - Checks for http://jython.org/bugs/1861985 - ''' - def setUp(self): - out = open('Abstract.class', 'w') - out.write(ABSTRACT_CLASS) - out.close() - self.orig_syspath = sys.path[:] - sys.path.append('') - - def tearDown(self): - os.unlink('Abstract.class') - sys.path = self.orig_syspath - - def test_can_subclass_abstract(self): - import Abstract - - class A(Abstract): - def method(self): - pass - A() - -""" -public abstract class ContextAbstract { - public ContextAbstract() { - method(); - } - - public abstract void method(); -} -""" -# The following is the correspoding bytecode for ContextAbstract compiled with javac 1.5 -# Needs to be named differently than Abstract above so the class loader won't just use it -CONTEXT_ABSTRACT = '''\ -eJxdjr1uwjAUhc8lbgIh/AVegA0YQJ1BlRBSp6gdWrE7wQKjEEvBVH0tFip14AF4KMQ17YSHc3yu -vuPry/X3DOAZ3RACrRAe2gE6AWKCP9OFti8EbzBcEsTCrBShlehCvR12qSo/ZZrzJE5MJvOlLLXL -/0NhN3pP6CQLU1j1befp3pYys1N+d6fsxqwI4Yc5lJl61a7QewDHW/klIzzBjxDB58UPAKHtkEku -i/XkPd2qzIo+/1/AnQrIdVkDTlN2Yq+NfkCjEyrHO1JlbXLF3QV7lbXGKfqDEaIOCHL7ORMad7J5 -A7yvPDQ= -'''.decode('base64').decode('zlib') -class ContextClassloaderTest(unittest.TestCase): - '''Classes on the context classloader should be importable and subclassable. - - http://bugs.jython.org/issue1216''' - def setUp(self): - self.orig_context = Thread.currentThread().contextClassLoader - class AbstractLoader(ClassLoader): - def __init__(self): - ClassLoader.__init__(self) - c = self.super__defineClass("ContextAbstract", CONTEXT_ABSTRACT, 0, - len(CONTEXT_ABSTRACT), ClassLoader.protectionDomain) - self.super__resolveClass(c) - Thread.currentThread().contextClassLoader = AbstractLoader() - - def tearDown(self): - Thread.currentThread().contextClassLoader = self.orig_context - - def test_can_subclass_abstract(self): - import ContextAbstract - - called = [] - class A(ContextAbstract): - def method(self): - called.append(True) - A() - self.assertEquals(len(called), 1) - -# The no-arg constructor for proxies attempts to look up its Python class by the Python class' name, -# so the class needs to be visible at the module level or the import will fail -class ModuleVisibleJavaSubclass(Object): - pass class InstantiationTest(unittest.TestCase): - def test_can_subclass_abstract(self): - class A(Component): - pass - A() - def test_cant_instantiate_abstract(self): self.assertRaises(TypeError, Component) + def test_no_public_constructors(self): + self.assertRaises(TypeError, Math) + + def test_invalid_self_to_java_constructor(self): + self.assertRaises(TypeError, Color.__init__, 10, 10, 10) + def test_str_doesnt_coerce_to_int(self): self.assertRaises(TypeError, Date, '99-01-01', 1, 1) - def test_Class_newInstance_works_on_proxies(self): - Class.newInstance(ModuleVisibleJavaSubclass) - - class BeanTest(unittest.TestCase): def test_shared_names(self): self.failUnless(callable(Vector.size), @@ -151,51 +56,7 @@ self.assertEquals("name", b.getName()) self.assertEquals("name", b.name) -class ExtendJavaTest(unittest.TestCase): - def test_override_tostring(self): - class A(Object): - def toString(self): - return 'name' - self.assertEquals('name', String.valueOf(A())) - def test_multiple_inheritance_prohibited(self): - try: - class MultiJava(Dimension, Color): - pass - self.fail("Shouldn't be able to subclass more than one concrete java class") - except TypeError: - pass - - def test_multilevel_override(self): - class SubDate(Date): - def toString(self): - s = Date.toString(self) - return 'SubDate -> Date' - - class SubSubDate(SubDate): - def toString(self): - return 'SubSubDate -> ' + SubDate.toString(self) - self.assertEquals("SubDate -> Date", SubDate().toString()) - self.assertEquals("SubSubDate -> SubDate -> Date", SubSubDate().toString()) - - def test_passthrough(self): - class CallbackPassthrough(Callbacker.Callback): - def __init__(self, worker): - self.worker = worker - - def __getattribute__(self, name): - if name == 'call': - return getattr(self.worker, name) - return object.__getattribute__(self, name) - - collector = Callbacker.CollectingCallback() - c = CallbackPassthrough(collector) - Callbacker.callNoArg(c) - self.assertEquals("call()", collector.calls[0]) - c.call(7) - self.assertEquals("call(7)", collector.calls[1]) - - class SysIntegrationTest(unittest.TestCase): def setUp(self): self.orig_stdout = sys.stdout @@ -212,32 +73,6 @@ self.assertEquals('hello', f.read()) f.close() -class AutoSuperTest(unittest.TestCase): - def test_auto_super(self): - class R(Rectangle): - def __init__(self): - self.size = Dimension(6, 7) - self.assert_("width=6,height=7" in R().toString()) - - def test_no_default_constructor(self): - "Check autocreation when java superclass misses a default constructor." - class A(ThreadGroup): - def __init__(self): - print self.name - self.assertRaises(TypeError, A) - - def test_no_public_constructors(self): - self.assertRaises(TypeError, Math) - -class PyObjectCmpTest(unittest.TestCase): - def test_vect_cmp(self): - "Check comparing a PyJavaClass with a Object." - class X(Runnable): - pass - v = Vector() - v.addElement(1) - v.indexOf(X()) - class IOTest(unittest.TestCase): def test_io_errors(self): "Check that IOException isn't mangled into an IOError" @@ -252,20 +87,6 @@ self.assertRaises(IOError, fp.tell) -class VectorTest(unittest.TestCase): - def test_looping(self): - for i in Vector(): pass - - def test_return_proxy(self): - "Jython proxies properly return back from Java code" - class FooVector(Vector): - bar = 99 - - ht = Hashtable() - fv = FooVector() - ht.put("a", fv) - self.failUnless(fv is ht.get("a")) - class JavaReservedNamesTest(unittest.TestCase): "Access to reserved words" @@ -419,7 +240,6 @@ self.assertRaises(ExceptionInInitializerError, __import__, "org.python.tests.BadStaticInitializer") class ColorTest(unittest.TestCase): - def test_assigning_over_method(self): self.assertRaises(TypeError, setattr, Color.RED, "getRGB", 4) @@ -436,39 +256,11 @@ self.assert_(red is Color.red) class TreePathTest(unittest.TestCase): - def test_overloading(self): treePath = TreePath([1,2,3]) self.assertEquals(len(treePath.path), 3, "Object[] not passed correctly") self.assertEquals(TreePath(treePath.path).path, treePath.path, "Object[] not passed and returned correctly") -class TableModelTest(unittest.TestCase): - def test_column_classes(self): - class TableModel(AbstractTableModel): - columnNames = "First Name", "Last Name","Sport","# of Years","Vegetarian" - data = [("Mary", "Campione", "Snowboarding", 5, False)] - - def getColumnCount(self): - return len(self.columnNames) - - def getRowCount(self): - return len(self.data) - - def getColumnName(self, col): - return self.columnNames[col] - - def getValueAt(self, row, col): - return self.data[row][col] - - def getColumnClass(self, c): - return Object.getClass(self.getValueAt(0, c)) - - def isCellEditable(self, row, col): - return col >= 2 - model = TableModel() - for i, expectedClass in enumerate([String, String, String, Integer, Boolean]): - self.assertEquals(expectedClass, model.getColumnClass(i)) - class BigDecimalTest(unittest.TestCase): def test_coerced_bigdecimal(self): from javatests import BigDecimalTest @@ -478,41 +270,7 @@ self.assertEqual(type(x), type(y), "BigDecimal coerced") self.assertEqual(x, y, "coerced BigDecimal not equal to directly created version") -class MethodInvTest(unittest.TestCase): - - def test_method_invokation(self): - bar = MethodInvokationTest.foo1(Byte(10)) - - self.assertEquals(bar, "foo1 with byte arg: 10", "Wrong method called") - -class InterfaceTest(unittest.TestCase): - - def test_override(self): - class Foo(Runnable): - def run(self): pass - def toString(self): return "Foo!!!" - - foo = Foo() - s = String.valueOf(foo) - - self.assertEquals(s, "Foo!!!", "toString not overridden in interface") - - def test_java_calling_python_interface_implementation(self): - called = [] - class PyCallback(Callbacker.Callback): - def call(self, extraarg=None): - called.append(extraarg) - Callbacker.callNoArg(PyCallback()) - Callbacker.callOneArg(PyCallback(), 4294967295L) - self.assertEquals(None, called[0]) - self.assertEquals(4294967295L, called[1]) - class PyBadCallback(Callbacker.Callback): - def call(pyself, extraarg): - self.fail("Shouldn't be callable with a no args") - self.assertRaises(TypeError, Callbacker.callNoArg, PyBadCallback()) - class JavaStringTest(unittest.TestCase): - def test_string_not_iterable(self): x = String('test') self.assertRaises(TypeError, list, x) @@ -551,27 +309,26 @@ tokenizer = StringTokenizer('foo bar') self.assertEquals(list(iter(tokenizer)), ['foo', 'bar']) + def test_vector_delegation(self): + class X(Runnable): + pass + v = Vector() + v.addElement(1) + v.indexOf(X())# Compares the Java object in the vector to a Python subclass + for i in v: + pass def test_main(): - test_support.run_unittest(AbstractOnSyspathTest, - ContextClassloaderTest, - InstantiationTest, + test_support.run_unittest(InstantiationTest, BeanTest, - ExtendJavaTest, SysIntegrationTest, - AutoSuperTest, - PyObjectCmpTest, IOTest, - VectorTest, JavaReservedNamesTest, PyReservedNamesTest, ImportTest, ColorTest, - TableModelTest, TreePathTest, BigDecimalTest, - MethodInvTest, - InterfaceTest, JavaStringTest, JavaDelegationTest, ) Added: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py (rev 0) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -0,0 +1,243 @@ +'''Tests subclassing Java classes in Python''' +import os +import sys +import unittest + +from test import test_support + +from java.lang import (Boolean, Class, ClassLoader, Integer, Object, Runnable, String, Thread, + ThreadGroup) +from java.util import Date, Hashtable, Vector + +from java.awt import Color, Component, Dimension, Rectangle +from javax.swing.table import AbstractTableModel + +from org.python.tests import Callbacker + +class InterfaceTest(unittest.TestCase): + def test_java_calling_python_interface_implementation(self): + called = [] + class PyCallback(Callbacker.Callback): + def call(self, extraarg=None): + called.append(extraarg) + Callbacker.callNoArg(PyCallback()) + Callbacker.callOneArg(PyCallback(), 4294967295L) + self.assertEquals(None, called[0]) + self.assertEquals(4294967295L, called[1]) + class PyBadCallback(Callbacker.Callback): + def call(pyself, extraarg): + self.fail("Shouldn't be callable with a no args") + self.assertRaises(TypeError, Callbacker.callNoArg, PyBadCallback()) + +class TableModelTest(unittest.TestCase): + def test_class_coercion(self): + '''Python type instances coerce to a corresponding Java wrapper type in Object.getClass''' + class TableModel(AbstractTableModel): + columnNames = "First Name", "Last Name","Sport","# of Years","Vegetarian" + data = [("Mary", "Campione", "Snowboarding", 5, False)] + + def getColumnCount(self): + return len(self.columnNames) + + def getRowCount(self): + return len(self.data) + + def getColumnName(self, col): + return self.columnNames[col] + + def getValueAt(self, row, col): + return self.data[row][col] + + def getColumnClass(self, c): + return Object.getClass(self.getValueAt(0, c)) + + def isCellEditable(self, row, col): + return col >= 2 + + model = TableModel() + for i, expectedClass in enumerate([String, String, String, Integer, Boolean]): + self.assertEquals(expectedClass, model.getColumnClass(i)) + +class AutoSuperTest(unittest.TestCase): + def test_auto_super(self): + class Implicit(Rectangle): + def __init__(self): + self.size = Dimension(6, 7) + class Explicit(Rectangle): + def __init__(self): + Rectangle.__init__(self, 6, 7) + self.assert_("width=6,height=7" in Implicit().toString()) + self.assert_("width=6,height=7" in Explicit().toString()) + + def test_no_default_constructor(self): + "Check autocreation when java superclass misses a default constructor." + class A(ThreadGroup): + def __init__(self): + print self.name + self.assertRaises(TypeError, A) + +# The no-arg constructor for proxies attempts to look up its Python class by the Python class' name, +# so the class needs to be visible at the module level or the import will fail +class ModuleVisibleJavaSubclass(Object): + pass +class PythonSubclassesTest(unittest.TestCase): + def test_multiple_inheritance_prohibited(self): + try: + class MultiJava(Dimension, Color): + pass + self.fail("Shouldn't be able to subclass more than one concrete java class") + except TypeError: + pass + + def test_multilevel_override(self): + class SubDate(Date): + def toString(self): + s = Date.toString(self) + return 'SubDate -> Date' + + class SubSubDate(SubDate): + def toString(self): + return 'SubSubDate -> ' + SubDate.toString(self) + self.assertEquals("SubDate -> Date", SubDate().toString()) + self.assertEquals("SubSubDate -> SubDate -> Date", SubSubDate().toString()) + + def test_passthrough(self): + class CallbackPassthrough(Callbacker.Callback): + def __init__(self, worker): + self.worker = worker + + def __getattribute__(self, name): + if name == 'call': + return getattr(self.worker, name) + return object.__getattribute__(self, name) + + collector = Callbacker.CollectingCallback() + c = CallbackPassthrough(collector) + Callbacker.callNoArg(c) + self.assertEquals("call()", collector.calls[0]) + c.call(7) + self.assertEquals("call(7)", collector.calls[1]) + + def test_Class_newInstance_works_on_proxies(self): + Class.newInstance(ModuleVisibleJavaSubclass) + + def test_override(self): + class Foo(Runnable): + def toString(self): return "Foo" + self.assertEquals(String.valueOf(Foo()), "Foo", "toString not overridden in interface") + + class A(Object): + def toString(self): + return 'name' + self.assertEquals('name', String.valueOf(A()), 'toString not overriden in subclass') + + def test_can_subclass_abstract(self): + class A(Component): + pass + A() + + def test_return_proxy(self): + "Jython proxies properly return back from Java code" + class FooVector(Vector): + bar = 99 + + ht = Hashtable() + fv = FooVector() + ht.put("a", fv) + self.failUnless(fv is ht.get("a")) + + +""" +public abstract class Abstract { + public Abstract() { + method(); + } + + public abstract void method(); +} +""" +# The following is the correspoding bytecode for Abstract compiled with javac 1.5 +ABSTRACT_CLASS = """\ +eJw1TrsKwkAQnI1nEmMe/oKdSaHYiyCClWih2F+SQyOaQDz9LxsFCz/AjxL3Am6xw8zs7O7n+3oD +GKPnQcD30ELgIHQQEexJURZ6SmgN4h1BzKtcEaJlUarV9ZyqeivTEyv2WelDlRO8TXWtM7UojBrM +0ouuZaaHR3mTPtqwfXRgE9y/Q+gZb3SS5X60To8q06LPHwiYskAmxN1hFjMSYyd5gpIHrDsT3sU9 +5IgZF4wuhCBzpnG9Ru/+AF4RJn8= +""".decode('base64').decode('zlib') + +class AbstractOnSyspathTest(unittest.TestCase): + '''Subclasses an abstract class that isn't on the startup classpath. + + Checks for http://jython.org/bugs/1861985 + ''' + def setUp(self): + out = open('Abstract.class', 'w') + out.write(ABSTRACT_CLASS) + out.close() + self.orig_syspath = sys.path[:] + sys.path.append('') + + def tearDown(self): + os.unlink('Abstract.class') + sys.path = self.orig_syspath + + def test_can_subclass_abstract(self): + import Abstract + + class A(Abstract): + def method(self): + pass + A() + +""" +public abstract class ContextAbstract { + public ContextAbstract() { + method(); + } + + public abstract void method(); +} +""" +# The following is the correspoding bytecode for ContextAbstract compiled with javac 1.5 +# Needs to be named differently than Abstract above so the class loader won't just use it +CONTEXT_ABSTRACT = '''\ +eJxdjr1uwjAUhc8lbgIh/AVegA0YQJ1BlRBSp6gdWrE7wQKjEEvBVH0tFip14AF4KMQ17YSHc3yu +vuPry/X3DOAZ3RACrRAe2gE6AWKCP9OFti8EbzBcEsTCrBShlehCvR12qSo/ZZrzJE5MJvOlLLXL +/0NhN3pP6CQLU1j1befp3pYys1N+d6fsxqwI4Yc5lJl61a7QewDHW/klIzzBjxDB58UPAKHtkEku +i/XkPd2qzIo+/1/AnQrIdVkDTlN2Yq+NfkCjEyrHO1JlbXLF3QV7lbXGKfqDEaIOCHL7ORMad7J5 +A7yvPDQ= +'''.decode('base64').decode('zlib') +class ContextClassloaderTest(unittest.TestCase): + '''Classes on the context classloader should be importable and subclassable. + + http://bugs.jython.org/issue1216''' + def setUp(self): + self.orig_context = Thread.currentThread().contextClassLoader + class AbstractLoader(ClassLoader): + def __init__(self): + ClassLoader.__init__(self) + c = self.super__defineClass("ContextAbstract", CONTEXT_ABSTRACT, 0, + len(CONTEXT_ABSTRACT), ClassLoader.protectionDomain) + self.super__resolveClass(c) + Thread.currentThread().contextClassLoader = AbstractLoader() + + def tearDown(self): + Thread.currentThread().contextClassLoader = self.orig_context + + def test_can_subclass_abstract(self): + import ContextAbstract + + called = [] + class A(ContextAbstract): + def method(self): + called.append(True) + A() + self.assertEquals(len(called), 1) + + +def test_main(): + test_support.run_unittest(InterfaceTest, + TableModelTest, + AutoSuperTest, + PythonSubclassesTest, + AbstractOnSyspathTest, + ContextClassloaderTest) Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -3,7 +3,7 @@ import subprocess import sys from test import test_support -from java.lang import Class +from java.lang import Byte, Class from java.util import HashMap, Observable, Observer from org.python.tests import (Coercions, HiddenSuper, InterfaceCombination, Invisible, OnlySubclassable, OtherSubVisible, SomePyMethods, SubVisible, Visible, VisibleOverride) @@ -157,6 +157,7 @@ self.assertEquals("5", c.takeInt(5)) self.assertEquals("15", c.takeInteger(15)) self.assertEquals("150", c.takeNumber(150)) + self.assertEquals("take with byte arg: 10", Coercions.take(Byte(10))) def test_array_coercion(self): self.assertEquals("double", Coercions.takeArray(array.zeros('d', 2))) Deleted: trunk/jython/Lib/test/test_jsubclass.py =================================================================== --- trunk/jython/Lib/test/test_jsubclass.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/Lib/test/test_jsubclass.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,49 +0,0 @@ -from test_support import * - -print 'Subclassing Java from Python (test_jsubclass.py)' - -from java.lang import Runnable, Thread - -# Overriding Methods - -print 'override methods' -class MyThread(Thread): - count = 0 - def run(self): - self.count = self.count+1 - - -t1 = MyThread() -t1.start() -t1.join() -assert t1.count == 1, 'subclassing java.lang.Thread' - -print 'pass subclass back to java' - -class MyRun(Runnable): - count = 0 - def run(self): - self.count = self.count+1 - -run = MyRun() -t = Thread(run) -t.start() -t.join() -assert run.count == 1, 'subclassing java.lang.Thread' - -print "invoke super's constructor" - -class MyThread(Thread): - def __init__(self): - self.name = "Python-"+self.name - -t = MyThread() -assert t.name[:14] == "Python-Thread-", 'automatic constructor call' - -class MyThread(Thread): - def __init__(self): - Thread.__init__(self, "Python-Thread") - -t = MyThread() -assert t.name == "Python-Thread", 'explicit constructor call' - Deleted: trunk/jython/bugtests/classes/test288i.java =================================================================== --- trunk/jython/bugtests/classes/test288i.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/classes/test288i.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,4 +0,0 @@ -public interface test288i { - public int get(); - public int get(int i); -} Deleted: trunk/jython/bugtests/classes/test288j.java =================================================================== --- trunk/jython/bugtests/classes/test288j.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/classes/test288j.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,14 +0,0 @@ - -public class test288j extends Object implements test288i { - protected int last; - public test288j() { - this.last = 0; - } - public int get() { - return this.last; - } - public int get(int i) { - this.last = i; - return i; - } -} Deleted: trunk/jython/bugtests/test290.py =================================================================== --- trunk/jython/bugtests/test290.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/test290.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,11 +0,0 @@ -""" -test newline in text pickles #437215 -""" - -import pickle -s1="line1\nline2\nline3" -s2="line4\nline5\nline6" -l = [s1, s2] -p = pickle.dumps(l) # newlines won't be escaped -l2 = pickle.loads(p) # blows up - Deleted: trunk/jython/bugtests/test291.py =================================================================== --- trunk/jython/bugtests/test291.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/test291.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,18 +0,0 @@ -""" -Test keywords to import builtin. -""" - -import support - -impl_names = ['java'] - -# Will only return anygui :P -try: - impls = [__import__('anygui.impl.%sgui' % name, - fromlist=['%sgui' % name]) for name in impl_names] -except TypeError, e: - support.compare(e, "__import__\(\) takes no keyword arguments"); -else: - support.TestError("Should raise a TypeError") - - Modified: trunk/jython/src/org/python/core/PyReflectedConstructor.java =================================================================== --- trunk/jython/src/org/python/core/PyReflectedConstructor.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/src/org/python/core/PyReflectedConstructor.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -82,6 +82,9 @@ throw Py.TypeError("invalid self argument to constructor"); } Class<?> javaClass = self.getType().getProxyType(); + if (javaClass == null) { + throw Py.TypeError("self invalid - must be a Java subclass [self=" + self + "]"); + } Class<?> declaringClass = argslist[0] == null ? null : argslist[0].declaringClass; // If the declaring class is a pure Java type but we're instantiating a Python proxy, // grab the proxy version of the constructor to instantiate the proper type Deleted: trunk/jython/tests/java/javatests/MethodInvokationTest.java =================================================================== --- trunk/jython/tests/java/javatests/MethodInvokationTest.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/tests/java/javatests/MethodInvokationTest.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,19 +0,0 @@ -package javatests; - -public class MethodInvokationTest{ - public static String foo1(int i) { - return "foo1 with int arg: " + i; - } - - public static String foo1(char c) { - return "foo1 with char arg: " + c; - } - - public static String foo1(boolean b) { - return "foo1 with boolean arg: " + b; - } - - public static String foo1(byte bt) { - return "foo1 with byte arg: " + bt; - } -} Modified: trunk/jython/tests/java/org/python/tests/Coercions.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Coercions.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/tests/java/org/python/tests/Coercions.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -67,4 +67,20 @@ public String tellClassNameSerializable(Serializable o) { return o.getClass().toString(); } + + public static String take(int i) { + return "take with int arg: " + i; + } + + public static String take(char c) { + return "take with char arg: " + c; + } + + public static String take(boolean b) { + return "take with boolean arg: " + b; + } + + public static String take(byte bt) { + return "take with byte arg: " + bt; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |