Here is what I am using for performing an is_java() test:

def is_java(obj):
    if is_proxy(obj):
        return True
        return isinstance(obj, Object)

def is_proxy(obj):
        return hasattr(obj, '_getPyInstance')
    except AttributeError:
        return False

You'll want to import java.lang.Object at the top of your module.

Hope this helps...

Josh Juneau
Twitter ID:  javajuneau

On Tue, Mar 9, 2010 at 8:55 AM, Thanos Tsounis <> wrote:

I have been asked to maintain some java code that was developed on top of Jython 2.1. When testing existing code against Jython 2.5.1 I've noticed that the PyJavaInstance class is no longer present in the Jython API and therefore get a compilation error. Has it been replaced with another class? I tried to find one but with no success. More explicitly, I would like to check if a PyObject is a representation of a Java object. Consider the following code:

somePyObject instanceof PyJavaInstance

Is there an easy way to obtain the same behaviour with Jython 2.5.1? Thanks!

Kind regards,
Thanos Tsounis
Thanos Tsounis
European Space Astronomy Centre (ESAC)
Research and Scientific Support Department
Herschel Science Centre - Data Processing
P.O. Box 78
28691 Villanueva de la Caņada
phone: +34 918131 178 
This message and any attachments are intended for the use of the addressee or addressees only.

The unauthorised disclosure, use, dissemination or copying (either in whole or in part) of its content is prohibited.

If you received this message in error, please delete it from your system and notify the sender.

E-mails can be altered and their integrity cannot be guaranteed.

ESA shall not be liable for any e-mail if modified.

Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
Jython-users mailing list