Presentation is loading. Please wait.

Presentation is loading. Please wait.

JACO JACO - Java Access to C++ Objects Mark Dönszelmann and Tony Johnson 25 May 2000.

Similar presentations


Presentation on theme: "JACO JACO - Java Access to C++ Objects Mark Dönszelmann and Tony Johnson 25 May 2000."— Presentation transcript:

1 JACO JACO - Java Access to C++ Objects Mark Dönszelmann and Tony Johnson 25 May 2000

2 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC Goals and limitations Provide automatic Java proxies and JNI code to talk to C++ objects Provide a one to one mapping between Java and C++ objects Use C++ Header files as input Support multiple inheritance Support primitives, simple object references and pointers No access to private C++ member variables

3 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC What is out there ? SWIG Simple Wrapper and Interface Generator University of Utah, OpenSource Provides access from PERL, Tcl, Java and others to C/C++ TypeMaps to “convert” parameters and return values Not a full C/C++ parser Written in C++, being moved to C (?) No object to object mapping Project seems relatively abandoned... J2CPP Proxy class and JNI generator IBM, part of VAJ Enterprise Edition Standard mappings to “convert” parameters and return values Object to object mapping Good Example for JACO Relatively expensive No way to extend Not a full C/C++ parser No Multiple Inheritance

4 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC JACO Written in Java, with a full C++ parser (templates, namespaces,...) Part of FreeHep, OpenSource, as a separate jar file Input: C++ header files Output for every C++ class: Java Interfaces, allowing multiple inheritance Java Proxy implementing the corresponding Java Interface, inheriting from a standard CPPProxy and for all C++ classes: JNI Code to glue the Java Proxies to the C++ classes A two-way lookup table to provide Object to Object mapping

5 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC JACO Architecture Java Program JNI Wrapper Code JACO Java Proxies C++ Program C++ Interface Definitions (Header Files) Lookup Table Java Interfaces

6 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC C++ Parser and RTTI system Parser for C++ Header Files JavaCC - Parser Generator, free tool from Sun and Metamata Input:  a C++ Grammar file (CPPParser.jj)  some Java classes (ClassScope, SymTab,...) Output:  CPPParser.java and CPPParserTokenManager.java RTTI System Some classes to keep:  Class, Method and Parameter definitions make: System to parse C++ header files and provide enough information to generate Java Interfaces, Java Proxies and JNI code

7 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC Java Interface, Proxy and JNI Generation A Java Interface B Java Interface C Java Interface AProxy Java Class BProxy Java Class CProxy Java Class JNI C/C++ Code A C++ Class B C++ Class C C++ Class CPPProxy Java Class Lookup Table C/C++ Code Generated Code Hand-written Code

8 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC Object to Object mapping using Lookup Table Calls from Java to C++ Lookup Java object -> handle -> pointer -> C++ object C++ method returns New Object Lookup C++ pointer, not found, create Java object, add to table C++ method returns Existing Object Lookup C++ pointer -> handle -> jref -> Java object AProxy Java Class A C++ Class CPPProxy Java Class Lookup Table C/C++ Code pointerhandle pointerhandle pointerhandle B C++ Class jref

9 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC Tests See if we can generate the AIDA Java and JNI code, and compare this with the hand-written code. Generate the other AIDA parts Generate the C++ HepRep interfaces of which the Java version is currently being integrated into WIRED Access to GEANT4 for visualization ? Access to Objectivity ? Access to ROOT I/O?

10 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC Problems Mapping of some standard classes to some Java standard classes (e.g. String) Mapping of C++ collection classes to Java collection classes Complex pointers and references Instantiations of Templates Definitions of Templates Operator overloading Object creation and lifetime

11 1 December 2015Mark Dönszelmann, CERN and Tony Johnson, SLAC Conclusions The C++ parser and RTTI are ready, though they may have to be extended extract and keep more information, to use for the generators The Java Interface and Proxy generators are ready, but may need some tweaking once the JNI generator is in place Practical hand-coded JNI examples (AIDA, CHORUS, ATLAS and GEANT4) are available The tables for Object to Object mapping are ready The JNI generator has to be written (Tony with help from me and some C++ experts)


Download ppt "JACO JACO - Java Access to C++ Objects Mark Dönszelmann and Tony Johnson 25 May 2000."

Similar presentations


Ads by Google