Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 JTransformer Framework Tobias Windeln Institut für Informatik III Rheinische Friedrich-Wilhelms-Universität Bonn.

Similar presentations


Presentation on theme: "1 JTransformer Framework Tobias Windeln Institut für Informatik III Rheinische Friedrich-Wilhelms-Universität Bonn."— Presentation transcript:

1 1 JTransformer Framework Tobias Windeln windeln@cs.uni-bonn.de Institut für Informatik III Rheinische Friedrich-Wilhelms-Universität Bonn

2 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 2 JTransformer Framework  Motivation  Idea  Overview  program representation  Query and Transformation API  Conditional Transformations  Future Work: Eclipse Integration  Demo?

3 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 3 Motivation  our need for a program transformation tool with complete source code representation powerful query and transformation API  Applications program analysis refactorings design pattern detection design pattern editor aspect oriented programming  additional requirements source to source byte code analysis (interface of types)

4 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 4 Idea  combine existing approaches logic meta-programming (TyRuBa)  generative program creation  powerful reasoning about programs Conditional Transformations (JContract)  formally structured transformation description  enables transformation analysis Solution  generate a program presentation readable for a logic programming language  use a logic prog. lang. to analyse and transform the program

5 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 5 JTransformer Overview Transformation Module Abstract Syntax Tree in Prolog fact presentation Java Byte code Java Source code Condition Transformations CT Module ConditionAction generation of Prolog facts apply Parser transformed Java source code Writer Transformation Engine

6 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 6 Parser + Program Representation  parses Java Source and Byte Code  checks Java syntax and semantics for source code  adds attributes to tree elements method call: called method field access: referenced field object instantiation: called constructor...  generates Prolog facts for the whole Abstract Syntax Tree (AST) for every node class one predicate  elementNameT(ID, parentID,…) includes all transitively referenced types

7 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 7 Translation Example packageT(100002, 'example'). toplevelT(100001, 100002, 'example/Test.java', [100003]). classDefT(100003, 100002, 'Test', [100005, 100006, 100014]). extendsT(100003, 100019). varDefT(100005, 100003, 100003, type(class, 100004, 0), 's', 'null'). methodDefT(100006, 100003,'setS',[100007],type(basic, 'void', 0),[],100008). modifierT(100006, 'public'). varDefT(100007, 100006, 100006, type(class, 100004, 0), 'val', 'null'). blockT(100008, 100006, 100006, [100009]). execT(100009, 100008, 100006, 100010). assignT(100010, 100009, 100006, 100011, 100012). selectT(100011, 100010, 100006, 's', 100013, 100005). identT(100013, 100011, 100006, 'this', 100003). identT(100012, 100010, 100006, 'val', 100007). methodDefT(100014, 100003,' ',[],type(basic, 'void', 0),[],100015). blockT(100015, 100014, 100014, [100016]). execT(100016, 100015, 100014, 100017). applyT(100017, 100016, 100014, 100018, []). identT(100018, 100017, 100014, 'super', 100019). classDefT(100004, 100025, 'String', [108037, 108038,..., 108240]).... Test.java world.pl package example; class Test { String s; public void setS(String val) { s = val; }

8 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 8 Transformation and Query Engine  logic programming language Prolog analyse + transform program  predicate library subtype full qualified method... higher level predicates for AST Elements  getField, setField, … transformation predicates  AOP (before, after, around) ...

9 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 9 Conditional Transformation (CT)  structure of CTs precondition  structural requirements on the program  binds variables  Prolog term without side effects action  transformation of the program  changes the program based on the variable binding in the precondition  list of Prolog predicates with side effects add, delete, replace AST Elements

10 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 10 Accessor CT ct(addGetterMethods, ( class(_CID, _, _,_), not(externT(_CID)), field(_VID, _CID, _Type, _Name, _), concat('get$',_Name,_MethName), not(method(_, _CID, _MethName, [], _, _, _)), newIDs([_MethID, _BodyID, _ReturnID, _ReadFID]),( add(method(_MethID, _CID, _MethName, [], _Type, [], _BodyID)), add(blockT(_BodyID, _MethID, _MethID, [_ReturnID])), add(returnT(_ReturnID, _BodyID, _MethID, _ReadFID)), add(getField(_ReadFID, _ReturnID, _MethID, 'null', VID)))). class C { int i; String s; } int get$i() { return i; } String get$s() { return s; } Precondition Action

11 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 11 Eclipse JDT Integration  general transformation API for Eclipse  synchronized with program representation in Eclipse with the JTransformer Framework Compiler Abstract Syntax Tree Eclipse Java Editor Transformation Module Abstract Syntax Tree in Prolog fact representation JTransformer synchronized

12 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 12 Advantages of the Integration  current approach each transformation step involves  fact generation  transformation  source generation  compiler run on new sources the source code format and comments are not preserved  Eclipse integration complete fact generation only once afterwards incremental generation of changed source code JTransformer only communicates the changed parts of the AST Eclipse preserves the source code format and comments

13 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 13 Eclipse JDT Integration (3)  will be implemented in the upcoming eXtreme Programming internchip

14 JTransformer: A Transformationsframework for Java - Tobias Windeln - 2003 14 Work Based on JTransformer  ConDor Conflict Detector for CTs  LogicAJ logic meta-programming extension of AspectJ „An Aspect Language with Genericity and Interference Analysis“  DPDetect design pattern detection (Lava Patterns)  PatchWork (???)


Download ppt "1 JTransformer Framework Tobias Windeln Institut für Informatik III Rheinische Friedrich-Wilhelms-Universität Bonn."

Similar presentations


Ads by Google