Transcript slides

The Java Legacy Interface
Stephan Korsholm
Centre for Embedded Software Systems (CISS)
Aalborg University
Denmark
Background
Ph. D. work
1-17
Introducing Java to a C/Assembler legacy
platform
KIRK DECT handsets
KIRK generic wireless
control module.
16 bit
512 Kb
16 Mhz
Java for GUIs
Java for end user
customization
2-17
Introducing Java to a C/Assembler legacy
platform
Legacy code is very important,
• Represents decades of software development.
• Is the ”golden egg” of the company.
• But, legacy code is in general,
 ”Untouchable” code.
 Written by engineers without proper SW development skills.
 Hard to maintain, hard to refactor.
 A burden that will never go away.
3-17
Introducing Java to a C/Assembler legacy
platform
Legacy code is very important,
• Represents decades of software development.
• Is the ”golden egg” of the company.
• But, legacy code is in general,
 ”Untouchable” code.
 Written by engineers without proper SW development skills.
 Hard to maintain, hard to refactor.
 A burden that will never go away.
They need HELP!
How can Java be introduced into such a setting?
3-17
Introducing Java to a C/Assembler legacy
platform
Overview,
• The KIRK legacy software architecture.
• Scheduling a JVM using the legacy scheduler.
• Java/C Communication using the legacy message exchange protocol.
• Code samples.
• Looking ahead….
4-17
The KIRK legacy software architecture
Layered architecture
Application
DECT protocol
MAC Layer
5-17
The KIRK legacy software architecture
HW
Events
Layered architecture
Application
putEvent
getEvent
DECT protocol
MAC Layer
Event handlers
Event dispatcher
5-17
Scheduling the JVM
Integrate from the legacy architecture
(JNI unfortunately not an option).
Schedule the JVM in an event driven system.
Run the JVM as a short lived event handler.
6-17
Scheduling the JVM
Events
JLI function,
JLI_runVM(int timeout)
Executes bytecodes a certain
amount of time.
Event handlers
Event dispatcher
Suspends the VM.
Queues an event to be handled
by the VM event handler.
VM event handler
Returns to the scheduler.
7-17
Implementing
JLI_runVM(int timeout)
Slice the JVM,
•
•
•
•
Divide the execution into smaller units.
Eliminate recursion and long loops.
E.g. change the interpreter loop.
Enable suspend/resume of interpreter loop.
Slicing an existing JVM (SimpleRTJ VM),
• Analyzed program dependency graph.
• Refactored JVM source code.
• Introduced slicing points into the code.
8-17
Scheduling the JVM
Events
Legacy Events
JVM Events
Handling of legacy code and
Java code is intermixed.
Selfregulating prioritization of
Java code.
Event handlers
Event dispatcher
Legacy code unaware and
unaffected of Java code.
Seamless integration.
9-17
Communication
10-17
Communication
Event handlers communicate by sending events to each other,
• Support queueing events to Java from legacy code.
• Support queueing events to legacy code from Java.
The KIRK Java API adds functionality for subscribing to events in Java
• Steal events and handle them in Java.
• Change events and send them on.
• Look at events and send them on unchanged.
10-17
Communication
Events
JLI function,
void
int
void
void
JLI_subscribe(int event)
JLI_available(int event)
JLI_getData(byte[] data)
JLI_setFate(bool fate)
subscribe
Event handlers
Event dispatcher
available?
getData
setFate
Java handler
11-17
Communication
12-17
Possibilities – GUI customization
KIRK Dect Handsets
Subscribe to GUI events (e.g. key press).
Implement different handling of selected
events.
Manipulate GUI by sending new events.
Adding new behaviour to basic firmware.
Increasing end user experience.
Sell add-on Java applications.
13-17
Possibilities – Core software development
Today
100%
0%
Java
Legacy
14-17
Possibilities – Core software development
Today
Tomorrow
100%
100%
0%
0%
Java
Legacy
Java
Legacy
Incrementel (baby steps) porting of legacy code into Java
14-17
Looking ahead....
• Event driven programming vs. other types of paradigms.
• VM slicing – effect on real-time behaviour?
• WCET of JLI_runVM?
 Give proper value of timeout parameter.
• Integrating legacy code with,
 JIT compiled Java.
 AOT compiled Java.
15-17
Summing up.
• Given initial specification of JLI (Java Legacy Interface),
 Focused on event driven embedded legacy platforms.
• Implemented JLI in a interpreter,
 Implemented VM slicing.
 Implemented Java/legacy message exchange.
• Implemented the KIRK API,
 Supports handling events in Java.
 Supports implementing selected functionality in Java.
 Supports incremental transition from legacy code (C)
to Java.
16-17
What has been gained?
On event driven legacy platforms we have gained,
• The ability to run Java components.
 Yes.
• Fine grained customization of application behaviour using Java.
 Yes.
• The option of incrementally porting legacy code into Java.
 Yes.
• Real-time?
 No! Certainly not (slicing has an impact on a real-time profile).
• Efficiency?
 No! Certainly not (currently we only support interpretation).
17-17
Your Comments?
17-17