Supporting Unanticipated Dynamic Adaptation of Application Behaviour Barry Redmond and Vinny Cahill Distributed Systems Group Trinity College, Dublin.

Slides:



Advertisements
Similar presentations
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Advertisements

METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Load-time structural reflection in Java – Shigeru Chiba, 2000 May 27, 2004 Shimin.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Lab#1 (14/3/1431h) Introduction To java programming cs425
ITEC200 – Week03 Inheritance and Class Hierarchies.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Inheritance and Polymorphism.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
1 Memory Model of A Program, Methods Overview l Closer Look at Methods l Memory Model of JVM »Method Area »Heap »Stack l Preview: Parameter Passing.
1 Inheritance and Polymorphism. 2 Motivations Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common.
Lecture 9 Concepts of Programming Languages
Institute of Computing Jaca: a Reflective Fault Injection Tool based on Patterns Eliane Martins Cecilia Rubira Nelson Leme Institute of Computing State.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
OOP Languages: Java vs C++
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
1 Inheritance and Polymorphism Chapter 9. 2 Polymorphism, Dynamic Binding and Generic Programming public class Test { public static void main(String[]
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Chapter 21 Generics 1. Generics - Overview Generic Methods specify a set of related methods Generic classes specify a set of related types Software reuse.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 9 - Inheritance.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.
2000 Jordan Anastasiade. All rights reserved. 1 Class In this lesson you will be learning about: Class. Inheritance. Polymorphism. Nested and.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 11 Inheritance and Polymorphism.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
Polymorphism. 3 main programming mechanisms that constitute OOP: 1. Encapsulation 2. Inheritance 3. Polymorphism.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 9 Inheritance and.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 10 Inheritance and.
Object Oriented Programming
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 19 Generics.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
CSCE 314 Programming Languages Reflection Dr. Hyunyoung Lee 1.
Interfaces F What is an Interface? F Creating an Interface F Implementing an Interface F What is Marker Interface?
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Programming in java Packages Access Protection Importing packages Java program structure Interfaces Why interface Defining interface Accessing impln thru.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
1 Manipulating Managed Execution Runtimes to support Self-Healing Systems Rean Griffith‡, Gail Kaiser‡ Presented by Rean Griffith
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Polymorphism in Methods
Modern Programming Tools And Techniques-I
Sections Inheritance and Abstract Classes
Chapter 11 Inheritance and Polymorphism
Inheritance and Polymorphism
Continuing Chapter 11 Inheritance and Polymorphism
ATS Application Programming: Java Programming
Lecture 9 Concepts of Programming Languages
Chapter 9 Inheritance and Polymorphism
Java Programming Language
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Inheritance Cse 3rd year.
Chapter 14 Abstract Classes and Interfaces
Chapter 11 Inheritance and Polymorphism Part 2
Lecture 9 Concepts of Programming Languages
Plug-In Architecture Pattern
Presentation transcript:

Supporting Unanticipated Dynamic Adaptation of Application Behaviour Barry Redmond and Vinny Cahill Distributed Systems Group Trinity College, Dublin

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Introduction Uses of unanticipated dynamic adaptation: –Long running applications –Applications which must adapt to a changing environment –Applications for which source code is not available “Unanticipated” –No preparatory modifications to source or compiled code “Dynamic”: –Insertion and removal of new behaviour at runtime Usually implemented for interpreted languages –MetaXa, Guaraná, PROSE, MetaclassTalk, Iguana/J

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Iguana/J An architecture to support unanticipated dynamic adaptation of Java programs Implemented as –An extended JVM –A class library Provides a strong separation between new and existing behaviours –New behaviour is reusable in compiled form Uses reflective techniques –Some reflective terms

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP A Simple Example Add synchronisation to this class –while it is running –without access to the source code public class Stack { … public void push(Object o) { … } public Object pop() { … } }

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Implement the New Behaviour 1.Create a class to implement the new behaviour –Extend Iguana/J library class MExecute public class Sync extends MExecute { public Object execute( Object targ, Object[] args, Method m) { synchronized(targ) { return(proceed(targ, args, m)); } } } This is called a metaobject class

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Create a Protocol 2.Declare that our new class is for handling method invocation: protocol SyncProtocol { reify Invocation: Sync; } 3.Use the Iguana/J protocol compiler to convert this to a Java class file

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Associate the New Behaviour 4.Associate the new behaviour with the Stack class: Meta.associate(“Stack”, “SyncProtocol”); Affects all existing and future instances of Stack Association is inherited –Affects all subclasses of Stack and all their existing and future instances

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Associating with One Object Apply new behaviour to a single object: Object x = new Object(); … Meta.associate(x, “SyncProtocol”); Remove new behaviour: Meta.reset(x);

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Organisation Uanticipated adaptation Dynamic adaptation JVM Iguana/J extension Application classes Protocol compiler Protocol declarations Metaobject classes Protocol classes Iguana/J classes

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP A More Focused Solution Apply synchronisation to selected methods of Stack: public class Sync extends MExecute { public Object execute( Object targ, Object[] args, Method m) { String s = m.getName(); if(s.equals(“push”) || s.equals(“pop”)) { synchronized(targ) { return(proceed(targ, args, m)); } } else return(proceed(targ, args, m)); } }

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP A Reusable Solution public class Sync extends MExecute { private String[] names; public Sync(String[] n) { names = n;// Accept & store parameters } public Object execute( Object targ, Object[] args, Method m) { if(match(m.getName())) { synchronized(targ) { return(proceed(targ, args, m)); } } else return(proceed(targ, args, m)); } // Check for match with an element of names[]: private boolean match(String s) { … } }

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Applying the Reusable Solution Add parameters to the protocol declaration: protocol SyncProt(String[] mNames) { reify Invocation: Sync(mNames); } Provide parameter values at association time: Object[] params = new Object[1]; params[0] = new String[] {“push”, “pop”}; Meta.associate(“Stack”, “SyncProt”, params);

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Context Sensitivity Allow calls only from a specified class: public class Guard extends MExecute { private String name; public Guard(String c) { name = c & “.*”; } public Object execute( Object targ, Object[] args, Method m) { if(getCallStack().containsCallTo(name)) return(proceed(targ, args, m)); else throw new RuntimeException(); } } protocol GuardProt(String cName) { reify Invocation: Guard(cName); }

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Deriving New Behaviour Protocols may be derived from other protocols protocol NewP(String c, String[] m): GuardProt(c), SyncProt(m) { reify Invocation: Verbose; } Automatic composition of metaobject classes for each category (no overriding) Composition is a simple chain SyncProt NewP GuardProt

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Restrictions on Association The protocol associated with a class must be equal to or derived from the protocol associated with its superclass  Every class includes all new behaviour applied to any superclass The protocol associated with an object must be equal to or derived from the protocol associated with its class  Every object includes all new behaviour applied to its class

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Inheritance and Derivation Association is inherited (B) Inheritance can be overridden by explicit association (C) –P2 must be derived from P1 New behaviour cannot be inadvertantly omitted from subclasses CP2 AP1 Explicit association BP1 Inherited association

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Implementation Interception mechanism is an extended JVM Prototype extends Sun JDK1.3 using the JIT Interface JIT Interface supports: –Close integration with the JVM –Insertion of hooks before the application loads –Interception of all class loading –Access to internal JVM data structures Interception is by dynamically changing invoker functions and altering bytecode

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Performance No effect on classes and objects with no associated metaobject protocol No effect on non-intercepted operations Prototype: Overhead of 24 times for intercepted method invocation –Affects invocation only, not method execution –Performance of other dynamic architectures: 40 times for Guaraná and 70 times for PROSE

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Conclusion The Iguana/J architecture supports: Dynamic insertion/removal of new behaviour Unanticipated change without source code Inheritance of new behaviour Strong separation Context sensitivity Reusable new behaviour

Supporting Unanticipated Dynamic Adaptation of Application Behaviour ECOOP Ireland for the World Cup!