Download No Slide Title

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
JACO
JACO - Java Access to C++ Objects
Mark Dönszelmann and Tony Johnson
25 May 2000
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
24 May 2017
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...
Mark Dönszelmann, CERN and Tony Johnson, SLAC
 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
24 May 2017
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
24 May 2017
JACO Architecture
C++ Interface
Definitions
(Header Files)
C++ Program
JACO
JNI
Wrapper
Code
Lookup
Table
Mark Dönszelmann, CERN and Tony Johnson, SLAC
Java Interfaces
Java Proxies
24 May 2017
Java Program
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
24 May 2017
Java Interface, Proxy and JNI Generation
CPPProxy
A
A
Java
Class
Java
Interface
C++
Class
B
AProxy
B
Java
Interface
Java
Class
C++
Class
JNI
C/C++
Code
BProxy
C
Java
Class
C
C++
Class
Java
Interface
CProxy
Java
Class
Hand-written Code
Generated Code
Mark Dönszelmann, CERN and Tony Johnson, SLAC
Lookup
Table
C/C++
Code
24 May 2017
Object to Object mapping using Lookup Table
Lookup
Table
CPPProxy
Java
Class
A
C++
Class
C/C++
Code
AProxy
Java
Class
jref
handle pointer
jref
handle pointer
jref
handle pointer
 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
Mark Dönszelmann, CERN and Tony Johnson, SLAC
24 May 2017
B
C++
Class
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
24 May 2017
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
24 May 2017
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
24 May 2017