JNI Light: An Operational Model for the Core JNI

  • Gang Tan
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6461)


Through foreign function interfaces (FFIs), software components in different programming languages interact with each other in the same address space. Recent years have witnessed a number of systems that analyze FFIs for safety and reliability. However, lack of formal specifications of FFIs hampers progress in this endeavor. We present a formal operational model, JNI Light (JNIL), for a subset of a widely used FFI—the Java Native Interface (JNI). JNIL focuses on the core issues when a high-level garbage-collected language interacts with a low-level language. It proposes abstractions for handling a shared heap, crosslanguage method calls, cross-language exception handling, and garbage collection. JNIL can directly serve as a formal basis for JNI tools and systems. The abstractions in JNIL are also useful when modeling other FFIs, such as the Python/C interface and the OCaml/C interface.


Garbage Collection Calling Convention Native Code Java Object Native Frame 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Furr, M., Foster, J.S.: Polymorphic type inference for the JNI. In: Sestoft, P. (ed.) ESOP 2006. LNCS, vol. 3924, pp. 309–324. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  2. 2.
    Tan, G., Appel, A.W., Chakradhar, S., Raghunathan, A., Ravi, S., Wang, D.: Safe Java Native Interface. In: Proceedings of IEEE International Symposium on Secure Software Engineering, pp. 97–106 (2006)Google Scholar
  3. 3.
    Hirzel, M., Grimm, R.: Jeannie: Granting Java Native Interface developers their wishes. In: OOPSLA, pp. 19–38 (2007)Google Scholar
  4. 4.
    Tan, G., Morrisett, G.: ILEA: Inter-language analysis across Java and C. In: OOPSLA, pp. 39–56 (2007)Google Scholar
  5. 5.
    Tan, G., Croft, J.: An empirical security study of the native code in the JDK. In: 17th Usenix Security Symposium, pp. 365–377 (2008)Google Scholar
  6. 6.
    Kondoh, G., Onodera, T.: Finding bugs in Java Native Interface programs. In: ISSTA 2008: Proceedings of the 2008 International Symposium on Software Testing and Analysis, pp. 109–118. ACM, New York (2008)CrossRefGoogle Scholar
  7. 7.
    Li, S., Tan, G.: Finding bugs in exceptional situations of JNI programs. In: Proceedings of the 16th ACM conference on Computer and communications security (CCS), pp. 442–452 (2009)Google Scholar
  8. 8.
    Lee, B., Hirzel, M., Grimm, R., Wiedermann, B., McKinley, K.S.: Jinn: Synthesizing a dynamic bug detector for foreign language interfaces. In: ACM Conference on Programming Language Design and Implementation (PLDI), pp. 36–49 (2010)Google Scholar
  9. 9.
    Matthews, J., Findler, R.B.: Operational semantics for multi-language programs. In: 34th ACM Symposium on Principles of Programming Languages (POPL), pp. 3–10 (2007)Google Scholar
  10. 10.
    Tan, G.: JNI Light: An operational model for the core JNI. Technical report, Lehigh University (March 2010),
  11. 11.
    Liang, S.: Java Native Interface: Programmer’s Guide and Reference. Addison-Wesley Longman Publishing Co., Inc., Amsterdam (1999)Google Scholar
  12. 12.
    Lindholm, T., Yellin, F.: The Java Virtual Machine Specification, 2nd edn. Addison-Wesley, Reading (1999)Google Scholar
  13. 13.
    Drossopoulou, S., Eisenbach, S.: Describing the semantics of Java and proving type soundness. In: Alves-Foss, J. (ed.) Formal Syntax and Semantics of Java. LNCS, vol. 1523, pp. 41–82. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  14. 14.
    Flatt, M., Krishnamurthi, S., Felleisen, M.: A programmer’s reduction semantics for classes and mixins. In: Alves-Foss, J. (ed.) Formal Syntax and Semantics of Java. LNCS, vol. 1523, pp. 241–269. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  15. 15.
    Freund, S.N., Mitchell, J.C.: A type system for the Java bytecode language and verifier. Journal of Automated Reasoning 30(3-4), 271–321 (2003)CrossRefzbMATHGoogle Scholar
  16. 16.
    Klein, G., Nipkow, T.: A machine-checked model for a Java-like language, virtual machine, and compiler. ACM Transactions on Programming Languages and Systems 28(4), 619–695 (2006)CrossRefGoogle Scholar
  17. 17.
    Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems 23(3), 396–450 (2001)CrossRefGoogle Scholar
  18. 18.
    Petri, G., Huisman, M.: BicolanoMT: a formalization of multi-threaded Java at bytecode level. In: Bytecode 2008 (2008)Google Scholar
  19. 19.
    Bacon, D.F., Cheng, P., Rajan, V.T.: A unified theory of garbage collection. In: OOPSLA, pp. 50–68. ACM Press, New York (2004)Google Scholar
  20. 20.
    Necula, G.C., McPeak, S., Weimer, W.: CCured: type-safe retrofitting of legacy code. In: 29th ACM Symposium on Principles of Programming Languages (POPL), pp. 128–139 (2002)Google Scholar
  21. 21.
    Leroy, X., Blazy, S.: Formal verification of a C-like memory model and its uses for verifying program transformations. Journal of Autom. Reasoning 41(1), 1–31 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Morrisett, G., Crary, K., Glew, N., Walker, D.: Stack-based typed assembly language. Journal of Functional Programming 12(1), 43–88 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Furr, M., Foster, J.S.: Checking type safety of foreign function calls. ACM Transactions on Programming Languages and Systems 30(4), 1–63 (2008)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Gang Tan
    • 1
  1. 1.Computer Science and EngineeringLehigh UniversityUSA

Personalised recommendations