Queryll: Java Database Queries Through Bytecode Rewriting

  • Ming-Yee Iu
  • Willy Zwaenepoel
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4290)


When interfacing Java with other systems such as databases, programmers must often program in special interface languages like SQL. Code written in these languages often needs to be embedded in strings where they cannot be error-checked at compile-time, or the Java compiler needs to be altered to directly recognize code written in these languages. We have taken a different approach to adding database query facilities to Java. Bytecode rewriting allows us to add query facilities to Java whose correctness can be checked at compile-time but which don’t require any changes to the Java language, Java compilers, Java VMs, or IDEs. Like traditional object-relational mapping tools, we provide Java libraries for accessing individual database entries as objects and navigating among them. To express a query though, a programmer simply writes code that takes a Collection representing the entire contents of a database, iterates over each entry like they would with a normal Collection, and choose the entries of interest. The query is fully valid Java code that, if executed, will read through an entire database and copy entries into Java objects where they will be inspected. Executing queries in this way is obviously inefficient, but we have a special bytecode rewriting tool that can decompile Java class files, identify queries in the bytecode, and rewrite the code to use SQL instead. The rewritten bytecode can then be run using any standard Java VM. Since queries use standard Java set manipulation syntax, Java programmers do not need to learn any new syntax. Our system is able to handle complex queries that make use of all the basic relational operations and exhibits performance comparable to that of hand-written SQL.


Complex Query Database Query Java Code Pair Object Destination Collection 
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.


  1. 1.
    Eisenberg, A., Melton, J.: SQLJ part 0, now known as SQL/OLB (object-language bindings). SIGMOD Rec. 27(4), 94–100 (1998)CrossRefGoogle Scholar
  2. 2.
    Sun Microsystems: JDBC technology,
  3. 3.
    JBoss: Hibernate,
  4. 4.
    Sun Microsystems: Enterprise JavaBeans technology,
  5. 5.
  6. 6.
    Tilevich, E., Smaragdakis, Y.: Portable and efficient distributed threads for Java. In: Jacobsen, H.-A. (ed.) Middleware 2004. LNCS, vol. 3231, pp. 478–492. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  7. 7.
    Pawlak, R., Seinturier, L., Duchien, L., Florin, G.: Jac: A flexible solution for aspect-oriented programming in Java. In: Yonezawa, A., Matsuoka, S. (eds.) Reflection 2001. LNCS, vol. 2192, pp. 1–24. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  8. 8.
    Bik, A.J., Gannon, D.B.: Javab—a prototype bytecode parallelization tool. Technical Report TR489, Indiana University (1997)Google Scholar
  9. 9.
    Miecznikowski, J., Hendren, L.: Decompiling Java bytecode: Problems, traps and pitfalls. In: Horspool, R.N. (ed.) CC 2002. LNCS, vol. 2304, pp. 111–127. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  10. 10.
    Vallée-Rai, R., Co, P., Gagnon, E., Hendren, L., Lam, P., Sundaresan, V.: Soot - a Java bytecode optimization framework. In: CASCON 1999: Proceedings of the 1999 conference of the Centre for Advanced Studies on Collaborative research, p. 13. IBM Press (1999)Google Scholar
  11. 11.
    Erosa, A.M., Hendren, L.J.: Taming control flow: A structured approach to eliminating GOTO statements. In: ICCL (1994)Google Scholar
  12. 12.
    Peterson, W.W., Kasami, T., Tokura, N.: On the capabilities of while, repeat, and exit statements. Commun. ACM 16(8), 503–512 (1973)MathSciNetCrossRefMATHGoogle Scholar
  13. 13.
    Transaction Processing Performance Council (TPC): TPC Benchmark W (Web Commerce) Specification Version 1.8. Transaction Processing Performance Council (2002)Google Scholar
  14. 14.
    Amza, C., Cecchet, E., Chanda, A., Elnikety, S., Cox, A., Gil, R., Marguerite, J., Rajamani, K., Zwaenepoel, W.: Bottleneck characterization of dynamic web site benchmarks. Technical Report TR02-389, Rice University (2002)Google Scholar
  15. 15.
    PostgreSQL Global Development Group: PostgreSQL,

Copyright information

© IFIP International Federation for Information Processing 2006

Authors and Affiliations

  • Ming-Yee Iu
    • 1
  • Willy Zwaenepoel
    • 1
  1. 1.School of Computer and Communication SciencesEPFLLausanneSwitzerland

Personalised recommendations