SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
Static Checking of Safety
  Critical Java Annotations
    Daniel Tang, Ales Plsek, Jan Vitek                         S3 Lab, Purdue University


                                   http://www.ovmj.net/oscj/



        oSCJ
       Open Safety-Critical Java



Wednesday, September 15, 2010
API Visibility

          public abstract class PeriodicEventHandler
                extends ManagedEventHandler
                implements Runnable {

               public PeriodicEventHandler(...) ...

               public ReleaseParameters getReleaseParameters() ...

               public final void run() {...}




Wednesday, September 15, 2010
API Visibility

         @SCJAllowed(LEVEL_0, members=true)
         class M extends CyclicExecutive {

                  public void initialize() {
                    PEH p = new PEH(...);
                    p.run();
                    ...

         @SCJAllowed(LEVEL_0, members=true)
         class PEH extends PeriodicEventHandler {
          public ReleaseParameters getReleaseParameters(){
               public void handleEvent() {...} ...
          }
Wednesday, September 15, 2010
API Visibility

         @SCJAllowed(LEVEL_0)
         public abstract class PeriodicEventHandler
               extends ManagedEventHandler
               implements Runnable {

                     public PeriodicEventHandler(...) ...

               @SCJAllowed(LEVEL_2)
               public ReleaseParameters getReleaseParameters() ...

               @SCJAllowed(INFRASTRUCTURE)
               public final void run() {}


Wednesday, September 15, 2010
Level Compliance Annotations

                                parameter          values
                                    s             LEVEL_0
                                                  LEVEL_1
                                                  LEVEL_2
                                  value
                                                 SUPPORT
        @SCJAllowed
                                            INFRASTRUCTURE
                                              HIDDEN (default)
                                                   TRUE
                                members
                                               FALSE (default)



Wednesday, September 15, 2010
Phase Restrictions




  USER CODE


Wednesday, September 15, 2010
Phase Restrictions

      class M extends CyclicExecutive {
        public void setUp() {...}
        public void tearDown() {...}
      }




  USER CODE


Wednesday, September 15, 2010
Phase Restrictions

      class M extends CyclicExecutive {
        public void setUp() {...}
        public void tearDown() {...}
      }


    @SCJAllowed(LEVEL_0, members=true)
    class PEH extends
    PeriodicEventHandler {
      public void handleEvent() {
        new PEH(...);
        ...
        getCurrentMission().tearDown();
  USER CODE


Wednesday, September 15, 2010
Phase Restrictions




  USER CODE


Wednesday, September 15, 2010
Phase Restrictions
     class M extends CyclicExecutive {
       ...
       @SCJRestricted(INITIALIZATION)
       public void setUp() {...}
       @SCJRestricted(CLEANUP)
       public void tearDown() {...}
     }




  USER CODE


Wednesday, September 15, 2010
Phase Restrictions
     class M extends CyclicExecutive {
       ...
       @SCJRestricted(INITIALIZATION)
       public void setUp() {...}
       @SCJRestricted(CLEANUP)
       public void tearDown() {...}
     }
   @SCJAllowed(LEVEL_0, members=true)
   class PEH extends PeriodicEventHandler {
      SCJRestricted(EXECUTION)
      public void handleEvent() {
         new PEH(...);
         ...
         getCurrentMission().tearDown();
  USER CODE

   ...
Wednesday, September 15, 2010
Phase Annotations




                                   parameters       values
                                                INITIALIZATION
                 •                   value          RUN
                  @SCJRestricted
                                                  CLEANUP
                                                 ALL (default)




Wednesday, September 15, 2010
Behavior Restrictions

         @SCJAllowed(LEVEL_1)
         public class IH extends InterruptHandler{

               @SCJRestricted(mayAllocate=false,
                              maySelfSuspend=false)
               protected void handleInterrupt() {
                  foo();
               }

               protected void foo() {
                 new PEH(...);
                 sleep(); ...


Wednesday, September 15, 2010
Behavior Restrictions
        @SCJAllowed(LEVEL_1)
        public class IH extends InterruptHandler{

              @SCJRestricted(mayAllocate=false,
                             maySelfSuspend=false)
              protected void handleInterrupt() {
                 foo();
              }

              @SCJRestricted(mayAllocate=false,
                             maySelfSuspend=false)
              protected void foo() {
                  new PEH(...);
                  sleep();

Wednesday, September 15, 2010
Behavior Restrictions



                                  parameters         values
                                                 TRUE (default)
                                 mayAllocate
                                                     FALSE
               @SCJRestricted
                                                     TRUE
                                maySelfSuspend
                                                 FALSE (default)




Wednesday, September 15, 2010
Memory Safety


      class PEH extends PeriodicEventHandler {
        Data data;
        public void handleEvent() {
          R r = new R(this);
          ManagedMemory.getCurrentManagedMemory().
                        enterPrivateMemory(3000, r); ...

      class R implements Runnable {
        PEH p;
        public void run() { p.data = new Data(); }
      }
      class Data { ... }


Wednesday, September 15, 2010
Memory Safety


      class PEH extends PeriodicEventHandler {
        Data data;
        public void handleEvent() {
          R r = new R(this);
          ManagedMemory.getCurrentManagedMemory().
                        enterPrivateMemory(3000, r); ...

      class R implements Runnable {
        PEH p;
        public void run() { p.data = new Data(); }
      }
      class Data { ... }


Wednesday, September 15, 2010
Memory Safety
      class PEH extends PeriodicEventHandler {
                                     Runnable      new Data()
       Data data;                    Memory
        R r = new R(this);
          enterPrivateMemory(r); ...   PEH       data
                                      Memory
      class R implements Runnable {
        PEH p;                        Mission      PEH
        pp.data = new Data(); }       Memory
      }
      class Data




Wednesday, September 15, 2010
Memory Safety

      @Scope("M") @RunsIn("PEH")
      class PEH extends PeriodicEventHandler {
        Data data;
        public void handleEvent() {
          @DefineScope(name="R", parent="PEH")
          R r = new R(this);
          ManagedMemory.getCurrentManagedMemory().
                        enterPrivateMemory(3000, r); ...

      @Scope("PEH") @RunsIn("R")
      class R implements Runnable {
        PEH p;
        public void run() { p.data = new Data(); }
      }
      @Scope("R") class Data { ... }
Wednesday, September 15, 2010
Memory Safety

      @Scope("M") @RunsIn("PEH")
      class PEH extends PeriodicEventHandler {
        Data data;
        public void handleEvent() {
          @DefineScope(name="R", parent="PEH")
          R r = new R(this);
          ManagedMemory.getCurrentManagedMemory().
                        enterPrivateMemory(3000, r); ...

      @Scope("PEH") @RunsIn("R")
      class R implements Runnable {
        PEH p;
        public void run() { p.data = new Data(); }
      }
      @Scope("R") class Data { ... }
Wednesday, September 15, 2010
Memory Safety Annotations


                                parameters                        values

                                  name       a name of newly defined scope
          @DefineScope
                                  parent     a parenting scope of a new scope


                @Scope            name       a name of scope in which the object is allocated

               @RunsIn            name       name of scope where a method will allocate




Wednesday, September 15, 2010
@Scope

      @Scope("M") @RunsIn("PEH")
      class PEH extends PeriodicEventHandler {

               ... new Data() ....
      }


      @Scope("PEH") @RunsIn("R")
      class R implements Runnable {
        ... new Data() ...
      }

      @Scope("R") class Data { ... }



Wednesday, September 15, 2010
Objects with no @Scope

      @Scope("M") @RunsIn("PEH")
      class PEH extends PeriodicEventHandler {

               ... new Data() ....
      }


      @Scope("PEH") @RunsIn("R")
      class R implements Runnable {
       ... new Data() ...

      }

      class Data { ... }

Wednesday, September 15, 2010
Class and Fields
    @Scope("M") @RunsIn("PEH")
    class Clazz {
       Field f;           Field must be in the same or
       Data d;           parent scope


            @RunsIn("R")
            public void foo(Data d) {
                 this.d = d;     d may not reside in immortal
             }
    }



    @Scope("R") class Field { ... }

    class Data { ... }          no @Scope annotation
Wednesday, September 15, 2010
Class Casting

      @Scope("PEH") @RunsIn("R")
      class R implements Runnable {
        ... Foo f = (Foo) new Data() ...
      }



      class Foo { ... }



      @Scope("R") class Data extends Foo { ... }




Wednesday, September 15, 2010
Enter Child Scope

    @Scope("M") @RunsIn("PEH")
    class PEH
        ...
        @DefineScope(name="R", parent="PEH")
        R r = new R(this);
        ManagedMemory.getCurrentManagedMemory().
                      enterPrivateMemory(3000, r); ...

               @DefineScope(name="R2", parent="PEH")
               R r2 = new R(this); ....



    @Scope("PEH") @RunsIn("R")
    class R implements Runnable { ...}
Wednesday, September 15, 2010
Conclusion
      • Checker Implementation

                 • Java 7 Checker Framework
                 • Compile-time checking (Eclipse plugin coming soon)
      • Evaluation

                 • miniCDj benchmark Case Study
                       • ~100 annotations, ~100 examples in the Checker distribution
                 • @SCJAllowed and @SCJRestricted easy to use
                 • Memory safety annotations
                 • Sometimes overly restrictive, resulting in class duplication




Wednesday, September 15, 2010
Safety Critical Java
      • High level story: Java for safety critical systems

                 • Safety critical systems may cause harm to persons if they fail, so they require
                   vigorous certifications
                 • SCJ compliance levels


      • Java annotations may help the certification process

                 • A mechanism for adding metadata to Java constructs for compile-time or
                   run-time processing
                 • Java annotations preserved in the bytecode as well
                 • Enhanced in Java 7 by allowing use in more constructs, enabling
                   construction of pluggable type systems in Java




Wednesday, September 15, 2010

Más contenido relacionado

La actualidad más candente

Towards Reusable Components With Aspects [ICSE 2008]
Towards Reusable Components With Aspects [ICSE 2008]Towards Reusable Components With Aspects [ICSE 2008]
Towards Reusable Components With Aspects [ICSE 2008]Kevin Hoffman
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습DoHyun Jung
 
Easy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEEasy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEUehara Junji
 
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for EducationPythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for EducationECAM Brussels Engineering School
 
Practical Migration to Java 7
Practical Migration to Java 7Practical Migration to Java 7
Practical Migration to Java 7Markus Eisele
 
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"ZendCon
 
VJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript togetherVJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript togetherJustin Early
 

La actualidad más candente (8)

Towards Reusable Components With Aspects [ICSE 2008]
Towards Reusable Components With Aspects [ICSE 2008]Towards Reusable Components With Aspects [ICSE 2008]
Towards Reusable Components With Aspects [ICSE 2008]
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
 
Easy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEEasy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVE
 
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for EducationPythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
 
Practical Migration to Java 7
Practical Migration to Java 7Practical Migration to Java 7
Practical Migration to Java 7
 
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
Architecting for PHP5 - Why "Runs on PHP5" is not "Written for PHP5"
 
VJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript togetherVJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript together
 
Commons Nabla
Commons NablaCommons Nabla
Commons Nabla
 

Similar a Jtres checker

How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeDaniel Wellman
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Cleverson Sacramento
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
 
Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9Ismar Silveira
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
About java
About javaAbout java
About javaJay Xu
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 
Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Anton Arhipov
 
Generic Types in Java (for ArtClub @ArtBrains Software)
Generic Types in Java (for ArtClub @ArtBrains Software)Generic Types in Java (for ArtClub @ArtBrains Software)
Generic Types in Java (for ArtClub @ArtBrains Software)Andrew Petryk
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondMario Fusco
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à DartSOAT
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Javaelliando dias
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Python mu Java mı?
Python mu Java mı?Python mu Java mı?
Python mu Java mı?aerkanc
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 

Similar a Jtres checker (20)

How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010
 
In kor we Trust
In kor we TrustIn kor we Trust
In kor we Trust
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камни
 
Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
About java
About javaAbout java
About java
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012
 
Generic Types in Java (for ArtClub @ArtBrains Software)
Generic Types in Java (for ArtClub @ArtBrains Software)Generic Types in Java (for ArtClub @ArtBrains Software)
Generic Types in Java (for ArtClub @ArtBrains Software)
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à Dart
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Python mu Java mı?
Python mu Java mı?Python mu Java mı?
Python mu Java mı?
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++
 

Jtres checker

  • 1. Static Checking of Safety Critical Java Annotations Daniel Tang, Ales Plsek, Jan Vitek S3 Lab, Purdue University http://www.ovmj.net/oscj/ oSCJ Open Safety-Critical Java Wednesday, September 15, 2010
  • 2. API Visibility public abstract class PeriodicEventHandler extends ManagedEventHandler implements Runnable { public PeriodicEventHandler(...) ... public ReleaseParameters getReleaseParameters() ... public final void run() {...} Wednesday, September 15, 2010
  • 3. API Visibility @SCJAllowed(LEVEL_0, members=true) class M extends CyclicExecutive { public void initialize() { PEH p = new PEH(...); p.run(); ... @SCJAllowed(LEVEL_0, members=true) class PEH extends PeriodicEventHandler { public ReleaseParameters getReleaseParameters(){ public void handleEvent() {...} ... } Wednesday, September 15, 2010
  • 4. API Visibility @SCJAllowed(LEVEL_0) public abstract class PeriodicEventHandler extends ManagedEventHandler implements Runnable { public PeriodicEventHandler(...) ... @SCJAllowed(LEVEL_2) public ReleaseParameters getReleaseParameters() ... @SCJAllowed(INFRASTRUCTURE) public final void run() {} Wednesday, September 15, 2010
  • 5. Level Compliance Annotations parameter values s LEVEL_0 LEVEL_1 LEVEL_2 value SUPPORT @SCJAllowed INFRASTRUCTURE HIDDEN (default) TRUE members FALSE (default) Wednesday, September 15, 2010
  • 6. Phase Restrictions USER CODE Wednesday, September 15, 2010
  • 7. Phase Restrictions class M extends CyclicExecutive { public void setUp() {...} public void tearDown() {...} } USER CODE Wednesday, September 15, 2010
  • 8. Phase Restrictions class M extends CyclicExecutive { public void setUp() {...} public void tearDown() {...} } @SCJAllowed(LEVEL_0, members=true) class PEH extends PeriodicEventHandler { public void handleEvent() { new PEH(...); ... getCurrentMission().tearDown(); USER CODE Wednesday, September 15, 2010
  • 9. Phase Restrictions USER CODE Wednesday, September 15, 2010
  • 10. Phase Restrictions class M extends CyclicExecutive { ... @SCJRestricted(INITIALIZATION) public void setUp() {...} @SCJRestricted(CLEANUP) public void tearDown() {...} } USER CODE Wednesday, September 15, 2010
  • 11. Phase Restrictions class M extends CyclicExecutive { ... @SCJRestricted(INITIALIZATION) public void setUp() {...} @SCJRestricted(CLEANUP) public void tearDown() {...} } @SCJAllowed(LEVEL_0, members=true) class PEH extends PeriodicEventHandler { SCJRestricted(EXECUTION) public void handleEvent() { new PEH(...); ... getCurrentMission().tearDown(); USER CODE ... Wednesday, September 15, 2010
  • 12. Phase Annotations parameters values INITIALIZATION • value RUN @SCJRestricted CLEANUP ALL (default) Wednesday, September 15, 2010
  • 13. Behavior Restrictions @SCJAllowed(LEVEL_1) public class IH extends InterruptHandler{ @SCJRestricted(mayAllocate=false, maySelfSuspend=false) protected void handleInterrupt() { foo(); } protected void foo() { new PEH(...); sleep(); ... Wednesday, September 15, 2010
  • 14. Behavior Restrictions @SCJAllowed(LEVEL_1) public class IH extends InterruptHandler{ @SCJRestricted(mayAllocate=false, maySelfSuspend=false) protected void handleInterrupt() { foo(); } @SCJRestricted(mayAllocate=false, maySelfSuspend=false) protected void foo() { new PEH(...); sleep(); Wednesday, September 15, 2010
  • 15. Behavior Restrictions parameters values TRUE (default) mayAllocate FALSE @SCJRestricted TRUE maySelfSuspend FALSE (default) Wednesday, September 15, 2010
  • 16. Memory Safety class PEH extends PeriodicEventHandler { Data data; public void handleEvent() { R r = new R(this); ManagedMemory.getCurrentManagedMemory(). enterPrivateMemory(3000, r); ... class R implements Runnable { PEH p; public void run() { p.data = new Data(); } } class Data { ... } Wednesday, September 15, 2010
  • 17. Memory Safety class PEH extends PeriodicEventHandler { Data data; public void handleEvent() { R r = new R(this); ManagedMemory.getCurrentManagedMemory(). enterPrivateMemory(3000, r); ... class R implements Runnable { PEH p; public void run() { p.data = new Data(); } } class Data { ... } Wednesday, September 15, 2010
  • 18. Memory Safety class PEH extends PeriodicEventHandler { Runnable new Data() Data data; Memory R r = new R(this); enterPrivateMemory(r); ... PEH data Memory class R implements Runnable { PEH p; Mission PEH pp.data = new Data(); } Memory } class Data Wednesday, September 15, 2010
  • 19. Memory Safety @Scope("M") @RunsIn("PEH") class PEH extends PeriodicEventHandler { Data data; public void handleEvent() { @DefineScope(name="R", parent="PEH") R r = new R(this); ManagedMemory.getCurrentManagedMemory(). enterPrivateMemory(3000, r); ... @Scope("PEH") @RunsIn("R") class R implements Runnable { PEH p; public void run() { p.data = new Data(); } } @Scope("R") class Data { ... } Wednesday, September 15, 2010
  • 20. Memory Safety @Scope("M") @RunsIn("PEH") class PEH extends PeriodicEventHandler { Data data; public void handleEvent() { @DefineScope(name="R", parent="PEH") R r = new R(this); ManagedMemory.getCurrentManagedMemory(). enterPrivateMemory(3000, r); ... @Scope("PEH") @RunsIn("R") class R implements Runnable { PEH p; public void run() { p.data = new Data(); } } @Scope("R") class Data { ... } Wednesday, September 15, 2010
  • 21. Memory Safety Annotations parameters values name a name of newly defined scope @DefineScope parent a parenting scope of a new scope @Scope name a name of scope in which the object is allocated @RunsIn name name of scope where a method will allocate Wednesday, September 15, 2010
  • 22. @Scope @Scope("M") @RunsIn("PEH") class PEH extends PeriodicEventHandler { ... new Data() .... } @Scope("PEH") @RunsIn("R") class R implements Runnable { ... new Data() ... } @Scope("R") class Data { ... } Wednesday, September 15, 2010
  • 23. Objects with no @Scope @Scope("M") @RunsIn("PEH") class PEH extends PeriodicEventHandler { ... new Data() .... } @Scope("PEH") @RunsIn("R") class R implements Runnable { ... new Data() ... } class Data { ... } Wednesday, September 15, 2010
  • 24. Class and Fields @Scope("M") @RunsIn("PEH") class Clazz { Field f; Field must be in the same or Data d; parent scope @RunsIn("R") public void foo(Data d) { this.d = d; d may not reside in immortal } } @Scope("R") class Field { ... } class Data { ... } no @Scope annotation Wednesday, September 15, 2010
  • 25. Class Casting @Scope("PEH") @RunsIn("R") class R implements Runnable { ... Foo f = (Foo) new Data() ... } class Foo { ... } @Scope("R") class Data extends Foo { ... } Wednesday, September 15, 2010
  • 26. Enter Child Scope @Scope("M") @RunsIn("PEH") class PEH ... @DefineScope(name="R", parent="PEH") R r = new R(this); ManagedMemory.getCurrentManagedMemory(). enterPrivateMemory(3000, r); ... @DefineScope(name="R2", parent="PEH") R r2 = new R(this); .... @Scope("PEH") @RunsIn("R") class R implements Runnable { ...} Wednesday, September 15, 2010
  • 27. Conclusion • Checker Implementation • Java 7 Checker Framework • Compile-time checking (Eclipse plugin coming soon) • Evaluation • miniCDj benchmark Case Study • ~100 annotations, ~100 examples in the Checker distribution • @SCJAllowed and @SCJRestricted easy to use • Memory safety annotations • Sometimes overly restrictive, resulting in class duplication Wednesday, September 15, 2010
  • 28. Safety Critical Java • High level story: Java for safety critical systems • Safety critical systems may cause harm to persons if they fail, so they require vigorous certifications • SCJ compliance levels • Java annotations may help the certification process • A mechanism for adding metadata to Java constructs for compile-time or run-time processing • Java annotations preserved in the bytecode as well • Enhanced in Java 7 by allowing use in more constructs, enabling construction of pluggable type systems in Java Wednesday, September 15, 2010