SLIDE 1 @PaniniJ: Generating Capsule Systems from Annotated Java
Dec15-12: Trey Erenberger, Dalton Mills, and David Johnston
SLIDE 2 Overview
- Project Foundations: Capsule Oriented Programming
- Goals of @PaniniJ
- How It Works
- Usability and Maintainability Improvements
SLIDE 3
Project Goal
Make Capsule Oriented Programming more accessible to Java programmers
SLIDE 4
Concurrent Programming
Concurrent Programming in Java is Hard
SLIDE 5 Capsule Oriented Programming
One can think of it like a design pattern.
- Capsule: Like an object with a thread inside.
- System of Capsules: A collection of capsules
sending requests to each other.
- Write sequential code; asynchronous code.
- String s = fooCapsule.bar(“Hello, world!”);
SLIDE 6 PaniniJ: The Existing Solution
- PaniniJ is a capsule-oriented language.
- Language is similar to Java.
- Modified Java compiler (panc) compiles PaniniJ code.
- Auto-generate boilerplate concurrent capsule code.
- Correct by construction concurrency.
SLIDE 7
The Problem With PaniniJ: Few Development Tools
SLIDE 8 Build an Eclipse Plugin for PaniniJ to:
- Fix red squiggles
- Provide useful compilation errors & warnings
- Enable code completion & IDE features
Initial Project Specification
SLIDE 9
Eclipse Plugin
Pro: It would work. Con: IDE lock in Con: Maintainability hurdles Con: Usability hurdles
SLIDE 10 Client Goals
Capsule Oriented Programming shall be:
- More usable by Java programmers.
- More compatible with existing Java tools.
- Less complex to use within Java projects.
SLIDE 11
Alternative: Compiler Plugin
Pro: Core Java Feature (Annotation Processor) Pro: IDE Independent Con: Required Reimplementation Functionality of PaniniJ
SLIDE 12
Deciding Factor: Use Standard Tools
Standard compiler plugin strategy met all 3 goals. Bring panini to tools rather than tools to panini.
SLIDE 13 @PaniniJ: Our Solution
- The user defines a set of
capsule templates as Java classes.
properties and behavior of the desired capsule.
concurrent Java code required for such a capsule.
SLIDE 14
Code Generation
SLIDE 15 User’s Capsule Templates (.java files) Auto-Generated Source Artifacts (.java files) Executable Capsule System (.class files)
Annotation Processing Pipeline
SLIDE 16 Capsule Template Capsule Interface Capsule$Thread Inter-Capsule Messages @PaniniJ Annotation Processor Java Compiler Executable .class files
Many Artifacts are Generated From One Capsule Template
SLIDE 17 Capsule System Includes Many Artifacts From Many Capsule Templates
SLIDE 18
User’s Capsule Template
SLIDE 19 User’s Capsule Template
Capsule Interface Capsule$Thread Inter-Capsule Messages
SLIDE 20
Generated Capsule Interface
SLIDE 21 User’s Capsule Template
Capsule Interface Capsule$Thread Inter-Capsule Messages
SLIDE 22
Generated Multithreaded Wrapper
SLIDE 23 User’s Capsule Template
Capsule Interface Capsule$Thread Inter-Capsule Messages
SLIDE 24
Generated Message Wrapper
SLIDE 25 User’s Capsule Template
Capsule Interface Capsule$Thread Inter-Capsule Messages
SLIDE 26
Static Checks
SLIDE 27 Static Checking
Exposing Panini Model via IDE
- Rules identified and implemented as checks.
- Reported from annotation processor
- Violations displayed in context
- 45 checks implemented
SLIDE 28
Static Checking in Eclipse
SLIDE 29
Static Checking in NetBeans
SLIDE 30
Improving Maintainability and Usability
SLIDE 31 Annotation Processor PaniniProcessor: Refactored Capsule Processing Dataflow
@Capsule Template (.java) Capsule Artifacts (.java) Capsule Template Checks Capsule Model Capsule Artifact Factories Message Artifact Factories Message Artifacts (.java)
Return Type Models Param Type Models
Procedure Models
SLIDE 32 Testing Methods
- Invoke compiler with Maven
- Programmatically invoke compiler with javax.tools
- Unit testing with Google’s compile-testing
Improving Testing
SLIDE 33
Getting Started Website
SLIDE 34
Usability: Documentation
Annotation Processor Javadoc
SLIDE 35 Client Goals
Capsule Oriented Programming shall be:
- More usable by Java programmers.
- More compatible with existing Java tools.
- Less complex to use within Java projects.
SLIDE 36
Questions?
SLIDE 37
Questions?
SLIDE 38
- Background: Capsules and PaniniJ
- Identify (specific) client goals
- Reformulated project as @PaniniJ
- Built working prototype
Spring Semester
SLIDE 39 Fall Semester
- Refine Prototype into Product
○ Processor Refactor ○ Unit & Integration Tests
- Documentation
- Usability Enhancements
○ Static Checks ○ Setup/Compile/Run Ease
SLIDE 40
Example Program: “Hello, World!”
SLIDE 41 “Hello World” Example
Console Writes a string Greeter Stores and sends a greeting HelloWorld Creates and drives activity
SLIDE 42 “Hello World” Example
Console write(String) Greeter greet() HelloWorld run()
SLIDE 43 “Hello World” Example
Console Greeter { @Imports Stream s } HelloWorld { @Local Greeter g; @Local Console c; }
SLIDE 44 “Hello World”: Capsule Template Syntax
procedure
Console Greeter HelloWorld
SLIDE 45 “Hello World”: Capsule Template Syntax
- @Wired
- init()
- User-defined
procedure
Console Greeter HelloWorld
TODO: Change annotations!
SLIDE 46 “Hello World”: Capsule Template Syntax
- @Local
- design()
- run()
- imports()
Console Greeter HelloWorld
TODO: Change annotations!
SLIDE 47
Designing Capsule Artifact Inheritance
SLIDE 48
Designing Additional Message Types
SLIDE 49 Background: Our Client
- ISU Laboratory For Software Design
- Advisor: Dr. Hridesh Rajan
- Research:
○ Software Engineering ○ Programming Language Design
- Collaborators: Panini Project Grad Students
SLIDE 50
Background: Panini Project Vision
Make efficient programming abstractions which increase productivity and decrease maintenance costs by making concurrent programming less error-prone. Make concurrency less complicated.
SLIDE 51 Development Process
- Rapid Application Development
○ Many prototypes which tackle small problems ○ Documentation along the way
○ git, GitHub, GitHub Issues, GitHub wiki ○ Eclipse, Maven