Skip to main content

Efficient Inference of Static Types for Java Bytecode

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1824))

Abstract

In this paper, we present an efficient and practical algorithm for inferring static types for local variables in a 3-address, stackless, representation of Java bytecode.

By decoupling the type inference problem from the low level bytecode representation, and abstracting it into a constraint system, we show that there exists verifiable bytecode that cannot be statically typed. Further, we show that, without transforming the program, the static typing problem is NP-hard. In order to get a practical approach we have developed an algorithm that works efficiently for the usual cases and then applies efficient program transformations to simplify the hard cases.

We have implemented this algorithm in the Soot framework. Our experimental results show that all of the 17,000 methods used in our tests were successfully typed, 99.8% of those required only the first stage, 0.2% required the second stage, and no methods required the third stage.

This work has been supported in part by FCAR and NSERC.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Agesen, O.: Constraint-based type inference and parametric polymorphism. In: Le Charlier, B. (ed.) SAS 1994. LNCS, vol. 864, pp. 78–100. Springer, Heidelberg (1994)

    Google Scholar 

  2. Agesen, O.: The Cartesian product algorithm: Simple and precise type inference of parametric polymorphism. In: Olthoff, W. (ed.) ECOOP 1995. LNCS, vol. 952, pp. 2–26. Springer, Heidelberg (1995)

    Google Scholar 

  3. Ahpah Software Inc., http://zeus.he.net/~pah/products.html

  4. Bacon, D.F., Sweeney, P.F.: Fast static analysis of C++ virtual function calls. In: Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM SIGPLAN Notices, vol. 31, pp. 324–341. ACM Press, New York (1996)

    Google Scholar 

  5. Bothner, P.: Kawa - compiling dynamic languages to the Java VM (1998)

    Google Scholar 

  6. Cormen, T.H., Leiserson, C.E., Rivest, R.L.: Introduction to Algorithms. MIT Press; McGraw-Hill Book, Cambridge New York (1990)

    MATH  Google Scholar 

  7. Dean, J., Grove, D., Chambers, C.: Optimization of object-oriented programs using static class hierarchy analysis. In: Olthoff, W. (ed.) ECOOP 1995. LNCS, vol. 952, pp. 77–101. Springer, Heidelberg (1995)

    Google Scholar 

  8. Fernandez, M.F.: Simple and effective link-time optimization of Modula-3 programs. In: Proceedings of the ACM SIGPLAN 1995 Conference on Programming Language Design and Implementation (PLDI), La Jolla, California, June 1995, pp. 103–115 (1995)

    Google Scholar 

  9. Gagnon, E.M., Hendren, L.J.: Intra-procedural inference of static types for java bytecode.Technical Report Sable 1998-5, McGill University, Montreal, Canada (October 1998), http://www.sable.mcgill.ca/publications/

  10. Gosling, J., Joy, B., Steele, G.: The Java Language Specification. The Java Series. Addison-Wesley, Reading (1997)

    Google Scholar 

  11. Innovative Software, http://world.isg.de

  12. Knoblock, T., Rehof, J.: Type elaboration and subtype completion for Java bytecode. In: Proceedings 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 228–242 (January 2000)

    Google Scholar 

  13. Lindholm, T., Yellin, F.: The Java Virtual Machine Specification. The Java Series. Addison-Wesley, Reading (1997)

    Google Scholar 

  14. MLJ, http://research.persimmon.co.uk/mlj/ .

  15. Mocha, http://www.brouhaha.com/~eric/computers/mocha.html

  16. Morrisett, G., Crary, K., Glew, N., Walker, D.: Stack-based typed assembly language. In: Leroy, X., Ohori, A. (eds.) TIC 1998. LNCS, vol. 1473, pp. 28–52. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  17. Palsberg, J., Schwartzbach, M.I.: Object-Oriented Type Inference. In: Proceedings of the OOPSLA 1991 Conference on Object-oriented Programming Systems, Languages and Applications, pp. 146–161 (November 1991); published as ACM SIGPLAN Notices, vol. 26(11)

    Google Scholar 

  18. Plevyak, J., Chien, A.A.: Precise concrete type inference for object-oriented languages. ACM SIGPLAN Notices 29(10), 324–324 (1994)

    Article  Google Scholar 

  19. Proebsting, T.A., Watterson, S.A.: Krakatoa: Decompilation in Java (does bytecode reveal source?). In: USENIX (ed.) The Third USENIX Conference on Object-Oriented Technologies and Systems (COOTS), Portland, Oregon, Berkeley, CA, USA, June 16–19, pp. 185–197. USENIX (1997)

    Google Scholar 

  20. Small Eiffel, http://SmallEiffel.loria.fr/

  21. Soot, http://www.sable.mcgill.ca/soot/

  22. Sun Microsystems Inc., http://java.sun.com/products/hotspot/

  23. Taft, T.: Programming the Internet in Ada 95. In: Strohmeier, A. (ed.) Ada-Europe 1996. LNCS, vol. 1088, pp. 1–16. Springer, Heidelberg (1996)

    Chapter  Google Scholar 

  24. Tiuryn, J.: Subtype inequalities. In: Proceedings, Seventh Annual IEEE Symposium on Logic in Computer Science, Santa Cruz, California, pp. 308–315. IEEE Computer Society Press, Los Alamitos (1992)

    Chapter  Google Scholar 

  25. Vallée-Rai, R., Co, P., Gagnon, E., Hendren, L., Lam, P., Sundaresan, V.: Soot - a Java bytecode optimization framework. In: Proceedings of CASCON (1999)

    Google Scholar 

  26. Vallée-Rai, R., Gagnon, E., Hendren, L., Lam, P., Pominville, P., Sundaresan, V.: Optimizing Java Bytecode using the Soot framework: It is feasible? In: CC2000—International Conference on Compiler Construction, Berlin, Germany, pp. 18–34 (March 2000)

    Google Scholar 

  27. Wing Soft Corporation, http://www.wingsoft.com/wingdis.shtml

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2000 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Gagnon, E.M., Hendren, L.J., Marceau, G. (2000). Efficient Inference of Static Types for Java Bytecode. In: Palsberg, J. (eds) Static Analysis. SAS 2000. Lecture Notes in Computer Science, vol 1824. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-45099-3_11

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-45099-3_11

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-67668-3

  • Online ISBN: 978-3-540-45099-3

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics