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:
> I think I see where you're going, but it won't work. At the point where
> you "subclass or otherwise use" and then compile, the compiler will
> error out. If the compiler can't find the dependent class, the target
> class will fail to compile. I tried this.
Yea, I see that now that I've spent today trying out the test I
mentioned. But it turns out it's worse...
> Additionally, as I explain in more detail in my other response, you
> can't, in class D, try to load class C explicitly and then use it
> implicitly. In the process of loading class D, the JVM can try to load
> class C and any other class that D depends on, before it even runs one
> speck of code from class D.
So on the suggestion from JW (John Welch), I tried an experiment. He
suggested a rather devious possible solution; Create an empty stub
*.java and corresponding *.class that loads the native class:
====java
package boost;
public class A
{
static {
java.lang.System.out.println("stub/boost/A/static_init...");
java.lang.System.loadLibrary("boost_A.dll");
}
}
====
And as part of the loadLibrary() redefine the same class to the
native+JNI version (see attached test code). Hence when one uses the A
class, it can be loaded, but one is freed from having to declare all the
redundant Java members. But, and it's a big one, it seems the Java
compiler *does not load* a class in order to use it during compilation.
Rather it seems to read the .class file directly. Which seems to me a
rather serious case of false advertising from Sun.
> Unless, that is, you use class C
> explicitly, through Reflection. Which is a gross way to use a class.
Yes, that's fairly gross. Given your experiments, and mine, this only
leaves your suggestion of interfaces or of a launcher that puts in a
custom class loader.
--
-- 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/