Re: [Py4j-users] How to access "class"
Status: Beta
Brought to you by:
barthe
From: Barthelemy D. <bar...@in...> - 2015-07-16 08:54:16
|
You can always use reflection: aClass = gateway.jvm.Class.forName("java.lang.Integer") But I agree that .class would be handy for JavaClass objects on the Python side. Please do not hesitate to fill a feature request ( https://github.com/bartdag/py4j/issues/new) Barthelemy On Wed, Jul 15, 2015 at 8:18 PM Peter A <pet...@gm...> wrote: > Hi, > > I need to access the static member "class" in a Java object. For example > in Java the code would look something like: > > if( object.getClass() == Object.class ) { > // do something > } > > Now when I try that in py4j I run into issues that "class" is a protected > keyword. So the following causes it to crash: > > gateway.jvm.Object.class > > On the other hand gateway.jvm.Object.variable works just fine, assuming variable is a static member variable of Object. > > My current hack around this issue is to create a new instance of the object then call object.getClass() in python. > > Is there anyway to access "class" in python? > > - Peter > > > -- > "Now, now my good man, this is no time for making enemies." — Voltaire > (1694-1778), on his deathbed in response to a priest asking that he > renounce Satan. > > ------------------------------------------------------------------------------ > Don't Limit Your Business. Reach for the Cloud. > GigeNET's Cloud Solutions provide you with the tools and support that > you need to offload your IT needs and focus on growing your business. > Configured For All Businesses. Start Your Cloud Today. > https://www.gigenetcloud.com/ > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users > |