1 / 11

JACO

JACO - Java Access to C++ Objects Mark Dönszelmann and Tony Johnson 25 May 2000. JACO. 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

brackenj
Download Presentation

JACO

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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 Mark Dönszelmann, CERN and Tony Johnson, SLAC

  3. 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 What is out there ? Mark Dönszelmann, CERN and Tony Johnson, SLAC

  4. 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 Mark Dönszelmann, CERN and Tony Johnson, SLAC

  5. JACO Architecture C++ Interface Definitions (Header Files) JACO C++ Program JNIWrapperCode Java Interfaces Java Program Java Proxies LookupTable Mark Dönszelmann, CERN and Tony Johnson, SLAC

  6. 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 Mark Dönszelmann, CERN and Tony Johnson, SLAC

  7. Java Interface, Proxy and JNI Generation CPPProxy Java Class JNIC/C++ Code A Java Interface A C++ Class B Java Interface AProxy Java Class B C++ Class BProxy Java Class C C++ Class C Java Interface CProxy Java Class LookupTableC/C++ Code Hand-written Code Generated Code Mark Dönszelmann, CERN and Tony Johnson, SLAC

  8. 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 CPPProxy Java Class LookupTableC/C++ Code A C++ Class jref handle pointer B C++ Class AProxy Java Class jref handle pointer jref handle pointer Mark Dönszelmann, CERN and Tony Johnson, SLAC

  9. 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? Mark Dönszelmann, CERN and Tony Johnson, SLAC

  10. 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 Mark Dönszelmann, CERN and Tony Johnson, SLAC

  11. 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) Mark Dönszelmann, CERN and Tony Johnson, SLAC

More Related