Class Utility

java.lang.Object
org.aspectj.weaver.bcel.Utility

public class Utility extends Object
  • Field Details

    • testingParseCounter

      public static int testingParseCounter
      For testing purposes: bit clunky but does work
  • Constructor Details

    • Utility

      public Utility()
  • Method Details

    • readAjAttributes

      public static List<AjAttribute> readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w, AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor)
    • beautifyLocation

      public static String beautifyLocation(ISourceLocation isl)
    • createSuperInvoke

      public static Instruction createSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature)
    • createInvoke

      public static Instruction createInvoke(InstructionFactory fact, BcelWorld world, Member signature)
    • createGet

      public static Instruction createGet(InstructionFactory fact, Member signature)
    • createSet

      public static Instruction createSet(InstructionFactory fact, Member signature)
    • createInstanceof

      public static Instruction createInstanceof(InstructionFactory fact, ReferenceType t)
    • createInvoke

      public static Instruction createInvoke(InstructionFactory fact, LazyMethodGen m)
    • createInvoke

      public static Instruction createInvoke(InstructionFactory fact, short kind, Member member)
      Create an invoke instruction
      Parameters:
      fact -
      kind - INVOKEINTERFACE, INVOKEVIRTUAL..
      member -
      Returns:
    • makeArgNames

      public static String[] makeArgNames(int n)
    • appendConversion

      public static void appendConversion(InstructionList il, InstructionFactory fact, ResolvedType fromType, ResolvedType toType)
    • createConversion

      public static InstructionList createConversion(InstructionFactory factory, Type fromType, Type toType)
    • createConversion

      public static InstructionList createConversion(InstructionFactory fact, Type fromType, Type toType, boolean allowAutoboxing)
    • createConstant

      public static Instruction createConstant(InstructionFactory fact, int value)
    • makeJavaClass

      public static JavaClass makeJavaClass(String filename, byte[] bytes)
    • replaceInstruction

      public static void replaceInstruction(InstructionHandle ih, InstructionList replacementInstructions, LazyMethodGen enclosingMethod)
      replace an instruction handle with another instruction, in this case, a branch instruction.
      Parameters:
      ih - the instruction handle to replace.
      replacementInstructions - the branch instruction to replace ih with
      enclosingMethod - where to find ih's instruction list.
    • deleteInstruction

      public static void deleteInstruction(InstructionHandle ih, LazyMethodGen enclosingMethod)
      delete an instruction handle and retarget all targeters of the deleted instruction to the next instruction. Obviously, this should not be used to delete a control transfer instruction unless you know what you're doing.
      Parameters:
      ih - the instruction handle to delete.
      enclosingMethod - where to find ih's instruction list.
    • deleteInstruction

      public static void deleteInstruction(InstructionHandle ih, InstructionHandle retargetTo, LazyMethodGen enclosingMethod)
      delete an instruction handle and retarget all targeters of the deleted instruction to the provided target.
      Parameters:
      ih - the instruction handle to delete
      retargetTo - the instruction handle to retarget targeters of ih to.
      enclosingMethod - where to find ih's instruction list.
    • copyInstruction

      public static Instruction copyInstruction(Instruction i)
      Fix for Bugzilla #39479, #40109 patch contributed by Andy Clement Need to manually copy Select instructions - if we rely on the the 'fresh' object created by copy(), the InstructionHandle array 'targets' inside the Select object will not have been deep copied, so modifying targets in fresh will modify the original Select - not what we want ! (It is a bug in BCEL to do with cloning Select objects).
       declare error:
           call(* Instruction.copy()) && within(org.aspectj.weaver)
             && !withincode(* Utility.copyInstruction(Instruction)):
           "use Utility.copyInstruction to work-around bug in Select.copy()";
       
    • getSourceLine

      public static int getSourceLine(InstructionHandle ih)
      returns -1 if no source line attribute
    • setSourceLine

      public static void setSourceLine(InstructionHandle ih, int lineNumber)
    • makePublic

      public static int makePublic(int i)
    • pushAndReturnArrayOfVars

      public static BcelVar[] pushAndReturnArrayOfVars(ResolvedType[] proceedParamTypes, InstructionList il, InstructionFactory fact, LazyMethodGen enclosingMethod)
    • isConstantPushInstruction

      public static boolean isConstantPushInstruction(Instruction i)
    • isSuppressing

      public static boolean isSuppressing(Member member, String lintkey)
      Checks for suppression specified on the member or on the declaring type of that member
    • getSuppressedWarnings

      public static List<Lint.Kind> getSuppressedWarnings(AnnotationAJ[] anns, Lint lint)
    • bcelAttribute

      public static Attribute bcelAttribute(AjAttribute a, ConstantPool pool)