Issue1768876

classification
Title: JavaClassType and JavaInstanceType missing from types
Type: rfe Severity: normal
Components: Core Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, laukpe, zyasoft
Priority: normal Keywords:

Created on 2007-08-06.23:18:38 by laukpe, last changed 2008-12-15.19:01:43 by fwierzbicki.

Messages
msg1809 (view) Author: Pekka Laukkanen (laukpe) 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
1
>>> type(C()) is types.InstanceType
1
>>> type(String) is types.ClassType
0
>>> type(String()) is types.InstanceType
0
>>> 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) ]) 
0
>>> 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']

History
Date User Action Args
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:38laukpecreate