CATALOGUE OF REFACTORINGS FOR ASPECTJ

Do Minho, Miguel P. Monteiro · 2004

aspect GeneralPolicy { protected interface Participant {} public Data Participant._sensitiveData; //... } aspect ConcretePolicy extends GeneralPolicy { //code using Participant._sensitiveData } We can add in the superaspect the following ‘declare warning’: abstract aspect GeneralPolicy { protected interface Participant {} public Data Participant._sensitiveData; declare warning: (set(public Data Participant+._sensitiveData) || get(public Data Participant+._sensitiveData)) && !within(GeneralPolicy+): field _sensitiveData is aspect protected. Not visible here.; //... }aspect GeneralPolicy { protected interface Participant {} public Data Participant._sensitiveData; declare warning: (set(public Data Participant+._sensitiveData) || get(public Data Participant+._sensitiveData)) && !within(GeneralPolicy+): field _sensitiveData is aspect protected. Not visible here.; //... } After all warnings are gone, we change the ‘declare warning’ to ‘declare error’. Example: protecting an inter-type Suppose the same abstract aspect as in the previous example also includes processSensitiveData(), which we also would like to protect: abstract aspect GeneralPolicy { protected interface Participant {} public Data Participant._sensitiveData; public void processSensitiveData() { //code using Participant._sensitiveData } //... }aspect GeneralPolicy { protected interface Participant {} public Data Participant._sensitiveData; public void processSensitiveData() { //code using Participant._sensitiveData } //... } We create the following ‘declare warning’: abstract aspect GeneralPolicy { protected interface Participant {} public Data Participant._sensitiveData; public void processSensitiveData() { //code using caspule._sensitiveData } declare warning: call(void processSensitiveData()) && !within(GeneralPolicy+): method processSensitiveData is aspect protected. Not visible here.; //... }aspect GeneralPolicy { protected interface Participant {} public Data Participant._sensitiveData; public void processSensitiveData() { //code using caspule._sensitiveData } declare warning: call(void processSensitiveData()) && !within(GeneralPolicy+): method processSensitiveData is aspect protected. Not visible here.; //... } Likewise, the ‘declare warning’ should be changed to ‘declare error’ when all the warnings are gone.

Read the paper · More papers on PaperTik