> -----Original Message-----
> From: Andi Vajda [mailto:va...@apache.org]
> Sent: den 30 augusti 2013 16:11
> To: Toivo Henningsson
> Cc: pylucene-dev@lucene.apache.org
> Subject: Re: JCC for Java -> C++ and initializeClass
>
>
> On Aug 30, 2013, at 15:55, Toivo Henningsson
> <toivo.hennings...@modelon.com> wrote:
>
> >> -----Original Message-----
> >> From: Andi Vajda [mailto:va...@apache.org]
> >> Sent: den 30 augusti 2013 15:13
> >> To: pylucene-dev@lucene.apache.org
> >> Subject: Re: JCC for Java -> C++ and initializeClass
> >>
> >>
> >> On Fri, 30 Aug 2013, Toivo Henningsson wrote:
> >>
> >>> I've been using JCC successfully for a number of months for wrapping
> >>> Java
> >> code to use in a C++ program.
> >>> My question is about initializeClass. Right now, I'm calling
> >>>
> >>> mypackage::MyClass::initializeClass(false);
> >>>
> >>> on some of my classes during initialization (in the C++ code), as I
> >>> got the
> >> impression that I am supposed to do. But it doesn't seem to make a
> >> difference if I remove those calls. Is it still required, and if it is, 
> >> for what?
> >>
> >> initializeClass() is called for you, lazily, when the C++ wrapper
> >> class constructor is called for the first time.
> >> You can see this in the generated .h files.
> >
> > Ok, great!
> >
> > So it's only if I need to use something inside of a class before creating 
> > any
> instances that I need to call initializeClass()?
>
> Thinking about this, from C++, there may be holes. From Python, when import
> on the Python wrapper is called, initializeClass() ends up being called too.

I looked a bit at the source (generated and otherwise), and my conclusion was 
that
 * initializeClass() looks up class, method, field ids and static fields ==> it 
needs to be called before
   * calling methods on the class (also static ones)
   * accessing fields in the class
 * intializeClass() is called when
   * a wrapper instance is created
   * a static method is called
I think that this leaves only the case when accessing a static field, which 
indeed is a hole.

My only question now is: Do you plan to keep the other three cases (calling 
static/nonstatic methods, access to instance fields) safe when it comes to 
initializeClass?
Then I can write my code under that assumption.

 / Toivo

Toivo Henningsson, PhD
Software Engineer
Simulation & Optimization R&D

Phone direct: +46 46 286 22 11
Email: toivo.hennings...@modelon.com



Modelon AB
Ideon Science Park
SE-223 70 Lund, Sweden Phone: +46 46 286 2200
Fax: +46 46 286 2201
Web: http://www.modelon.com
This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged. If you are not one of the named recipients or have received this 
email in error, (i) you should not read, disclose, or copy it, (ii) please 
notify sender of your receipt by reply email and delete this email and all 
attachments, (iii) Modelon does not accept or assume any liability or 
responsibility for any use of or reliance on this email.

Reply via email to