Calling C++ DLL from Java code
1 posts in topic
Flat View  Flat View

Posted By:   Treck_Mohr
Posted On:   Friday, June 13, 2003 06:04 AM


Can anyone tell me how I can pass a Java "Document" object to a C++ "LNDocument" object using JNI?

I need to call a C++ DLL from a Java code passing a Document object as parameter.

Please reply ASAP.



Re: Calling C++ DLL from Java code

Posted By:   Laurent_Mihalkovic  
Posted On:   Saturday, June 14, 2003 11:13 AM

i am afraid you wont be able to do it. The Java Document object is implementation dependent (each XML parser has it's own private class that implements the Document interface). All these implementations end up being trees of Java objects. What you are trying to do is to change the nature of the implementation. The only thing you will be able to do is manipulate from your C++ code the Document as Java objects the same way you would do in Javal. The performance gain will probably be marginal considering how much 'Java' C++ code you will write.

Visa versa, the C++ dll expects an object that is the tree of C++ objects. This object would not be compatible, most likely, with the way Java manipulates Object derived classes.

the solution might be to create your own wrapper class (C++/JNI) that would parse the Document object using the DOM api and turn it into some other object, compatible with your C++ dll.


About | Sitemap | Contact