On Friday, I said Next task is to repackage the htmlparser as a library, and to reimplement the HTML2XML tool itself in C++. This is now done. In the process, I also converted a SystemErrErrorHandler
class into C++ so that I could be sure that I was able to do both Java=>C++ and C++=>Java calls.
A few things learned along the way:
gcjh
./usr/share/java/libgcj.jar
to the classpath.java.lang.Object
. This means that you can’t even pass an instance to a subclass to a method that is expecting an instance of a superclass without an explicit cast.native
, compiling the Java, and generating a header.Great to see progress on this!
Does the inheritance from Object
issue only apply to the CNI boundary or does it affect Java-to-Java calls within a bunch of Java code?
What do you need to do to bootstrap garbage collection for the Java classes if your main()
is in C++?
Does the inheritance from Object issue only apply to the CNI boundary or does it affect Java-to-Java calls within a bunch of Java code?
I believe that inheritance from Object “affects” Java-to-Java calls; that being said, a type cast in C/C++ involves no code.
What do you need to do to bootstrap garbage collection for the Java classes if your main() is in C++?
I believe that this main program does everything necessary to bootstrap garbage collection; but bootstrapping is only a part of the story. For objects created in Java and passed to CNI and retained, there will need to something like a “static” variable on the Java side which collects references to these objects. These references can be removed when the destructor / finalizer is executed on the CNI side. For a DOM-like API, only the root node needs to be so anchored.