51
@PaniniJ: Generating Capsule Systems from Annotated Java Dec15-12: Trey Erenberger, Dalton Mills, and David Johnston

@PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

@PaniniJ: Generating Capsule Systems from Annotated JavaDec15-12: Trey Erenberger, Dalton Mills, and David Johnston

Page 2: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Overview● Project Foundations: Capsule Oriented Programming● Goals of @PaniniJ● How It Works● Usability and Maintainability Improvements

Page 3: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Project Goal

Make Capsule Oriented Programming more accessible to Java programmers

Page 4: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Concurrent Programming

Concurrent Programming in Java is Hard

Page 5: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

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!”);

Page 6: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

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.

Page 7: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

The Problem With PaniniJ: Few Development Tools

Page 8: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Build an Eclipse Plugin for PaniniJ to:● Fix red squiggles● Provide useful compilation errors & warnings● Enable code completion & IDE features

Initial Project Specification

Page 9: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Eclipse Plugin

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

Page 10: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

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.

Page 11: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Alternative: Compiler Plugin

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

Page 12: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Deciding Factor: Use Standard Tools

Standard compiler plugin strategy met all 3 goals.

Bring panini to tools rather than tools to panini.

Page 13: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

@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.

Page 14: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Code Generation

Page 15: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

User’s Capsule Templates

(.java files)

Auto-Generated Source Artifacts

(.java files)

Executable Capsule System

(.class files)

Annotation Processing Pipeline

Page 16: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

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

Page 17: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Capsule System Includes Many Artifacts From Many Capsule Templates

Page 18: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

User’s Capsule Template

Page 19: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

User’s Capsule Template

Capsule Interface

Capsule$Thread

Inter-Capsule Messages

Page 20: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Generated Capsule Interface

Page 21: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

User’s Capsule Template

Capsule Interface

Capsule$Thread

Inter-Capsule Messages

Page 22: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Generated Multithreaded Wrapper

Page 23: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

User’s Capsule Template

Capsule Interface

Capsule$Thread

Inter-Capsule Messages

Page 24: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Generated Message Wrapper

Page 25: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

User’s Capsule Template

Capsule Interface

Capsule$Thread

Inter-Capsule Messages

Page 26: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Static Checks

Page 27: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Static CheckingExposing Panini Model via IDE● Rules identified and implemented as checks.● Reported from annotation processor● Violations displayed in context● 45 checks implemented

Page 28: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Static Checking in Eclipse

Page 29: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Static Checking in NetBeans

Page 30: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Improving Maintainability and Usability

Page 31: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Annotation Processor

PaniniProcessor: Refactored Capsule Processing Dataflow

@CapsuleTemplate(.java) Capsule

Artifacts(.java)

CapsuleTemplateChecks

CapsuleModel Capsule

Artifact Factories

MessageArtifact

Factories

MessageArtifacts(.java)

Return Type

Models

Param Type

Models

ProcedureModels

Page 32: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Testing Methods● Invoke compiler with Maven● Programmatically invoke compiler with javax.tools● Unit testing with Google’s compile-testing

Improving Testing

Page 33: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Getting Started Website

Page 34: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Usability: Documentation

Annotation Processor Javadoc

Page 35: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

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.

Page 36: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Questions?

Page 37: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Questions?

Page 38: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

● Background: Capsules and PaniniJ● Identify (specific) client goals● Reformulated project as @PaniniJ● Built working prototype

Spring Semester

Page 39: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Fall Semester● Refine Prototype into Product

○ Processor Refactor○ Unit & Integration Tests

● Documentation● Usability Enhancements

○ Static Checks○ Setup/Compile/Run Ease

● v0.1.0 release

Page 40: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Example Program:“Hello, World!”

Page 41: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

“Hello World” Example

ConsoleWrites a string

GreeterStores and sends a

greetingHelloWorldCreates and drives activity

Page 42: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

“Hello World” Example

Consolewrite(String)

Greetergreet()

HelloWorldrun()

Page 43: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

“Hello World” Example

Console

Greeter { @Imports Stream s}HelloWorld {

@Local Greeter g; @Local Console c;}

Page 44: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

“Hello World”: Capsule Template Syntax

● @Capsule

● User-defined procedure

Console

GreeterHelloWorld

Page 45: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

“Hello World”: Capsule Template Syntax

● @Wired

● init()

● User-defined procedure

Console

GreeterHelloWorld

TODO: Change annotations!

Page 46: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

“Hello World”: Capsule Template Syntax

● @Local

● design()

● run()

● imports()

Console

GreeterHelloWorld

TODO: Change annotations!

Page 47: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Designing Capsule Artifact Inheritance

Page 48: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Designing Additional Message Types

Page 49: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

Background: Our Client

● ISU Laboratory For Software Design● Advisor: Dr. Hridesh Rajan● Research:

○ Software Engineering

○ Programming Language Design

● Collaborators: Panini Project Grad Students

Page 50: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

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.

Page 51: @PaniniJ: Generating Capsule Systems from Annotated Javadec1512.sd.ece.iastate.edu/docs/project/final-presentation.pdf · Standard compiler plugin strategy met all 3 goals. Bring

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