DesignWizard (https://sites.google.com/site/designwizardhomepage/) supports automated inspection of Java programs in a higher level than ASM bytecode manipulator.
Other
17
stars
9
forks
source link
Absence of the annotation modifier in external class extraction #39
The error occurs when an internal class (extraction project class) calls one of its methods to an external class of the annotation type. The extraction of external classes is simplified and only creates a corresponding ClassNode without assigning extra information (for example, does not extract modifiers).
As the extraction process extracted the external class in a method call, before it appears as entry in a class, the ClassNode of the external class appears without annotation modifier. This modifier will only be identified when the external class is used to annotate a project class.
However, the extraction code only adds the modifier in new ClassNodes and did not update the classNodes already extracted.
The code below the class org.designwizard.design.Design is responsible for the extraction notes:
@Override
public void annotationExtracted(String entity) {
if (!this.entities.containsKey(entity)) {
ClassNode annotation = new ClassNode(entity);
annotation.modifiers.add(Modifier.ANNOTATION);
this.entities.put(entity, annotation);
}
}
Our proposed modification is to add the modifier in ClassNodes already extracted.
@Override
public void annotationExtracted(String entityName) {
if (!this.entities.containsKey(entityName)) {
ClassNode annotation = new ClassNode(entityName);
annotation.modifiers.add(Modifier.ANNOTATION);
this.entities.put(entityName, annotation);
} else {
ClassNode classNode = (ClassNode) this.entities.get(entityName);
if (classNode != null && !classNode.isAnnotation()) {
classNode.modifiers.add(Modifier.ANNOTATION);
}
}
The error occurs when an internal class (extraction project class) calls one of its methods to an external class of the annotation type. The extraction of external classes is simplified and only creates a corresponding ClassNode without assigning extra information (for example, does not extract modifiers).
As the extraction process extracted the external class in a method call, before it appears as entry in a class, the ClassNode of the external class appears without annotation modifier. This modifier will only be identified when the external class is used to annotate a project class.
However, the extraction code only adds the modifier in new ClassNodes and did not update the classNodes already extracted.
The code below the class org.designwizard.design.Design is responsible for the extraction notes:
Our proposed modification is to add the modifier in ClassNodes already extracted.