From: <cg...@us...> - 2008-12-29 23:56:50
|
Revision: 5811 http://jython.svn.sourceforge.net/jython/?rev=5811&view=rev Author: cgroves Date: 2008-12-29 23:56:48 +0000 (Mon, 29 Dec 2008) Log Message: ----------- Switch to the proxy constructor before checking if there are no visible constructors as the proxy class may be subclassing a class with only protected constructors. Modified Paths: -------------- trunk/jython/src/org/python/core/PyReflectedConstructor.java Modified: trunk/jython/src/org/python/core/PyReflectedConstructor.java =================================================================== --- trunk/jython/src/org/python/core/PyReflectedConstructor.java 2008-12-29 22:38:59 UTC (rev 5810) +++ trunk/jython/src/org/python/core/PyReflectedConstructor.java 2008-12-29 23:56:48 UTC (rev 5811) @@ -82,19 +82,19 @@ throw Py.TypeError("invalid self argument to constructor"); } Class<?> javaClass = self.getType().getProxyType(); + 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 + if ((declaringClass == null || !PyProxy.class.isAssignableFrom(declaringClass)) + && !(self.getType() instanceof PyJavaType)) { + return PyType.fromClass(javaClass).lookup("__init__").__call__(self, args, keywords); + } if (nargs == 0) { throw Py.TypeError("No visible constructors for class (" + javaClass.getName() + ")"); } - Class<?> declaringClass = argslist[0].declaringClass; if (!declaringClass.isAssignableFrom(javaClass)) { throw Py.TypeError("self invalid - must implement: " + declaringClass.getName()); } - // 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 - if (!PyProxy.class.isAssignableFrom(declaringClass) - && !(self.getType() instanceof PyJavaType)) { - return PyType.fromClass(javaClass).lookup("__init__").__call__(self, args, keywords); - } int mods = declaringClass.getModifiers(); if (Modifier.isInterface(mods)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |