From: <cg...@us...> - 2008-11-28 08:12:34
|
Revision: 5650 http://jython.svn.sourceforge.net/jython/?rev=5650&view=rev Author: cgroves Date: 2008-11-28 08:12:30 +0000 (Fri, 28 Nov 2008) Log Message: ----------- Check for abstract classes and interfaces before attempting to auto-create a proxy Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/PyObject.java Modified: branches/newstyle-java-types/src/org/python/core/PyObject.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PyObject.java 2008-11-27 22:17:41 UTC (rev 5649) +++ branches/newstyle-java-types/src/org/python/core/PyObject.java 2008-11-28 08:12:30 UTC (rev 5650) @@ -2,6 +2,7 @@ package org.python.core; import java.io.Serializable; +import java.lang.reflect.Modifier; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Iterator; @@ -109,10 +110,16 @@ * by our __init__. */ protected void proxyInit() { - if (javaProxy != null || getType().getProxyType() == null) { + Class<?> c = getType().getProxyType(); + if (javaProxy != null || c == null) { return; } - Class<?> c = getType().getProxyType(); + int mods = c.getModifiers(); + if (Modifier.isInterface(mods)) { + throw Py.TypeError("can't instantiate interface (" + c.getName() + ")"); + } else if (Modifier.isAbstract(mods)) { + throw Py.TypeError("can't instantiate abstract class (" + c.getName() + ")"); + } PyProxy proxy; ThreadState ts = Py.getThreadState(); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |