[Jython-checkins] jython: Fix failure in test_java_subclasses.

jeff.allen jython-checkins at python.org
Fri Dec 28 10:42:05 EST 2018


https://hg.python.org/jython/rev/8c2c15c2aa62
changeset:   8209:8c2c15c2aa62
user:        Jeff Allen <ja.py at farowl.co.uk>
date:        Fri Dec 28 11:48:19 2018 +0000
summary:
  Fix failure in test_java_subclasses.

Previous change to newInstance() in PyObject raises different exceptions
to signify absence of a default constructor. Failed in
test_java_subclasses.AutoSuperTest.test_no_default_constructor.

files:
  src/org/python/core/PyObject.java |  6 ++----
  1 files changed, 2 insertions(+), 4 deletions(-)


diff --git a/src/org/python/core/PyObject.java b/src/org/python/core/PyObject.java
--- a/src/org/python/core/PyObject.java
+++ b/src/org/python/core/PyObject.java
@@ -189,15 +189,13 @@
         try {
             try {
                 proxy = (PyProxy) c.getDeclaredConstructor().newInstance();
-            } catch (java.lang.InstantiationException e) {
+            } catch (InstantiationException | NoSuchMethodException e) {
                 Class<?> sup = c.getSuperclass();
-                String msg = "Default constructor failed for Java superclass";
+                String msg = "Default constructor failed/missing for Java superclass";
                 if (sup != null) {
                     msg += " " + sup.getName();
                 }
                 throw Py.TypeError(msg);
-            } catch (NoSuchMethodError nsme) {
-                throw Py.TypeError("constructor requires arguments");
             } catch (Exception exc) {
                 throw Py.JavaError(exc);
             }

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list