Re: [Java] Function Binding Redux (long post)

Rene Rivera <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Organization Redshift Software, Inc.
Message-ID <[email protected]>
John Moeller wrote:

> 2b. Generate the same, except directly in bytecode, and put the result 
> in a class file.
> 
> Same advantages as (2a), except without the compile time, but the 
> drawback that we'd have to maintain bytecode generation (probably not a 
> big deal, though).

There are bytecode generation libraries out there that would make this 
even less of a big deal.

> 3.  Do the same as (2b), but load the class at runtime with a special 
> class loader.  This is (from what I understand) the crux of Rene's idea, 
> and the most initially appealing.

Yes, that's what I meant. But using a class loader is only an idea. More 
briefly I would want to create the Java "code" and have it bound to the 
native code when the library is loaded. It would work something like:

When the library is loaded (System.loadLibrary) during the JNI_OnLoad 
<http://tinyurl.com/2dmsh8>:

   * It creates bytecode for the classes in the binding and loads it 
into the JVM with DefineClass <http://tinyurl.com/2bjzmz>.
   * It binds the Java native methods to the C++ functions with 
RegisterNatives <http://tinyurl.com/2bjzmz>.

That allows for the distribution of only the shared library (although it 
might be possible to work something equivalent for the embedded use 
case). All users need to do is call System.loadLibrary. What I don't 
know is how the Java compiler could be made to work without actual 
*.class files.

> I've been trying to think of ways to make this work, but there are some 
> major compromises:

Hm, I think your three points aren't relevant to what I just mentioned 
above so I'm refraining from comment until proven otherwise ;-)



-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.