ECE 750 Topic 8 Meta-programming languages, systems, and applications Load-time structural reflection in Java – Shigeru Chiba, 2000 May 27, 2004 Shimin.

Slides:



Advertisements
Similar presentations
Java security (in a nutshell)
Advertisements

JavAssist X.java X.class Class Loader My Loader X compile load JavAssist enables preload byte code modification.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
The road to reliable, autonomous distributed systems
Supporting Unanticipated Dynamic Adaptation of Application Behaviour Barry Redmond and Vinny Cahill Distributed Systems Group Trinity College, Dublin.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Introduction to Java Kiyeol Ryu Java Programming Language.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Reflection (Reflexion in British English ) Mo Alkhafaji.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Institute of Computing Jaca: a Reflective Fault Injection Tool based on Patterns Eliane Martins Cecilia Rubira Nelson Leme Institute of Computing State.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
Load Time Structural Reflection in Java Shigeru Chiba Institute of Information Science and Electronics University of Tsukuba.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Advanced Java Programming Lecture 5 Reflection dr hab. Szymon Grabowski dr inż. Wojciech Bieniecki
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Extensible Plug-ins for Aspect-Oriented Programming Macneil Shonle*Ankit Shah.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
1 22 August 2001 The Security Architecture of the M&M Mobile Agent Framework P. Marques, N. Santos, L. Silva, J. Silva CISUC, University of Coimbra, Portugal.
Tool support for crosscutting concerns of API documentation Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Composing Adaptive Software Authors Philip K. McKinley, Seyed Masoud Sadjadi, Eric P. Kasten, Betty H.C. Cheng Presented by Ana Rodriguez June 21, 2006.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
CT1513 Introduction To java © A.AlOsaimi.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
Jim Dowling, DSG. Introduction to Reflection1 Reflection and the Metaobject Protocol paradigm by Jim Dowling.
CSCE 314 Programming Languages Reflection Dr. Hyunyoung Lee 1.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Jun 14, 2004RAM-SE'04 Workshop, Oslo, Norway 1 Negligent Class Loaders for Software Evolution Yoshiki Sato, Shigeru Chiba (Tokyo Institute of Technology.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
1 Manipulating Managed Execution Runtimes to support Self-Healing Systems Rean Griffith‡, Gail Kaiser‡ Presented by Rean Griffith
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
Introduction to Programming 1 1 2Introduction to Java.
RealTimeSystems Lab Jong-Koo, Lim
Introduction to JAVA Programming
Software, IEE Proceedings, Vol.152, Num.3, June 2005,Page(s): Prasanthi.S March, Java-based component framework for dynamic reconfiguration.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Smalltalk Meta-Programming Programming Languages HUJI 2010 Yardena Meymann.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Applications Active Web Documents Active Web Documents.
Advanced Computer Systems
Visit for more Learning Resources
Introduction to Computers, the Internet and the World Wide Web
Rean Griffith‡, Gail Kaiser‡ Presented by Rean Griffith
Types of Programming Languages
2.1. Compilers and Interpreters
Presentation on Object Oriented programming Topic
Knowledge Byte In this section, you will learn about:
Multi-Dispatch in the Java™ Virtual Machine
JAsCo an Aspect-Oriented approach tailored for
Java History, Editions, Version Features
Knowledge Byte In this section, you will learn about:
CSCE 314: Programming Languages Dr. Dylan Shell
CSc 453 Interpreters & Interpretation
SPL – PS1 Introduction to C++.
Presentation transcript:

ECE 750 Topic 8 Meta-programming languages, systems, and applications Load-time structural reflection in Java – Shigeru Chiba, 2000 May 27, 2004 Shimin Li University of waterloo

Paper Overview

Contents: Overview Existing reflection facilities in Java - Standard Java Reflection API - Extensions to the reflection ability of Java Javassist – an intercession extension to Java - Implementation technique - Introduction to load-time structural reflection - Javassist API Three applications of Javassist

Contents: Detail Existing reflection facilities in Java - Standard Java Reflection API Restricted to introspection Behavior reflection is very limited - Extensions to Java Reflection API Enable restricted behavior reflection Modify runtime systems or compilers Use hook-insertion technique and metaobjects Runtime overheads can be low Limitation to some language extensions(e.g. BCA)

Contents: Detail Novel reflection architecture – Javassist - An extension to the Java reflection API Enables structural reflection in Java at load time - Is portable Runs with a standard JVM - Provides source-level abstraction for programmers Can be used without knowledge of the Java byte code - Never needs source code Performs structural reflection by instrumenting byte code of a loaded class

Contents: Detail Javassist API - Reification CtClass object and its reflective methods - Introspection Almost compatible with the Java reflection API - Alteration Three design goals and their achievements - Adding a new member Two approaches for adding a new method to a class

Contents: Detail Javassist API cont'd - Altering a method body - Reflective class loader Allows a loaded program to control the class loading - Three ways to use Javassist With a user class loader With a web server Off line

Contents: Detail Application examples of Javasssist - Binary Code Adaptation(BCA) - Behavioral reflection - Remote method invocation Generating stub code for RMI

Related Work Reflection in Java - Behavioral reflection examples: MetaXa, Kava, Java reflection API - Structural reflection example: Linguistic reflection Compile-time metaobject protocol - Source-code basis example: OpenJava Byte code translator - Examples: JOIE, JavaClass API Others - OpenJIT, CLOS MOP, BCA

Contributions and Novelties Architecture for performing structural refection in Java based on byte code - No need for source code - Used with a standard JVM and Java compiler - Source-level abstraction Practical structural reflection API Three application examples - Show implementing some language extensions with Javassist is much easier than other reflection architectures

What I like Javassist does not break security guarantees given by Java Javassist is easy to used - Without knowledge of the Java byte code - Can be used with a user class loader, web server, and offline Javassist architecture can be applied to other object-oriented languages - as long as the compiled binary includes enough symbolic information to construct a class object

Questions

Question 1 What is structural reflection?

Answer Structural reflection is the ability to allow a program to alter the definitions of data structures such as classes and methods.

Question 2 Some languages(e.g. Smalltalk,CLOS) implement structural reflection with support mechanisms embedded in runtime systems. What problems would the application of this implementation technique to Java cause?

Answer Invalidation of portability of Java due to modification of JVM Performance degradation of JVM due to difficulty to employ optimization at runtime Extra runtime type checks or restrictions on the structural reflection Less security

Question 3 What is load-time structural reflection?

Answer Structural reflection is performed only before a program is loaded into a runtime system, that is, at load time.

Question 4 How does Javassist perform structural reflection?

Answer Javassist implementation based on load- time structural reflection architecture Javassist performs structural reflection by translating alteration into equivalent bytecode transformation of the class files After the transformation, the modified class files are loaded into the JVM and then no alteration are allowed after that

Question 5 How does Javassist reify the class needed to be reflected?

Answer Javassist creates a CtClass(compile-time class) object CtClass represents the byte code of the class need to be reflected Then the class is accessible from a program by invocating the methods on CtClass object

Question 6 How is the introspecting facilities of Javassist?

Answer The introspection part of Javassist API is compatible with the Java reflection API But, Javassist does not provide methods for creating an instance or invoking a method

Question 7 What is the main features of the alteration methods in Javassist API?

Answer Provides source-level abstraction for users - Approach to specify a method body is in source level Executes structural reflection efficiently - Copy pre-compiled method body from a class to another Performs structural reflection in a safe manner in terms of types - No methods to remove a method or a field from a class - New superclass must be a subclass of the original superclass - No methods to change the parameters of a method

Question 8 What is the difference between the class loader provided by Javassist and the Java’s standard class loader?

Answer The Javassist class loader allows a loaded program to control the class loading (see Figure 1) - If a program is loaded by Javassist’s class loader L and it includes a class C, then it can intercept the loading of C by L to self-reflectively modify the byte code of C - For avoiding infinite recursion, while the loading of a class is intercepted, further interception is not allowed ∙ Java’s class loader never allows this self-reflective class loading

Question 9 Why Javassist does not break security guarantees given by Java?

Answer Javassist uses the standard JVM The classes processed by Javassist are subject to the bytecode verifier and the SecurityManager of Java

Question 10 Can Javassist and OpenJava both deal with syntax extensions of Java?

Answer OpenJava can deal with syntax extensions. Because OpenJava is source-code basis. It reads source code for creating an object representing a class, a method, or a field, and alteration on the object is translated into corresponding transformation of the source code Javassist can not deal with syntax extensions since Javassist is byte-code basis

Question 11 Can the architecture applied by Javassist be applied to other object-oriented language?

Answer Yes, as long as the compiled binary program contains enough symbolic information to construct a class object. However the API needs to be individually designed for each language to perform structural reflection in a safe manner in terms of types