skip to main content
10.1145/2814270.2814313acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Use at your own risk: the Java unsafe API in the wild

Published:23 October 2015Publication History

ABSTRACT

Java is a safe language. Its runtime environment provides strong safety guarantees that any Java application can rely on. Or so we think. We show that the runtime actually does not provide these guarantees---for a large fraction of today's Java code. Unbeknownst to many application developers, the Java runtime includes a "backdoor" that allows expert library and framework developers to circumvent Java's safety guarantees. This backdoor is there by design, and is well known to experts, as it enables them to write high-performance "systems-level" code in Java. For much the same reasons that safe languages are preferred over unsafe languages, these powerful---but unsafe---capabilities in Java should be restricted. They should be made safe by changing the language, the runtime system, or the libraries. At the very least, their use should be restricted. This paper is a step in that direction. We analyzed 74 GB of compiled Java code, spread over 86,479 Java archives, to determine how Java's unsafe capabilities are used in real-world libraries and applications. We found that 25% of Java bytecode archives depend on unsafe third-party Java code, and thus Java's safety guarantees cannot be trusted. We identify 14 different usage patterns of Java's unsafe capabilities, and we provide supporting evidence for why real-world code needs these capabilities. Our long-term goal is to provide a foundation for the design of new language features to regain safety in Java.

Skip Supplemental Material Section

Supplemental Material

References

  1. B. Alpern, S. Augart, S. M. Blackburn, M. Butrico, A. Cocchi, P. Cheng, J. Dolby, S. Fink, D. Grove, M. Hind, K. S. McKinley, M. Mergen, J. E. B. Moss, T. Ngo, and V. Sarkar. The Jikes Research Virtual Machine Project: Building an Opensource Research Community. IBM Syst. J., 44(2):399–417, January 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Alberto Bacchelli, Anthony Cleve, Michele Lanza, and Andrea Mocci. Extracting structured data from natural language documents with island parsing. In Proceedings of ASE 2011 (26th IEEE/ACM International Conference On Automated Software Engineering), pages 476–479, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. David F. Bacon, Perry Cheng, and V. T. Rajan. A real-time garbage collector with low overhead and consistent utilization. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’03, pages 285–298, New York, NY, USA, 2003. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Oscar Calla´u, Romain Robbes, Éric Tanter, and David Röthlisberger. How developers use the dynamic features of programming languages: The case of Smalltalk. In Proceedings of the 8th Working Conference on Mining Software Repositories, MSR ’11, pages 23–32, New York, NY, USA, 2011. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Roman Kennke Christine H. Flood. JEP 189: Shenandoah: An Ultra-Low-Pause-Time Garbage Collector. http: //openjdk.java.net/jeps/189, 2014.Google ScholarGoogle Scholar
  6. Robert Dyer, Hridesh Rajan, Hoan Anh Nguyen, and Tien N. Nguyen. Mining billions of AST nodes to study actual and potential usage of Java language features. In 36th International Conference on Software Engineering, ICSE’14, pages 779–790, June 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Daniel Frampton, Stephen M. Blackburn, Perry Cheng, Robin J. Garner, David Grove, J. Eliot B. Moss, and Sergey I. Salishev. Demystifying Magic: High-level Lowlevel Programming. In Proceedings of the 2009 ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, VEE ’09, pages 81–90, New York, NY, USA, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Milos Gligoric, Darko Marinov, and Sam Kamin. CoDeSe: Fast Deserialization via Code Generation. In Proceedings of the 2011 International Symposium on Software Testing and Analysis, ISSTA ’11, pages 298–308, New York, NY, USA, 2011. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Alessandra Gorla, Ilaria Tavecchia, Florian Gross, and Andreas Zeller. Checking app behavior against app descriptions. In Proceedings of the 36th International Conference on Software Engineering, ICSE 2014, pages 1025–1035, New York, NY, USA, 2014. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. James Gosling, Bill Joy, Guy L. Steele, Jr., Gilad Bracha, and Alex Buckley. The Java Language Specification, Java SE 7 Edition. Addison-Wesley Professional, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Mark Grechanik, Collin McMillan, Luca DeFerrari, Marco Comi, Stefano Crespi, Denys Poshyvanyk, Chen Fu, Qing Xie, and Carlo Ghezzi. An empirical investigation into a largescale Java open source code repository. In Proceedings of the 2010 ACM-IEEE International Symposium on Empirical Software Engineering and Measurement, ESEM ’10, pages 11:1–11:10, New York, NY, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Alex Holkner and James Harland. Evaluating the dynamic behaviour of Python applications. In Proceedings of the Thirty-Second Australasian Conference on Computer Science - Volume 91, ACSC ’09, pages 19–28, Darlinghurst, Australia, Australia, 2009. Australian Computer Society, Inc. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Guy Korland, Nir Shavit, and Pascal Felber. Noninvasive Concurrency with Java STM. In Communications of the ACM, Invited Review Paper, page 19 pages, 2010.Google ScholarGoogle Scholar
  14. Eugene Kuleshov. Using the ASM framework to implement common Java bytecode transformation patterns. In Conference on Aspect Oriented Software Development (AOSD): Industry Track, 2007.Google ScholarGoogle Scholar
  15. Doug Lea. JEP 193: Enhanced Volatiles. http://openjdk. java.net/jeps/193, 2014.Google ScholarGoogle Scholar
  16. Clemens Mayer, Stefan Hanenberg, Romain Robbes, Éric Tanter, and Andreas Stefik. An empirical study of the influence of static type systems on the usability of undocumented software. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’12, pages 683–702, New York, NY, USA, 2012. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Leon Moonen. Generating robust parsers using island grammars. In Proceedings of WCRE 2001 (8th Working Conference on Reverse Engineering), pages 13–22. IEEE CS, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Charles Oliver Nutter. JEP 191: Foreign Function Interface. http://openjdk.java.net/jeps/191, 2014.Google ScholarGoogle Scholar
  19. OpenJDK. Project Sumatra. http://openjdk.java.net/ projects/sumatra/, 2013.Google ScholarGoogle Scholar
  20. Luca Ponzanelli, Andrea Mocci, and Michele Lanza. StORMeD: Stack Overflow ready made data. In Proceedings of MSR 2015 (12th Working Conference on Mining Software Repositories), page to be published. ACM Press, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Mario Pukall, Christian Kästner, Walter Cazzola, Sebastian Götz, Alexander Grebhahn, Reimar Schröter, and Gunter Saake. JavAdaptor-Flexible runtime updates of Java applications. Software: Practice and Experience, 43(2):153–185, 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Xin Qi and Andrew C. Myers. Masked types for sound object initialization. In Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’09, pages 53–65, New York, NY, USA, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Gregor Richards, Christian Hammer, Brian Burg, and Jan Vitek. The eval that men do: A large-scale study of the use of eval in JavaScript applications. In Proceedings of the 25th European Conference on Object-oriented Programming, ECOOP’11, pages 52–78, Berlin, Heidelberg, 2011. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Gregor Richards, Sylvain Lebresne, Brian Burg, and Jan Vitek. An analysis of the dynamic behavior of JavaScript programs. In Proceedings of the 2010 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’10, pages 1–12, New York, NY, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. John Rose, Brian Goetz, and Guy Steele. State of the Values. http://cr.openjdk.java.net/˜jrose/values/ values-0.html, 2014.Google ScholarGoogle Scholar
  26. John R. Rose. Arrays 2.0. http://cr.openjdk.java.net/ ˜jrose/pres/201207-Arrays-2.pdf, 2012.Google ScholarGoogle Scholar
  27. John R. Rose. The isthmus in the VM. https://blogs. oracle.com/jrose/entry/the_isthmus_in_the_vm, 2014.Google ScholarGoogle Scholar
  28. Paul Sandoz. Safety not guaranteed: sun.misc.Unsafe and the quest for safe alternatives. http://cr.openjdk.java.net/˜psandoz/ dv14-uk-paul-sandoz-unsafe-the-situation.pdf, 2014. Oracle Inc. {Online; accessed 29-January-2015}.Google ScholarGoogle Scholar
  29. Paul Sandoz. Personal communication, 2015.Google ScholarGoogle Scholar
  30. Fridtjof Siebert. Eliminating external fragmentation in a nonmoving garbage collector for Java. In Proceedings of the 2000 International Conference on Compilers, Architecture, and Synthesis for Embedded Systems, CASES ’00, pages 9– 17, New York, NY, USA, 2000. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Use at your own risk: the Java unsafe API in the wild

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      OOPSLA 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
      October 2015
      953 pages
      ISBN:9781450336895
      DOI:10.1145/2814270
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 50, Issue 10
        OOPSLA '15
        October 2015
        953 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2858965
        • Editor:
        • Andy Gill
        Issue’s Table of Contents

      Copyright © 2015 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 23 October 2015

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate268of1,244submissions,22%

      Upcoming Conference

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader