# JavaAutomata **Repository Path**: linxiaolei/JavaAutomata ## Basic Information - **Project Name**: JavaAutomata - **Description**: This program takes a Java program trace output as input and outputs a visualisation of the program as an automata. - **Primary Language**: Java - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-07-17 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # JavaAutomata Developed By Automateam: Nicky van Hulst David Sheridan Shane Brewer Will Hardwick-Smith Chris Chin Ruben Magallnanas This program takes a Java program trace output as input and outputs a visualisation of the program as an automata. Developer Guide Tracer Package Running a trace To run a trace a new TraceLauncher object needs to be created and the path of the jar you want to trace needs to be passed in this is all you need to be able to call the run method which will trace the program. Parameters Passing parameters to the program. You can pass in the parameters to the program to be traced by calling the set parameters method and passing in a string representing the parameters. Filtering The Trace filtering, to set the filter call the setfilter method with a filter to use if this is left null it will trace all the methods and fields of the traced program. example public static void main(String[] args){ TraceLauncher tr = new TraceLauncher("JarPathName"); tr.setCommandLineArguments("Arguments”); Trace t = tr.run(); } TraceManager Tracemanager can be used to further filter a trace it makes a copy of it upon receiving the trace and a filter can be applied to the copy by calling apply filter. TraceFilterManager This can be used to create a filter by adding methods or fields to it using addMethodsToFilter and addFieldToFilter. ONce all the methods and fields you want to add are added you can use getFilter to get the custom filter. Trace File Format methodObject: {
“methodName”: [\
“stateBefore”: [fieldObject, … ,fieldObject],
“stateAfter”: [fieldObject, … ,fieldObject],
“startState”: [\
“children”: [methodObject, … ,methodObject]
}
fieldObject:
{
“name”: field name,
“value”: field value
}
The trace files are formatted in JSON and contains a single methodObject. This methodObject is the main method that is called from the Java program being run. For any methods called within a method, they get listed in the children field as listed above. This means that any methods called from main are listed in the main methodObject, and any methods called within that method are listed in that methodObject’s children field and so on.
The stateBefore and stateAfter fields represent the state of the program before and after that method has been executed. these fields are made up of a list of fieldObjects as listed above, with each field having a name and value (as they would within a Java program).
Note that the methodName and startState are considered arrays in the format is due to the JSON library used in the TraceToJSON class.
From Program to Automata Visualistation (After the trace has been run):
TraceToJSON: Converts the trace tree into a trace file
TraceToAutomata: Converts a trace file into an automata
AutomataToVisualistation: converts an automata into the JSON format used to visualise automata.
This process is hidden behind calls within the tool. So saving a trace saves the trace tree to a trace file. Then requesting a visualisation from the web page loads a trace file, converts it into an automata and then converts that automata into the JSON format for visualising.
State Package
Not much was done with the classes in the state package other than encapsulating them and documenting them with how we think they work. They are generated in a trace but it was not clear how they were created. From general observation we could see that they were generating correctly and didn’t want to mess with them too much.
Server Package - API included
API:
Requesting a JSON Visualisation.
\