Kava - A Reflective Java Based on Bytecode Rewriting

  • Ian Welch
  • Robert J. Stroud
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1826)


Current implementations of reflective Java typically either require access to source code, or require a modified Java platform. This makes them unsuitable for applying reflection to Commercial-off-the-Shelf (COTS) systems. The high level nature of Java bytecode makes on-the-fly rewritings of class files feasible and this has been exploited by a number of authors. However, in practice working at bytecode level is error prone and leads to fragile code. We propose using metaobject protocols in order to specify behavioural changes and use standard bytecode rewritings to implement the changes. We have developed a reflective Java called Kava that provides behavioural runtime reflection through the use of bytecode rewriting of Java classes. In this paper we discuss the binary rewriting approach, provide an overview of the Kava system and provide an example of an application of Kava.


Source Code Java Class Method Invocation Java Implementation Code Instruction 
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.
    Massimo Ancona, Walter Cazzola, and Eduardo B. Fernandez. Reflective Authorization Systems: Possibilities, Benefits and Drawbacks. In Jan Vitek and Christian Jensen, editors, Secure Internet Programming: Security Issues for Mobile and Distributed Objects, Lecture Notes in Computer Science 1603, pages 35–51. Springer-Verlag, July 1999.Google Scholar
  2. 2.
    Messaoud Benantar, Bob Blakley and Anthony J. Nadalin. Approach to Object Security in Distributed SOM. IBM Systems Journal, 35(2):204–226, 1996.CrossRefGoogle Scholar
  3. 3.
    Ole Agesen, Stephen N. Freund and John C. Mitchell. Adding Type Parameterization. In Proceedings of OOPSLA’97. Atlanta, Georgia. 1997.Google Scholar
  4. 4.
    Shigeru Chiba. Load-time Structural Reflection in Java. In Proceedings of ECOOP’2000. June 2000.Google Scholar
  5. 5.
    Geoff A. Cohen and Jeff Chase. Automatic Program Transformation with JOIE. In Proceedings of USENIX Annual Technical Symposium. 1998.Google Scholar
  6. 6.
    Grzegorz Czaijkowski and Thorsten von Eicken. JRes: A Resource Accounting Interface for Java. In Proceedings of OOPSLA’98. 1998.Google Scholar
  7. 7.
    Michael Gölm. Design and Implementation of a Meta Architecture for Java. Master’s thesis, University of Erlangen-Nurnberg, Germany, January 1997.Google Scholar
  8. 8.
    Joao Guimarães. Reflection for Statically Typed Languages. In Proceedings of ECOOP’98. July 1998.Google Scholar
  9. 9.
    IBM. Bean Extender Documentation, version 2.0. 1997.Google Scholar
  10. 10.
    Ralph Keller and Urs Holzle. Binary Component Adaptation. In Proceedings of ECOOP’98. July 1998.Google Scholar
  11. 11.
    Ruiz-Garcia Marc-Olivier Killijian, Jean-Charles Fabre and Shigeru Chiba. A Metaobject Protocol for Fault-Tolerant CORBA Applications. In Proceedings of the 17th Symposium on Reliable Distributed Systems (SRDS’98), pages 127–134, 1998.Google Scholar
  12. 12.
    Gregor Kickzales, Jim des Rivières, and Daniel G. Bobrow. The Art of the Metaobject Protocol. MIT Press, Cambridge, Massachusetts, 1991.Google Scholar
  13. 13.
    Sheng Liang and Gilad Bracha. Dynamic Class Loading in the Java™ Virtual Machine. In Proceedings of OOPSLA’98, Vancouver, Canada, October 1998.Google Scholar
  14. 14.
    Satoshi Matsuoka, Hirotaka Ogawa, Kouya Shimura, Yasunori Kimura, Koichiro Hotta, and Hiromitsu Takagi. OpenJIT A Reflective Java JIT Compiler. In Proceedings of OOPSLA’98 Workshop on Reflective Programming in C++ and Java, November 1998.Google Scholar
  15. 15.
    Alexandre Olivia, Luis Eduardo Buzato, and Calciolari Islene. The Reflective Architecture of Guaraná.
  16. 16.
    Insik Shin and John C. Mitchell. Java Bytecode Modification and Applet Security. Stanford CS Tech Report. 1998.Google Scholar
  17. 17.
    Robert J. Stroud. Transparency and Reflection in Distributed Systems. ACM Operating System Review, 22:99–103, April 1992.Google Scholar
  18. 18.
    Robert J. Stroud and Zhixue Wu. Using Metaobject Protocols to Satisfy Non-Functional Requirements. In Chris Zimmerman, editor, Advances in Object-Oriented Metalevel Architectures and Reflection, chapter 3, pages 31–52. CRC Press, Inc., 2000 Corporate Blvd., N.W., Boca Raton, Florida 33431, 1996.Google Scholar
  19. 19.
    Robert J. Stroud and Zhixue Wu. Using Meta-Object Protocol to Implement Atomic Data Types. In Walter Olthoff, editor, Proceedings of the 9th Conference on Object-Oriented Programming (ECOOP’95), LNCS 952, pages 168–189, Aarhus, Denmark, August 1995. Springer-Verlag.Google Scholar
  20. 20.
    Sun Microsystems, Inc. Java Development Kit version 1.3.0 Documentation. 2000.Google Scholar
  21. 21.
    Michiaki Tatsubori and Shigeru Chiba. Support of Design Patterns with Compile-time Reflection. In Shigeru Chiba and Jean-Charles Fabre, editors, Proceedings of OOPSLA Workshop on Reflective Programming in C++ and Java, Vancouver, Canada, November 1998.Google Scholar
  22. 22.
    Ian Welch and Robert J. Stroud. Dalang-A Reflective Extension for Java. Computing Science Technical Report CS-TR-672, University of Newcastle upon Tyne. 1999.Google Scholar
  23. 23.
    Ian Welch and Robert J. Stroud. From Dalang to Kava-The Evolution of a Reflective Java Extension. In Proceedings of Meta-Level Architectures and Reflection, Second International Conference, Reflection 1999, page 19–21. Saint-Malo, France. LNCS 1616, Springer. July 1999.Google Scholar
  24. 24.
    Ian Welch and Robert J. Stroud. Supporting Real World Security Models in Java. In Proceedings of 7th IEEE International Workshop on Future Treads of Distributed Computing Systems, pages 20–22. Cape Town, South Africa. TIEEE Computer Society. December 1999.Google Scholar
  25. 25.
    Zhixue Wu and Scarlet Schwiderski. Reflective Java-Making Java Even More Flexible. FTP: Architecture Projects Management Limited (, Cambridge, UK. 1997.
  26. 26.
    Chris Zimmerman. Metalevels, MOPs and What all the Fuzz is All about. In Chris Zimmerman, editor, Advances in Object-Oriented Metalevel Architectures and Reflection, chapter 1, pages 3–24. CRC Press, Inc., 2000 Corporate Blvd., N.W., Boca Raton, Florida 33431, 1996.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • Ian Welch
    • 1
  • Robert J. Stroud
    • 1
  1. 1.University of Newcastle-upon-TyneUK

Personalised recommendations