🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15310

Re: Can Java create and access a C++ object thru JNI?

#15310
From: Steve Schafer (TeamB)
Date: Thu, 24 Jun 1999 00:00
29 lines
1603 bytes
On Wed, 23 Jun 1999 23:19:47 -0500, Mike Schoonover
<mike@folsomvillage.com> wrote:

>The JNI specs are pretty clear about the ability of the native code to
>create and access Java objects, but can the Java code create and access
>C++ native objects?

Not directly. You have to provide native methods (written in C++, for
example) that do the work.

>Can I call a C++ function that will create the object and pass a pointer
>back to the Java side?  

Yes, but it has to be in the form of a native method, and conform to
the JNI naming conventions, etc.

>If so, where does this object exist - within the scope of the Java
>program or in some etheral memory space?

All DLLs loaded by a process (java.exe in this case) are loaded into
that process's address space. So, any object created via a native
method exists within the context of the process that invoked the
native method.

>Can Java call any function defined as part of a C++ class?

Not without wrapping the functions in native methods.

-Steve
Technical Details
Message-ID: <3784c0a1.40841361@90.0.0.40>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3771B1E3.92A16A3@folsomvillage.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,fa9bab9ae892721f
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: Can Java create and access a C++ object thru JNI?
Date: 1999/06/24
Message-ID: <3784c0a1.40841361@90.0.0.40>
X-Deja-AN: 493239769
Content-Transfer-Encoding: 7bit
References: <3771B1E3.92A16A3@folsomvillage.com>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language