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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
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)
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)
Ahpah Software Inc., http://zeus.he.net/~pah/products.html
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)
Bothner, P.: Kawa - compiling dynamic languages to the Java VM (1998)
Cormen, T.H., Leiserson, C.E., Rivest, R.L.: Introduction to Algorithms. MIT Press; McGraw-Hill Book, Cambridge New York (1990)
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)
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)
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/
Gosling, J., Joy, B., Steele, G.: The Java Language Specification. The Java Series. Addison-Wesley, Reading (1997)
Innovative Software, http://world.isg.de
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)
Lindholm, T., Yellin, F.: The Java Virtual Machine Specification. The Java Series. Addison-Wesley, Reading (1997)
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)
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)
Plevyak, J., Chien, A.A.: Precise concrete type inference for object-oriented languages. ACM SIGPLAN Notices 29(10), 324–324 (1994)
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)
Small Eiffel, http://SmallEiffel.loria.fr/
Sun Microsystems Inc., http://java.sun.com/products/hotspot/
Taft, T.: Programming the Internet in Ada 95. In: Strohmeier, A. (ed.) Ada-Europe 1996. LNCS, vol. 1088, pp. 1–16. Springer, Heidelberg (1996)
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)
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)
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)
Wing Soft Corporation, http://www.wingsoft.com/wingdis.shtml
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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