Runtime Specialization Java has never been so dynamic before - - PowerPoint PPT Presentation

runtime specialization java has never been so dynamic
SMART_READER_LITE
LIVE PREVIEW

Runtime Specialization Java has never been so dynamic before - - PowerPoint PPT Presentation

Runtime Specialization Java has never been so dynamic before Stephan Herrmann Simply Retail. Two Camps Strict Rules No Ceremony compiler detects errors Freedom Modularity Flexibility separate maintenance self modifying code Enforced


slide-1
SLIDE 1

Stephan Herrmann

Runtime Specialization Java has never been so dynamic before

Simply Retail.

slide-2
SLIDE 2

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 2

Two Camps

No Ceremony Freedom Flexibility

self modifying code code modifjes language

Strict Rules

compiler detects errors

Modularity

separate maintenance

Enforced Boundaries

blame assignment prevention

slide-3
SLIDE 3

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 3

Building Blocks

Boundary inside vs. outside What I get

lots of existing building blocks to choose from can compose them into my application

What I don't get

the right to open the box to make changes

Near miss

looks like a good match but doesn't totally fjt

slide-4
SLIDE 4

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 4

Near Miss

Adjust requirements to the building block?

not competitive

Drop existing, build your own

expensive

Why do we have the problem?

technical impossibility rules about boundaries

Envy those who don't have these rules

unlimited adaptation unanticipated adaptation

slide-5
SLIDE 5

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 5

Unanticipated Adaptation

Example:

StopWatch

time +clear() +start() +stop() tick()

WatchDisplay

+clear() +start() +stop() update() <

Missing Listener Infrastructure

slide-6
SLIDE 6

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 6

Unanticipated Adaptation

Example:

StopWatch

time +clear() +start() +stop() tick()

WatchDisplay

+clear() +start() +stop() update()

WANTED: Method Call Interception

infra structure solution language solution

Missing Listener Infrastructure

slide-7
SLIDE 7

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 7

Unanticipated Adaptation

Method call interception in Object Teams:

„callin“ method binding fmavors: before, after, replace

StopWatch

time +clear() +start() +stop() tick()

WatchDisplay

+clear() +start() +stop() update() «playedBy» update ← after tick

slide-8
SLIDE 8

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 8

Demo: Stop Watch

slide-9
SLIDE 9

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 9

Unanticipated Adaptation

Method call interception in Object Teams:

„callin“ method binding fmavors: before, after, replace

StopWatch

time +clear() +start() +stop() tick()

WatchDisplay

+clear() +start() +stop() update()

Role

«playedBy»

Base

update ← after tick

slide-10
SLIDE 10

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 10

The Role Playing Metaphor

Properties

Dynamism: roles can come and go (same base object) Multiplicities:

  • ne base can play several roles

(difgerent/same role types)

playedBy Relationship

Person

name

Employee

salary «playedBy»

name=”joe”

joe: Person :Student

matr=0815

«base»

:Employee

salary=100

« b a s e »

:Employee

salary=2000

«base»

Employee

salary

Role Base Person

name

slide-11
SLIDE 11

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 11

Summary Role Playing

playedBy

similar to inheritance connects instances

callin

method call interception

callout

method forwarding regardless of visibility

protected class WatchDisplay extends JFrame playedBy StopWatch { update <- after advance; void start() -> void start(); void stop() -> void stop(); void clear() -> void reset(); }

slide-12
SLIDE 12

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 12

Good or Bad?

Moralists

City: boundaries must not be violated! Fire site: boundaries are bad!

With power comes responsibility Give developers all the means necessary

  • For controlling roles
  • In a modular way
slide-13
SLIDE 13

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 13

Controlling Roles

Roles depend on context

contexts are reifjed as Teams

Each team instance can be (de)activated

active team instances contribute to the system state dispatch considers system state :Person

phoneNo getPhoneNo()

c :Company c :Company

name hire(Person p) name hire(Person p)

:Employee

  • fficePhoneNo

getPhoneNo ← getPhoneNo

«playedBy»

getPhoneNo()

Off On

if (c.isActive())

getPhoneNo()

slide-14
SLIDE 14

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 14

Controlling Roles (2)

Globally active teams

part of the top-level system defjnition

  • plain application: -Dot.teamconfjg=...
  • OT/Equinox: extension point aspectBinding

Scope of activation

per-thread ALL_THREADS while a certain code block is executing ...

slide-15
SLIDE 15

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 15

Demo: Flight Booking

slide-16
SLIDE 16

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 16

Integration – Technically

Weave hooks into the byte code

build time load time runtime

Execute on a standard JVM

application

  • -javaagent:

OT/Equinox

  • WeavingHook (OSGi standard)
slide-17
SLIDE 17

Stephan Herrmann: Runtime Specialization - EclipseCon Europe 2015

# 17

Phases

Development of building blocks

variability model extension points

Composition to an application

wire & confjgure building blocks unanticipated adaptation

Deployment

more wiring & confjguration

Operation

runtime adaptation

→ http://www.eclipse.org/objectteams

New in OT/J New in OT/J New in OT/J Neon New in OT/J Neon