Title: JavaClassType and JavaInstanceType missing from types
Type: rfe Severity: normal
Components: Core Versions: 2.5.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, pekka.klarck, pjenvey, zyasoft
Priority: normal Keywords:

Created on 2007-08-06.23:18:38 by pekka.klarck, last changed 2009-06-21.21:42:51 by pjenvey.

msg1809 (view) Author: Pekka Klärck (pekka.klarck) Date: 2007-08-06.23:18:38
There doesn't seem to be anything suitable in types to verify is an object a Java class or instance. As the code below demonstrates, there's ClassType and InstanceType but they only match Python classes and instances (which is probably a good thing). 

Adding something like JavaClassType and JavaInstanceType to types would probably be a good idea. Adding Jython specific types ought to be ok since there's ArrayType already.

Jython 2.2rc3 on java1.6.0
Type "copyright", "credits" or "license" for more information.
>>> import types
>>> from java.lang import String
>>> class C:
...     pass
>>> type(C) 
<type 'class'>
>>> type(C())
<type 'instance'>
>>> type(String)
<type 'javaclass'>
>>> type(String())
<type 'javainstance'>
>>> type(C) is types.ClassType
>>> type(C()) is types.InstanceType
>>> type(String) is types.ClassType
>>> type(String()) is types.InstanceType
>>> max([ type(String) is getattr(types, name) for name in dir(types) ]) 
0>>> max([ type(String()) is getattr(types, name) for name in dir(types) ]) 
>>> dir(types)
['ArrayType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MethodType', 'ModuleType', 'NoneType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType', '__doc__', 'classDictInit']

msg4830 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-21.21:42:51
I don't think these would have belonged in the types module anyway. 
types.ArrayType was a mistake that was removed in 2.5. Java classes are 
now new style types in 2.5 so this issue isn't really relevant any longer 
anyway. closing out
Date User Action Args
2009-06-21 21:42:51pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg4830
nosy: + pjenvey
2009-03-12 08:20:33zyasoftsetversions: + 2.5.1
2008-12-15 19:01:43fwierzbickisetcomponents: + Core, - None
2008-11-03 21:07:26fwierzbickisetnosy: + fwierzbicki
2008-11-03 21:07:05fwierzbickisettype: rfe
2008-09-17 18:40:28zyasoftsetnosy: + zyasoft
2007-08-06 23:18:38pekka.klarckcreate