JaMoPP can parse Java source and byte code into EMF-based models and vice versa. It preserves source formatting and can be used for code analysis and refactoring.
The resolver logic is structured into several classes for better seperation of concerns. However, there are more instances of those classes created as necessary.
Code Review Results
JavaDefaultResolverDelegate
is used by the IJavaReferenceResolver implementations (e.g. AnnotationAttributeSettingAttributeReferenceResolver)
They use the deResolve() method only which is thread safe, stateless and process submitted call arguments only.
=> It is an option to let all of them use only a single static instance
IJavaReferenceResolver
The different IJavaReferenceResolver implementations are instantiated by the JavaReferenceResolverSwitch only.
They are all stateless, and all of their setOptions() methods do nothing.
=> All JavaReferenceResolverSwitch instances could use the same resolver instances.
JavaReferenceResolverSwitch
As mentioned before, the resolver in the switch are stateless. The switch's setOptions()-method delegates the options map to the setOptions()-method of the resolvers, which again do nothing.
=> A single instance of the switch would be fine for the whole JaMoPP instance.
=> Within JaMoPP, there are 6 locations creating JavaReferenceResolverSwitch instances. (See screenshot below).
Recommended Adaptation
The locations within the src-gen source directory make all use of the JavaMetaInformation class, which already located in the manually modified source directory. Only JavaResource does create a new switch on it's own. Instead of the JavaResource itself, the JavaSourceOrClassFileResource is used, which is located in java.resource manually adapted source directory.
This allows to modify all 6 locations at already not-generated code locations.
To reduce the instantiation overhead and the memory footprint, these 6 locations should be adapted to request the switch from a factory using the same thread safe singleton.
Optimization Results
With the ArgoUML case study from the SPLevo/KoPL project, for example, the number of delegate instances has been reduced from > 450k (continuously increasing while the case study could not be finished) to 7 constant instances.
Also the switches and Resolvers have been reduced to constant number.
Issue Description
The resolver logic is structured into several classes for better seperation of concerns. However, there are more instances of those classes created as necessary.
Code Review Results
JavaDefaultResolverDelegate
IJavaReferenceResolver
The different IJavaReferenceResolver implementations are instantiated by the JavaReferenceResolverSwitch only. They are all stateless, and all of their setOptions() methods do nothing. => All JavaReferenceResolverSwitch instances could use the same resolver instances.
JavaReferenceResolverSwitch
As mentioned before, the resolver in the switch are stateless. The switch's setOptions()-method delegates the options map to the setOptions()-method of the resolvers, which again do nothing. => A single instance of the switch would be fine for the whole JaMoPP instance. => Within JaMoPP, there are 6 locations creating JavaReferenceResolverSwitch instances. (See screenshot below).
Recommended Adaptation
The locations within the src-gen source directory make all use of the JavaMetaInformation class, which already located in the manually modified source directory. Only JavaResource does create a new switch on it's own. Instead of the JavaResource itself, the JavaSourceOrClassFileResource is used, which is located in java.resource manually adapted source directory. This allows to modify all 6 locations at already not-generated code locations.
To reduce the instantiation overhead and the memory footprint, these 6 locations should be adapted to request the switch from a factory using the same thread safe singleton.
Optimization Results
With the ArgoUML case study from the SPLevo/KoPL project, for example, the number of delegate instances has been reduced from > 450k (continuously increasing while the case study could not be finished) to 7 constant instances. Also the switches and Resolvers have been reduced to constant number.