Java Interface To Root
tony_johnson@slac.stanford.edu
Introduction
- This is not a talk on building Java GUI’s for root
- It is a talk about a language level binding from Java to Root,
- Goal
- Make it possible to access Root objects from a Java program as if they were Java Objects
Why?
- Could be used to:
- Build Java based GUI applications with access to Root data (e.g. for online control/monitoring).
- Write data analysis in Java as an alternative to CINT
- Write data analysis in Java based scripting language (JPython, NetRexx etc.)
- Build Root interface to Java Analysis Studio
- Data format independent physics analysis tool
Why Care about Java?
Example Java Code
Problem Analysis
- Java code is compiled into machine independent bytecodes
- Converted to machine code at runtime
- No link step, so cannot link to modules in other languages
- Java uses Java Native Interface (JNI) instead
- Straightforward to call C, or Fortran
- Not so easy to transparently connect to C++ objects.
C++ + Root = Java?
- Root provides run-time information system similar to that built-in to Java
- Could be used to automate generation of glue code to tie Root Objects to C++ objects.
- Root already builds dynamic load libraries for user-defined objects
- Include C++ part of glue code in same DLL
Multiple Inheritance
- C++ supports multiple inheritance
- Java does not support multiple inheritance for classes
- Does support multiple inheritance for interfaces
- Map root classes to Java interfaces
- Automatically build implementation classes that implement all necessary interfaces
Class/Interaction Diagram
Proposed Solution
- Built Java library with binding to common root objects
- Modify rootcint to automatically generate glue code for user defined classes
Status
- “Proof of principle” done
- Library contains trivial implementations of
- TTree, TFile, TROOT, TObject
- Generated code (by hand) for user defined class
- It works!
Root Data in Java Analysis Studio
- An experiment independent HEP Analysis Application
- Runs on Windows, Unix (inc. Linux) et al
- Analysis code written in Java
- Histogram filling + manipulation package
- Access to data in
- PAW, SQL Database (Oracle, Access etc), hippo, histoscope, stdhep, objectivity, flat-file, user-defined, + ROOT
- Remote or Local access to data
- Powerful GUI
- Viewing manipulation, fitting, histograms
- Built in Editor and Compiler
- User Extensible
Unsolved Problems
- Templates
- Use solution like Java binding to objectivity
- Type mapping
- Map Root types to Java types
- Many mappings obvious
- Some may be problematic (pointers to pointers etc).
- Root (user code) can crash! (unlike Java)
- Java has garbage collection, Root doesn’t
- Anyone interested in helping?
- I like coding in Java, but I’m not a root or cint expert
References
- Write up of this talk
- http://www-sldnt.slac.stanford.edu/tony/root/
- More About
- Java - http://java.sun.com
- JPython - http://www.python.org/jpython/
- Java in HEP
- http://www-sldnt.slac.stanford.edu/java
- Java Analysis Studio
- http://www-sldnt.slac.stanford.edu/jas/