Expressive And Modular Predicate Dispatch In Java


Published on

Technical seminar on Jpred By Anjan.K

Published in: Education, Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Predicate : The word or words in a proposition which express what is affirmed of the subject. International Workshop on Foundations and Developments of Object-Oriented Languages FOOL/WOOD<number>
  • Typing is enforcement of the Class of object. Type checking to check whether the message calls conforms to same type.<number>
  • that is, whether
  • Expressive And Modular Predicate Dispatch In Java

    1. 1. Anjan.K II Sem M.Tech Dept of CSE M.S.R.I.T Technical Seminar : EMPD in Java 05/22/09 1
    2. 2.  Prerequisites  Introduction ◦ Paper ◦ Contributions  Dynamic Vs Predicate Dispatch  Salient features-Jpred ◦ Expressiveness ◦ Modular Static type  Jpred - Merits  Demerits  Conclusion And Future Work Technical Seminar : EMPD in Java 05/22/09 2
    3. 3.  Object oriented programming ◦ Languages ◦ Applications ◦ Pillars of OO Concept  Java ◦ Fundamental Of J2SE ◦ Different flavors  Compliers- Open Source Vs Proprietary  Framework like Playgot  Java Virtual Machine (JVM)  Integrated Development Environment (IDE) –eclipse, NetBeans, Myeclipse Technical Seminar : EMPD in Java 05/22/09 3
    4. 4.  Authors – Todd Millstein,  Key Terminologies Christoper Frost, Jason Ryder, ◦ Dynamic Dispatch – a Alessandro Warth of Dept of declarative mechanism Computer Science, University for determining code to of California, LA executed upon function  Initial version of work was invocation. presented at OOPSLA 2004 , ◦ Predicate Dispatch – FOOL/WOOD 2006 and Object oriented TOPLAS 2009 mechanism for determining the method  Permission to use for implementation to be personal or class room as invoked upon predicate digital or hard copies is guard condition. ACM Transaction on Programming Languages and System Vol 31,No2,Article 7 Feb 2009. granted ◦ Jpred compiler to support predicate Technical Seminar : EMPD in Java 05/22/09 4
    5. 5.  Design of Jpred can practically included in traditional OO languages making programming idioms easier to express and validate.  Jpred as extension in FWJava proves it type soundness for modular type checking system and its usage.  In addition to modular type checking strategy Jpred also introduces modular compilation strategy Technical Seminar : EMPD in Java 05/22/09 5
    6. 6. Dynamic Dispatch Predicate Dispatch  Guards are specified  Overriding is done declaratively on method based on predicate  OO Inheritance style, DD logically implication of makes function predicates say m1 & extensible. m2.  Better static type  Includes all support checking then manual concept of DD, approach. multimethod &  Fails to address issues functional-style ◦ Message-not- pattern matching. understood Technical Seminar : EMPD in Java 05/22/09 6
    7. 7.  Jpred ◦ Backward Compatible extension of Java supporting predicate dispatch. ◦ New generation compiler that employs general purpose, off-the-shelf decision procedures. ◦ Compatible with many of the open source Java compilers like playgot, Jikes and even Sun javac and works on standard JVM. ◦ Formally introduced with Java, Featherweight Java and MultiJava. ◦ Included in method declaration with clause when pred before throws clause. Seminar : EMPD in Java 05/22/09 Technical Also called as 7
    8. 8.  Expressiveness – predicate expression pred is Boolean condition under which method may be invoked. Discussed under ◦ Multimethod Dispatch  Event Based System (EBS)  Generalized Multi methods ◦ Interface Dispatch and Ordered Dispatch ◦ Field Dispatch ◦ Equality under Finite State Machine (FSM) ◦ Linear Arithmetic ◦ Pure Methods Technical Seminar : EMPD in Java 05/22/09 8
    9. 9. class FileEditor { class FileEditor { void handle(Event e) { void handle(Event e) if(e instanceof Open) { when e@Open {../* Open File*/} /* Open File*/} void handle(Event e) else if(e instanceof when e@SaveAs SaveAs){ {../* save it new file /*save it new file*/} */} else if (e instanceof void handle(Event e) Save){ when e@SaveAs /*save the file */ } {../* save the file */} File editor {/* Handle in Java else implemented File editor implemented in e) void handle(Event Jpred unexpected events*/} {../* Handle } Technical Seminar : EMPD in Java 05/22/09 9
    10. 10.  Modular Type Checking ◦ Type checking message sends – message type checking in Jpred is exactly as in Java ◦ Type checking method declarations in Jpred requires  Local checks –on each predicate method in isolation  Exhaustiveness Checking – ensure that “message-not-understood” errors cannot happen at runtime. Java and MultiJava shares the same Jpred’s conservatism  Ambiguity Checking – ensure that “message- ambiguous” errors cannot happen atJava 05/22/09 Technical Seminar : EMPD in runtime 10
    11. 11.  CVC3 ◦ Automatic theorem prover for Satisfiability Modulo Theories (SMT) problems. ◦ built-in base theories:  rational and integer linear arithmetic,  arrays, tuples, records, inductive data types,  bit vectors, and  equality over un interpreted function symbols; ◦ checks whether a given formula Φ  is valid in the built-in theories under a given set Γ of assumptions Technical Seminar : EMPD in Java 05/22/09 11
    12. 12.  Jpred is successfully implemented on Polygot-extensilbe compiler framework for Java base compiler being Java 1.5  Typechecking ◦ Local check – performed using existing typechecking pass. ◦ Exhaustive and ambiguity check are made using the algorithm previously discussed  Code Generation ◦ Jpred code in .pj file is generated in two phases  Conversion of Jpred’s Abstract syntax tree(AST) to Java’s AST  Resulting in .java compiled and executed05/22/09standard Technical Seminar : EMPD in Java by 12
    13. 13. Merits Demerits  Quantitative results have  Number of average sized proved that Jpred methods has increased required lesser number  Additionally more of Lines of Code (LOC) number of theorem when compared with Java proving queries to solve  Jpred implementation predicates has clearly eliminated  Single Jpred method manual dispatching logic requires tedious  Greatly reduces the processing under typecasting business MultiJava environment  Compilation is bit greater  Ordered dispatch reduces Technical Seminar : EMPD in Java 05/22/09 13
    14. 14.  Current Jpred build can be extended in many ways  Further support for High-end Java technologies like struts on Myeclipse, Hibernate, portlets  Predicate language currently supports literals of integer and Boolean. Further, its useful to support other Java literals with their associated operation.  Support for Scala-style extractors making predicate dispatch more expressive in the face of Technical Seminar : EMPD in Java 05/22/09 14
    15. 15.  Clear Contrast between Dynamic dispatch and Predicate Dispatch  Need for predicate dispatch  Jpred ◦ Expressiveness ◦ Modular Typechecking strategies  Jpred – an example in EBS  Compilation strategy Technical Seminar : EMPD in Java 05/22/09 15
    16. 16. [1] Eclipse 2007, Eclipse Home page [2] Authors site i.e., University of California [3] Christopher Frost and Todd Millstein, “Modular Typesafe Interface Dispatch in Jpred” at FOOL/WOOD in 2006 [4] Todd Millstein, “Practical Predicate Dispatch” at OOPSLA in 2004 Technical Seminar : EMPD in Java 05/22/09 16