1 / 17

SOUL for Java Philippe Demaecker @ PROG pdemaeck@vub.ac.be

SOUL for Java Philippe Demaecker @ PROG pdemaeck@vub.ac.be. Context. O bject oriented s ystems Reason about the structure of OO programs U se explicit logic meta-language : SOUL Smalltalk Open Unification Language. SOUL. Logic meta programming language Written in smalltalk

aida
Download Presentation

SOUL for Java Philippe Demaecker @ PROG pdemaeck@vub.ac.be

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SOUL for JavaPhilippe Demaecker @ PROGpdemaeck@vub.ac.be

  2. Context • Object orientedsystems • Reason about the structure of OO programs • Use explicit logic meta-language: SOUL • Smalltalk Open Unification Language

  3. SOUL • Logic meta programming language • Written in smalltalk • Reasons about structure of smalltalk programs • Class interaction • Implementation strategies • Programming style • Design patterns

  4. SOUL reasoning • SOUL base predicates class(?class) superclass(?super, ?sub) instVar(?class, ?iv) method(?class, ?m) • Used on logic representation of Smalltalk programs

  5. Logic representation class(queue). instVar(queue, contents). method(queue, add, [el], [], statements) • statements = list of logic representation of smalltalk statements

  6. Smalltalk body elements • Simple grammar • Literal • Variable • Assignment • Return statement • Message send • Cascaded message • Block

  7. SOUL for java • Can SOUL be applied to Java? • Represent java classes as logic facts • Focus on class files • Java syntax is complicated • Source code is not always available • Class files have more uniform representation

  8. Java class representation

  9. Classes to clauses: c2c • Written in Java • Extracts information from class files • Represents this information as logic facts • Based on existing class parser: BCEL • Byte Code Engineering Library (formerly JavaClass) • Tested on Drawlets

  10. Used representation (1) class(?class). / interface(?class). accessFlag(?class, ?accessFlag). superclass(?class, ?super). directInterface(?class,?interface).

  11. Used representation (2) fieldAccessFlag(?class, ?field, ?flag). fieldDescriptor(?class, ?field,?returnType).

  12. Used representation (3) methodAccessFlag(?class, ?m, ?argList, ?accessFlag). methodReturnType(…, ?returnType). methodBody(…, ?invokesUsedModifiedsList) • invokespecial(invokation) • putfield/putstatic(fieldName) • getfield/getstatic(fieldName)

  13. c2c example: input class public final class LineNumber implements Cloneable{ private int start_pc; LineNumber(DataInputStream file) throws IOException{ this(file.readUnsignedShort(), file.readUnsignedShort());} public final void dump(DataOutputStream file) throws IOException{ file.writeShort(start_pc); file.writeShort(line_number); } … }

  14. c2c example: output (1) class(LineNumber). classAccessFlag(LineNumber, public). classAccessFlag(LineNumber, final). directInterface(LineNumber, java.lang.Cloneable). superClass(LineNumber, java.lang.Object). fieldAccessFlags(LineNumber, start_pc, private). fieldDescriptor(LineNumber, start_pc, int). methodReturnType(LineNumber, LineNumber, [java.io.DataInputStream], void). methodException(LineNumber, LineNumber, [java.io.DataInputStream], java.io.IOException). methodBody(…).

  15. c2c example: output (2) methodAccessFlag(LineNumber, dump, [java.io.DataOutputStream], public). methodAccessFlag(LineNumber, dump, [java.io.DataOutputStream], final). methodReturnType(LineNumber, dump, [java.io.DataOutputStream], void). methodException(LineNumber, dump, [java.io.DataOutputStream], java.io.IOException). methodBody(LineNumber, dump, [java.io.DataOutputStream], [getfield(start_pc), invokevirtual(java.io.DataOutputStream.writeShort(int)), getfield(line_number), invokevirtual(java.io.DataOutputStream.writeShort(int))]).

  16. c2c example: output (3) getfield(LineNumber, dump, [java.io.DataOutputStream], start_pc). invokevirtual(LineNumber, dump, [java.io.DataOutputStream], java.io.DataOutputStream.writeShort(int)). getfield(LineNumber, dump, [java.io.DataOutputStream], line_number). invokevirtual(LineNumber, dump, [java.io.DataOutputStream], java.io.DataOutputStream.writeShort(int)).

  17. Future work • Write documentation • Optimization: • remove unneeded code/classes • Minor adjustments • Additional options • Integrate in SOUL

More Related