This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

One pattern of ensuring that a Jython base class implemented in Java can call an @ExposedMethod that has potentially been overridden in Python is to have a pair of methods on the base class:

Then the derived class overrides the super class method in the standard fashion, i.e.

This is done the use of the rest directive in the derived template - e.g. a typical implementation is:

   1   base_class: PyDefaultDict
   2   want_dict: true
   3   ctr:
   4   incl: dict
   5   rest:
   6       public PyObject __missing__(PyObject key) {
   7           PyType self_type=getType();
   8           PyObject impl=self_type.lookup("__missing__");
   9           if (impl!=null) {
  10               return impl.__get__(this,self_type).__call__(key);
  11           }
  12           return super.__missing__(key);
  13       }

So the base class now defines an @ExposedMethod:

   1      @ExposedMethod
   2      final PyObject defaultdict___missing__(PyObject key) {
   3          if (defaultFactory == Py.None) {
   4              throw Py.KeyError(key);
   5          }
   6          return defaultFactory.__call__();
   7      }

and the public method calls the @ExposedMethod directly like:

   1      public PyObject __missing__(PyObject key) {
   2          return defaultdict___missing__(key);
   3      }

So if any method in the base class calls the public method it will result in standard Java dynamic method dispatch to a Py*Derived class if the instance in question has derived from the base class and that will call the overridden python method if it exists or default back to the base classes implementation via super.


2026-02-14 16:30