Top Inners Fields Constructors Methods
org.python.core

public Class PyJavaType

extends PyType
Class Inheritance
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .InvalidClassException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamClass, .OutputStream, .Serializable, java.lang.invoke.MethodHandle, .MethodHandles, .MethodHandles.Lookup, .MethodType, java.lang.reflect.Constructor, .Field, .Member, .Method, .Modifier, java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .Enumeration, .EventListener, .HashMap, .HashSet, .Iterator, .LinkedHashSet, .LinkedList, .List, .Locale, .Map, .Queue, .Set, .Stack, org.python.core.util.StringUtil, org.python.util.Generic

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
private static class
private static class
private static class
private abstract static class
pack-priv static class
PyJavaType.Constant

Constant PyJavaTypes used frequently.

private static class
private class
private static class
PyJavaType.Modular

A class containing a test that a given class is accessible to Jython, in the Modular Java sense.

Field Summary

Modifier and TypeField and Description
private static final Set<String>
BAD_AWT_METHODS

Deprecated methods in java.awt.* that have bean property equivalents we prefer.

private Set<PyJavaType>
conflicted

Other Java classes this type has MRO conflicts with.

private static final String
private static final int
private static final Set<Class<?>>
private Set<String>
modified

The names of methods that have been added to this class.

private static final Class<?>[]
Inherited from org.python.core.PyType:
basebasesbuiltindicthasDeletehasGethasSetinstantiablemronameneeds_finalizerneeds_userdictneeds_weakrefTYPEunderlying_class

Constructor Summary

AccessConstructor and Description
public
PyJavaType()

Create a Python type for a Java class that does not descend from PyObject.

pack-priv
PyJavaType(Class<?>
Java class for which this is a Python type.
c
)

Create a Python type for a Java class that is not exposed, but may descend from PyObject.

pack-priv
PyJavaType(Class<?>
Java class for which this is a Python type.
c
,
boolean
true iff the class descends from PyObject
isPyObject
)

Create a Python type object for a given Java class that is not an exposed type, but may still be a PyObject.

pack-priv
PyJavaType(boolean ignored)

Create the PyJavaType instance (proxy) for java.lang.Class itself.

Method Summary

Modifier and TypeMethod and Description
private void
addBeanEvents(Map<String, PyBeanEvent<?>> events)

Add the methods corresponding to a each discovered JavaBean event.

private void
addBeanProperties(Map<String, PyBeanProperty> props)

Add the methods corresponding to a each discovered JavaBean property.

private void
addCollectionProxies(Class<?>
the target class
forClass
)

Add Python methods corresponding to the API of common Java collection types.

private void
addConstructors(Class<?> forClass, Constructor<?>[] constructors)

Process the given constructors defined on the target class (the fromClass).

private void
addFields(Class<?> baseClass, Field[] fields)

Process the given fields defined on the target class (the fromClass).

private void
addInheritedMethods(List<PyReflectedFunction>
to which reflected functions are added for further processing
reflectedFuncs
,
Method[]
of the target class
methods
)

Add descriptors to this type's dictionary (__dict__) for methods inherited from ancestor classes.

private void
addMethods(Class<?>
ancestor of the target class
baseClass
,
List<PyReflectedFunction>
to which reflected functions are added for further processing
reflectedFuncs
,
Map<String, PyBeanProperty>
to which Java Bean properties are added for further processing
props
,
Map<String, PyBeanEvent<?>>
to which Java Bean events are added for further processing
events
,
Method[]
of the target class
methods
)

Add descriptors to this type's dictionary (__dict__) for methods defined on the target class itself (the fromClass), where not inherited.

private void
addMethodsForCloneable()

Add special methods when this PyJavaType represents interface Cloneable.

private void
addMethodsForComparable()

Add special methods when this PyJavaType represents interface Comparable.

private void
addMethodsForObject()

Add special methods when this PyJavaType represents Object.

private void
addMethodsForSerializable()

Add special methods when this PyJavaType represents interface Serializable.

private static Map<Class<?>, PyBuiltinMethod[]>

Returns:

A map whose key is the base Java collection types and whose entry is a list of injected methods.
buildCollectionProxies
()

Build a map of common Java collection base types (Map, Iterable, etc) that need to be injected with Python's equivalent types' builtin methods (__len__, __iter__, iteritems, etc).

private static Map<Class<?>, PyBuiltinMethod[]>
private void
checkBeanMethod(Map<String, PyBeanProperty>
in which to store properties we discover
props
,
Map<String, PyBeanEvent<?>>
in which to store events we discover
events
,
Method
under consideration
meth
)

Consider whether the given method of the current class indicates the existence of a JavaBean property or event.

private static <T> T
cloneX(T x)

private static boolean

Returns:

true if the member is declared here on the fromClass
declaredHere
(Class<?>
super-class of the target of this PyJavaType, or null.
baseClass
,
Member
of the forClass that might be exposed on this PyJavaType
member
)

True iff the target of this PyJavaType's target (the forClass) declares the given member of this target.

private static Map<Class<?>, PyBuiltinMethod[]>
private static Method
getDescrMethod(Class<?> c, String name, Class<?>... parmtypes)

private static Map<Class<?>, PyBuiltinMethod[]>
pack-priv void
handleMroError(PyType.MROMergeState[]
partially processed algorithm state
toMerge
,
List<PyObject>
output MRO (incomplete)
mro
)

Overrides org.python.core.PyType.handleMroError.

This method is called when the computeMro(MROMergeState[], List) reaches an impasse as far as its official algorithm is concerned, with the partial MRO and current state of the working lists at the point the problem is detected.

private void
handleSuperMethodArgCollisions(Class<?>
of which the methods are currently being defined
forClass
)

Methods implemented in private, protected or package protected classes, and classes not exported by their module, may not be called directly through reflection.

private static boolean
ignore(Method meth)

Recognise certain methods as ignored (tagged as throws PyIgnoreMethodTag).

protected void
init(Set<PyJavaType>
collects PyJavaTypes that need further processing
needsInners
)

Overrides org.python.core.PyType.init.

Complete the initialisation of the PyType for non-exposed PyObject or any other Java class for which we need a Python type object.

pack-priv static boolean

Returns:

true iff accessible to Jython
isAccessibleClass
(Class<?>
the class
c
)

Test whether a given class is accessible, meaning it is in a package exported to Jython and public (or we are ignoring accessibility).

private void
mergeMethods(Class<?>
class or interface
parent
)

From a given class that is an ancestor of the Java class for which this PyJavaType is being initialised, or that is an interface implemented by it or an ancestor, process each method in the ancestor so that, if the class or interface that declares the method is public, that method becomes a method of the Python type we are constructing.

private static String
public boolean
public int
traverse(Visitproc visit, Object arg)

Overrides org.python.core.PyType.traverse.

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

pack-priv void
pack-priv void
protected boolean
useMetatypeFirst(PyObject attr)

Overrides org.python.core.PyType.useMetatypeFirst.

Returns true if the given attribute retrieved from an object's metatype should be used before looking for the object on the actual object.

public static PyObject
Inherited from org.python.core.PyType:
__call____delattr____findattr_ex____rawdir____setattr____tojava__addBuilderaddMethodcheckDelattrcompatibleForAssignmentcomputeLinearMrocomputeMrocomputeMrodelBasesdelDictdelModuleensureBootstrappedensureDocensureModulefastGetDictfastGetNamefromClassfromClassgetAbstractmethodsgetBasegetBasesgetDictgetDocgetFlagsgetModulegetMrogetNamegetNumSlotsgetProxyAttrgetProxyTypegetStaticgetUsesObjectGetattributehasProxyAttrinstDictinvalidateMethodCacheisAbstractisSubTypelookuplookup_mrolookup_wherelookup_where_mroneedsFinalizernewTypenoAttributeErrorpostDelattrpostSetattrpyDelNamepyGetNamepySetNameremoveMethodrichComparesetAbstractmethodssetBasessetDictsetNamesetProxyAttrsetUsesObjectGetattributesuper_lookuptoStringtype___call__type___delattr__type___eq__type___findattr_ex__type___ge__type___getattribute__type___gt__type___init__type___instancecheck__type___le__type___lt__type___ne__type___new__type___setattr__type___subclasscheck__type___subclasses__type_mrotype_toStringwriteReplace