@PaniniJ: Generating Capsule Systems from Annotated Java Dec15-12: - - PowerPoint PPT Presentation

paninij generating capsule systems from annotated java
SMART_READER_LITE
LIVE PREVIEW

@PaniniJ: Generating Capsule Systems from Annotated Java Dec15-12: - - PowerPoint PPT Presentation

@PaniniJ: Generating Capsule Systems from Annotated Java Dec15-12: Trey Erenberger, Dalton Mills, and David Johnston Overview Project Foundations: Capsule Oriented Programming Goals of @PaniniJ How It Works Usability and


slide-1
SLIDE 1

@PaniniJ: Generating Capsule Systems from Annotated Java

Dec15-12: Trey Erenberger, Dalton Mills, and David Johnston

slide-2
SLIDE 2

Overview

  • Project Foundations: Capsule Oriented Programming
  • Goals of @PaniniJ
  • How It Works
  • Usability and Maintainability Improvements
slide-3
SLIDE 3

Project Goal

Make Capsule Oriented Programming more accessible to Java programmers

slide-4
SLIDE 4

Concurrent Programming

Concurrent Programming in Java is Hard

slide-5
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
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
SLIDE 7

The Problem With PaniniJ: Few Development Tools

slide-8
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
SLIDE 9

Eclipse Plugin

Pro: It would work. Con: IDE lock in Con: Maintainability hurdles Con: Usability hurdles

slide-10
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
SLIDE 11

Alternative: Compiler Plugin

Pro: Core Java Feature (Annotation Processor) Pro: IDE Independent Con: Required Reimplementation Functionality of PaniniJ

slide-12
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
SLIDE 13

@PaniniJ: Our Solution

  • The user defines a set of

capsule templates as Java classes.

  • Each template describes

properties and behavior of the desired capsule.

  • @PaniniJ generates the

concurrent Java code required for such a capsule.

slide-14
SLIDE 14

Code Generation

slide-15
SLIDE 15

User’s Capsule Templates (.java files) Auto-Generated Source Artifacts (.java files) Executable Capsule System (.class files)

Annotation Processing Pipeline

slide-16
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
SLIDE 17

Capsule System Includes Many Artifacts From Many Capsule Templates

slide-18
SLIDE 18

User’s Capsule Template

slide-19
SLIDE 19

User’s Capsule Template

Capsule Interface Capsule$Thread Inter-Capsule Messages

slide-20
SLIDE 20

Generated Capsule Interface

slide-21
SLIDE 21

User’s Capsule Template

Capsule Interface Capsule$Thread Inter-Capsule Messages

slide-22
SLIDE 22

Generated Multithreaded Wrapper

slide-23
SLIDE 23

User’s Capsule Template

Capsule Interface Capsule$Thread Inter-Capsule Messages

slide-24
SLIDE 24

Generated Message Wrapper

slide-25
SLIDE 25

User’s Capsule Template

Capsule Interface Capsule$Thread Inter-Capsule Messages

slide-26
SLIDE 26

Static Checks

slide-27
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
SLIDE 28

Static Checking in Eclipse

slide-29
SLIDE 29

Static Checking in NetBeans

slide-30
SLIDE 30

Improving Maintainability and Usability

slide-31
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
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
SLIDE 33

Getting Started Website

slide-34
SLIDE 34

Usability: Documentation

Annotation Processor Javadoc

slide-35
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
SLIDE 36

Questions?

slide-37
SLIDE 37

Questions?

slide-38
SLIDE 38
  • Background: Capsules and PaniniJ
  • Identify (specific) client goals
  • Reformulated project as @PaniniJ
  • Built working prototype

Spring Semester

slide-39
SLIDE 39

Fall Semester

  • Refine Prototype into Product

○ Processor Refactor ○ Unit & Integration Tests

  • Documentation
  • Usability Enhancements

○ Static Checks ○ Setup/Compile/Run Ease

  • v0.1.0 release
slide-40
SLIDE 40

Example Program: “Hello, World!”

slide-41
SLIDE 41

“Hello World” Example

Console Writes a string Greeter Stores and sends a greeting HelloWorld Creates and drives activity

slide-42
SLIDE 42

“Hello World” Example

Console write(String) Greeter greet() HelloWorld run()

slide-43
SLIDE 43

“Hello World” Example

Console Greeter { @Imports Stream s } HelloWorld { @Local Greeter g; @Local Console c; }

slide-44
SLIDE 44

“Hello World”: Capsule Template Syntax

  • @Capsule
  • User-defined

procedure

Console Greeter HelloWorld

slide-45
SLIDE 45

“Hello World”: Capsule Template Syntax

  • @Wired
  • init()
  • User-defined

procedure

Console Greeter HelloWorld

TODO: Change annotations!

slide-46
SLIDE 46

“Hello World”: Capsule Template Syntax

  • @Local
  • design()
  • run()
  • imports()

Console Greeter HelloWorld

TODO: Change annotations!

slide-47
SLIDE 47

Designing Capsule Artifact Inheritance

slide-48
SLIDE 48

Designing Additional Message Types

slide-49
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
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
SLIDE 51

Development Process

  • Rapid Application Development

○ Many prototypes which tackle small problems ○ Documentation along the way

  • Tools Used

○ git, GitHub, GitHub Issues, GitHub wiki ○ Eclipse, Maven