def _initialize(): global _java_ClassLoader _jpype.setResource('GetClassMethod', _JClassNew) # Due to bootstrapping, Object and Class must be defined first. global _java_lang_Object, _java_lang_Class _java_lang_Object = JClass("java.lang.Object") _java_lang_Class = JClass("java.lang.Class") _java_ClassLoader = JClass('java.lang.ClassLoader').getSystemClassLoader() global _java_lang_throwable, _java_lang_RuntimeException _java_lang_throwable = JClass("java.lang.Throwable") _java_lang_RuntimeException = JClass("java.lang.RuntimeException") # Preload needed classes java_lang_Boolean = JClass("java.lang.Boolean") java_lang_Long = JClass("java.lang.Long") java_lang_Double = JClass("java.lang.Double") java_lang_String = JClass("java.lang.String") global _JP_OBJECT_CLASSES _JP_OBJECT_CLASSES[bool] = java_lang_Boolean _JP_OBJECT_CLASSES[int] = java_lang_Long _JP_OBJECT_CLASSES[_long] = java_lang_Long _JP_OBJECT_CLASSES[float] = java_lang_Double _JP_OBJECT_CLASSES[str] = java_lang_String _JP_OBJECT_CLASSES[_unicode] = java_lang_String _JP_OBJECT_CLASSES[type] = _java_lang_Class _JP_OBJECT_CLASSES[_jpype.PyJPClass] = _java_lang_Class _JP_OBJECT_CLASSES[object] = _java_lang_Object
def _initialize(): global _COMPARABLE, _JAVACLASS, _JAVAOBJECT, _JAVATHROWABLE, _RUNTIMEEXCEPTION _JAVAOBJECT = JClass("java.lang.Object") _JAVACLASS = JClass("java.lang.Class") _JAVATHROWABLE = JClass("java.lang.Throwable") _RUNTIMEEXCEPTION = JClass("java.lang.RuntimeException") _jpype.setResource('JavaClass', _JavaClass) _jpype.setResource('JavaObject', _JavaObject) _jpype.setResource('GetClassMethod', _getClassFor) _jpype.setResource('SpecialConstructorKey', _SPECIAL_CONSTRUCTOR_KEY)
def _initialize(): _jpype.setResource('JavaArrayClass',_JavaArrayClass) _jpype.setResource('GetJavaArrayClassMethod',_getClassFor) registerArrayCustomizer(CharArrayCustomizer()) registerArrayCustomizer(ByteArrayCustomizer())
def _initialize(): _jpype.setResource('ProxyClass', JProxy)
def _initialize(): _jpype.setResource('WrapperClass', _JWrapper) _jpype.setResource('StringWrapperClass', JString)
# Special handling if we have 1 overload if len(overloads) == 1: ov = overloads[0] out = {} for i, p in enumerate(ov.getParameterTypes()): out['arg%d' % i] = JClass(p) out['return'] = JClass(ov.getReturnType()) return out # Otherwise, we only get the return for ov in overloads: returns.append(ov.getReturnType()) returns = set(returns) if len(returns) == 1: return {"return": JClass([i for i in returns][0])} return {} def _jmethodCode(method): def call(*args): return method.__call__(*args) return call _jpype.setResource('GetClassMethod', _JClassNew) _jpype.setResource('GetMethodDoc', _jmethodDoc) _jpype.setResource('GetMethodAnnotations', _jmethodAnnotation) _jpype.setResource('GetMethodCode', _jmethodCode)
def _initialize(): _jpype.setResource('JavaExceptionClass', JavaException)
methods.append(" * %s %s(%s)" % (returnName, ov.getName(), params)) if classmethods: out.append(" Static Methods:") out.extend(classmethods) out.append("") if methods: out.append(" Virtual Methods:") out.extend(methods) out.append("") if exceptions: out.append(" Raises:") for exc in set(exceptions): out.append(" %s: from java" % exc.getCanonicalName()) out.append("") if returns: out.append(" Returns:") words = ", ".join([str(i) for i in set(returns)]) wrapper = TextWrapper(initial_indent=' ', subsequent_indent=' ') out.extend(wrapper.wrap(words)) out.append("") return "\n".join(out) _jpype.setResource('GetClassMethod', _JClassNew) _jpype.setResource('GetMethodDoc', _jmethodDoc)
def _initialize(): _jpype.setResource('ProxyClass',JProxy)