JET: exception checking in the Java native interface

Java's type system enforces exception-checking rules that stipulate a checked exception thrown by a method must be declared in the throws clause of the method. Software written in Java often invokes native methods through the use of the Java Native Interface (JNI). Java's type system, however, cannot enforce the same exception-checking rules on Java exceptions raised in native methods. This gap makes Java software potentially buggy and often difficult to debug when an exception is raised in native code. In this paper, we propose a complete static-analysis framework called JET to extend exception-checking rules even on native code. The framework has a two-stage design where the first stage throws away a large portion of irrelevant code so that the second stage, a fine-grained analysis, can concentrate on a small set of code for accurate bug finding. This design achieves both high efficiency and accuracy. We have applied JET on a set of benchmark programs with a total over 227K lines of source code and identified 12 inconsistent native-method exception declarations.

[1]  J. Gregory Morrisett,et al.  Ilea: inter-language analysis across java and c , 2007, OOPSLA.

[2]  Goh Kondoh,et al.  Finding bugs in java native interface programs , 2008, ISSTA '08.

[3]  Mark N. Wegman,et al.  Constant propagation with conditional branches , 1985, POPL.

[4]  Sheng Liang,et al.  Java Native Interface: Programmer's Guide and Reference , 1999 .

[5]  Manuel M. T. Chakravarty,et al.  The haskell 98 foreign function interface 1 , 2003 .

[6]  Jeffrey S. Foster,et al.  Polymorphic Type Inference for the JNI , 2006, ESOP.

[7]  Riccardo Pucella,et al.  A framework for interoperability , 2001, Electron. Notes Theor. Comput. Sci..

[8]  J. Gregory Morrisett,et al.  Robusta: taming the native beast of the JVM , 2010, CCS '10.

[9]  Robert Grimm,et al.  Jinn: synthesizing dynamic bug detectors for foreign language interfaces , 2010, PLDI '10.

[10]  Andrew W. Appel,et al.  Safe Java Native Interface , 2006 .

[11]  Robert Grimm,et al.  Jeannie: granting java native interface developers their wishes , 2007, OOPSLA.

[12]  Jeffrey S. Foster,et al.  Checking type safety of foreign function calls , 2005, PLDI '05.

[13]  Thomas W. Reps,et al.  Precise interprocedural dataflow analysis via graph reachability , 1995, POPL '95.

[14]  Sorin Lerner,et al.  ESP: path-sensitive program verification in polynomial time , 2002, PLDI '02.

[15]  Matthias Blume No-Longer-Foreign: Teaching an ML compiler to speak C "natively" , 2001, Electron. Notes Theor. Comput. Sci..

[16]  Kwangkeun Yi,et al.  Interprocedural exception analysis for Java , 2001, SAC.

[17]  Robert Grimm,et al.  Debug all your code: portable mixed-environment debugging , 2009, OOPSLA 2009.

[18]  Jonathan Aldrich,et al.  Practical Exception Specifications , 2006, Advanced Topics in Exception Handling Techniques.

[19]  Gang Tan,et al.  Finding bugs in exceptional situations of JNI programs , 2009, CCS.

[20]  Martin P. Robillard,et al.  Static analysis to support the evolution of exception structure in object-oriented systems , 2003, TSEM.

[21]  George C. Necula,et al.  CIL: Intermediate Language and Tools for Analysis and Transformation of C Programs , 2002, CC.