1 24 25 package org.aspectj.compiler.crosscuts; 26 27 import org.aspectj.compiler.base.ast.*; 28 import org.aspectj.compiler.base.JavaCompiler; 29 import org.aspectj.compiler.base.AbstractCompilerPass; 30 import org.aspectj.compiler.base.WorldPass; 31 import org.aspectj.compiler.base.CompilationUnitPass; 32 33 import java.util.*; 34 35 import org.aspectj.compiler.crosscuts.ast.AspectDec; 36 37 38 39 public class PrivilegeFixer extends AbstractCompilerPass { 40 private boolean apply; 41 42 46 47 public PrivilegeFixer(JavaCompiler compiler, boolean apply) { 48 super(compiler); 49 this.apply = apply; 50 } 51 52 public String getDisplayName() { 53 return (apply ? "implement":"plan") + " backdoors"; 54 } 55 56 public void transform(TypeDec td) { 57 AccessFixer fixer = new AccessFixer(getCompiler(), td, apply); 61 fixer.fixAccesses(td); 62 } 64 65 70 private void checkTypeDecs(CompilationUnit cu, boolean apply) { 71 List typeDecs = cu.getDefinedTypes(); 72 final int N = typeDecs.size(); 73 74 for (int j = 0; j < N; j++) { 75 Dec dec = (Dec)typeDecs.get(j); 76 if (dec instanceof TypeDec) { 77 TypeDec typeDec = (TypeDec)dec; 78 if (typeDec instanceof AspectDec && 79 typeDec.getModifiers().isPrivileged()) 80 { 81 AccessFixer fixer = new AccessFixer(getCompiler(), typeDec, apply); 83 fixer.fixAccesses(typeDec); 84 } 85 86 fixIntroducedDecs( typeDec, apply ); 87 } 88 } 89 } 90 91 private void fixIntroducedDecs(TypeDec typeDec, boolean apply) { 92 94 Decs decs = typeDec.getBody(); 95 96 for(int i=0; i < decs.size(); i++) { 97 Dec dec = (Dec)decs.get(i); 98 if (dec.isIntroduced()) { 100 new AccessFixer(getCompiler(), typeDec, apply).fixAccesses(dec); 101 } 102 } 103 } 104 } 105 | Popular Tags |