blob: 1daf321fb76548ab3dec2e57c0e8956cc0c55e5c [file] [log] [blame]
Federico Tomassettif81802b2016-09-21 10:24:09 +02001# Architecture and Design
2
Federico Tomassetti9dcca182016-10-20 22:27:51 +02003This document describe the architecture and design of JavaSymbolSolver.
Federico Tomassettif81802b2016-09-21 10:24:09 +02004
5## Goal of the project
6
7The basic idea is to be able to resolve all sorts of symbols:
8
9* field, variable, parameter references
10* type references
11* calculate the type of expressions
12* determine which methods are invoked out of the several overload possible
Federico Tomassetti9dcca182016-10-20 22:27:51 +020013
14# Organization
15
16The project is divided in four modules:
17
18* **model**: it contains the interfaces of all declarations used by JavaSymbolSolver such as _ClassDeclaration_, _ParameterDeclaration_, _MethodDeclaration_, etc.
19* **logic**: it contains general logic to operate on declarations, for example to perform method resolution
20* **core**: it contains most of the implementation including all the implementation of all the interfaces for source code (using JavaParser), compiled code (using Javassist) and JRE standard libraries (using reflection)
21* **examples**: examples of possible usages of JavaSymbolSolver
Federico Tomassettif81802b2016-09-21 10:24:09 +020022
23# Strategy
24
25## Resolving types
26
27Given a reference to a declared type such as `Object`, `java.lang.String`, or `Foo` we need to figure out to which declaration
28it corresponds. Declarations can derive from three sources:
29
30* Compiled classes (class files contained in a directory or a JAR file)
31* Java source code
32* Classes from the JRE for which we do not have JAR classes. We access them through reflection
33
34To each of these types correspond an implementation of a `TypeSolver`.
35
36We consider the way Java resolve types (considering imports, using simple names for classes in the same package, usage
37of canonical names) and we look at the different sources we have to find the types definitions.
38
39# Resources
40
41TODO: link to articles on tomassetti.me