def _JClassNew(arg, loader=None, initialize=True): params = None if isinstance(arg, str): if arg.endswith(">"): i = arg.find("<") params = arg[i + 1:-1] arg = arg[:i] if params: params = params.split(',') else: params = [] # FIXME we can check the geneic parameters better. if loader and isinstance(arg, str): arg = _java_lang_Class.forName(arg, initialize, loader) if isinstance(arg, _jpype.PyJPClass): javaClass = arg else: javaClass = _jpype.PyJPClass(arg) if javaClass is None: raise _java_lang_RuntimeException("Java class '%s' not found" % name) # Lookup the class name name = javaClass.getCanonicalName() # See if we have an existing class in the cache if name in _JCLASSES: cls = _JCLASSES[name] else: cls = _JClassFactory(name, javaClass) if params is not None: acceptParams = len(cls.class_.getTypeParameters()) if acceptParams == 0: raise TypeError("Java class '%s' does not take parameters" % (cls.__name__)) if len(params) > 0 and len(params) != len( cls.class_.getTypeParameters()): raise TypeError("Java generic class '%s' length mismatch" % (cls.__name__)) return cls
def _JClassNew(arg, loader=None, initialize=True): if loader and isinstance(arg, str): arg = _java_lang_Class.forName(arg, initialize, loader) if isinstance(arg, _jpype.PyJPClass): javaClass = arg else: javaClass = _jpype.PyJPClass(arg) if javaClass is None: raise _java_lang_RuntimeException("Java class '%s' not found" % name) # Lookup the class name name = javaClass.getCanonicalName() # See if we have an existing class in the cache if name in _JCLASSES: return _JCLASSES[name] return _JClassFactory(name, javaClass)
def _JPrimitiveLoad(cls, boxedType): type.__setattr__(cls, '__javaclass__', _jpype.PyJPClass(cls.__name__)) type.__setattr__(cls, '_java_boxed_class', boxedType)
def _initialize(): type.__setattr__(JObject, '__javaclass__', _jpype.PyJPClass('java.lang.Object'))
def jinit(): type.__setattr__(res, '__javaclass__', _jpype.PyJPClass(jclass))
def _load(self, boxed): type.__setattr__(self, '__javaclass__', _jpype.PyJPClass(self.__name__)) type.__setattr__(self, '_java_boxed_class', boxed)
def runNoMethodCode(path): _jpype.startup(path, tuple(), False, False) cls = _jpype.PyJPClass("java.lang.String") methods = cls.getClassMethods() methods[0].__code__ # RuntimeError