Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.LocalVariableTable


      return EMPTY_STRINGS;
    }

    final int startAtStackIndex = method.isStatic() ? 0 : 1;
    final List<MethodArgument> arguments = new ArrayList<MethodArgument>();
    LocalVariableTable lt = method.getLocalVariableTable();
    if (lt != null) {
      LocalVariable[] lvt = lt.getLocalVariableTable();
      for (int j = 0; j < lvt.length; j++) {
        LocalVariable localVariable = lvt[j];
        if (localVariable.getStartPC() == 0) {
          if (localVariable.getIndex() >= startAtStackIndex) {
            arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
View Full Code Here


  public void determineParameterNames() {
    if ((bitflags & PARAMETER_NAMES_INITIALIZED) != 0) {
      return;
    }
    bitflags |= PARAMETER_NAMES_INITIALIZED;
    LocalVariableTable varTable = method.getLocalVariableTable();
    int len = getArity();
    if (varTable == null) {
      // do we have an annotation with the argNames value specified...
      if (hasAnnotations()) {
        AnnotationAJ[] axs = getAnnotations();
        for (int i = 0; i < axs.length; i++) {
          AnnotationAJ annotationX = axs[i];
          String typename = annotationX.getTypeName();
          if (typename.charAt(0) == 'o') {
            if (typename.equals("org.aspectj.lang.annotation.Pointcut")
                || typename.equals("org.aspectj.lang.annotation.Before")
                || typename.equals("org.aspectj.lang.annotation.Around")
                || typename.startsWith("org.aspectj.lang.annotation.After")) {
              AnnotationGen a = ((BcelAnnotation) annotationX).getBcelAnnotation();
              if (a != null) {
                List<NameValuePair> values = a.getValues();
                for (NameValuePair nvPair : values) {
                  if (nvPair.getNameString().equals("argNames")) {
                    String argNames = nvPair.getValue().stringifyValue();
                    StringTokenizer argNameTokenizer = new StringTokenizer(argNames, " ,");
                    List<String> argsList = new ArrayList<String>();
                    while (argNameTokenizer.hasMoreTokens()) {
                      argsList.add(argNameTokenizer.nextToken());
                    }
                    int requiredCount = getParameterTypes().length;
                    while (argsList.size() < requiredCount) {
                      argsList.add("arg" + argsList.size());
                    }
                    setParameterNames(argsList.toArray(new String[] {}));
                    return;
                  }
                }
              }
            }
          }
        }
      }
      setParameterNames(Utility.makeArgNames(len));
    } else {
      UnresolvedType[] paramTypes = getParameterTypes();
      String[] paramNames = new String[len];
      int index = Modifier.isStatic(modifiers) ? 0 : 1;
      for (int i = 0; i < len; i++) {
        LocalVariable lv = varTable.getLocalVariable(index);
        if (lv == null) {
          paramNames[i] = "arg" + i;
        } else {
          paramNames[i] = lv.getName();
        }
View Full Code Here

        //Here because its easier to collect the information of the
        //(possibly more than one) LocalVariableTables belonging to
        //one certain Code attribute.
        if (atts[a] instanceof LocalVariableTable){ // checks conforming to vmspec2 4.7.9

          LocalVariableTable lvt = (LocalVariableTable) atts[a];

          checkIndex(lvt, lvt.getNameIndex(), CONST_Utf8);

          String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes();
          if (! lvtname.equals("LocalVariableTable")){
            throw new ClassConstraintException("The LocalVariableTable attribute '"+tostring(lvt)+"' is not correctly named 'LocalVariableTable' but '"+lvtname+"'.");
          }

          Code code = obj;

          //In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
          LocalVariable[] localvariables = lvt.getLocalVariableTable();

          for (int i=0; i<localvariables.length; i++){
            checkIndex(lvt, localvariables[i].getNameIndex(), CONST_Utf8);
            String localname = ((ConstantUtf8) cp.getConstant(localvariables[i].getNameIndex())).getBytes();
            if (!validJavaIdentifier(localname)){
View Full Code Here

    /* We cannot use code.getLocalVariableTable() because there could be more
       than only one. This is a bug in BCEL. */
    Attribute[] atts = code.getAttributes();
    for (int a=0; a<atts.length; a++){
      if (atts[a] instanceof LocalVariableTable){
        LocalVariableTable lvt = (LocalVariableTable) atts[a];
        if (lvt != null){
          LocalVariable[] localVariables = lvt.getLocalVariableTable();
          for (int i=0; i<localVariables.length; i++){
            int startpc = localVariables[i].getStartPC();
            int length  = localVariables[i].getLength();
       
            if (!contains(instructionPositions, startpc)){
View Full Code Here

            return EMPTY_STRINGS;
        }

        final int startAtStackIndex = method.isStatic() ? 0 : 1;
        final List arguments = new ArrayList();
        LocalVariableTable lt = (LocalVariableTable) method.getLocalVariableTable();
        if (lt != null) {
            for (int j = 0; j < lt.getLocalVariableTable().length; j++) {
                LocalVariable localVariable = lt.getLocalVariableTable()[j];
                if (localVariable.getStartPC() == 0) {
                    if (localVariable.getIndex() >= startAtStackIndex) {
                        arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
                    }
                }
View Full Code Here

    LocalVariable[]    lv   = new LocalVariable[size];

    for(int i=0; i < size; i++)
      lv[i] = lg[i].getLocalVariable(cp);

    return new LocalVariableTable(cp.addUtf8("LocalVariableTable"),
          2 + lv.length * 10, lv, cp.getConstantPool());
  }
View Full Code Here

    if(il != null)
      byte_code = il.getByteCode();

    LineNumberTable    lnt = null;
    LocalVariableTable lvt = null;
    //J5TODO: LocalVariableTypeTable support!

    /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.)
     */
    if((variable_vec.size() > 0) && !strip_attributes)
View Full Code Here

    ExceptionTable exnTable = method.getExceptionTable();
    checkedExceptions = (exnTable == null)
      ? UnresolvedType.NONE
      : UnresolvedType.forNames(exnTable.getExceptionNames());
     
    LocalVariableTable varTable = method.getLocalVariableTable();
    int len = getArity();
    if (varTable == null) {
      this.parameterNames = Utility.makeArgNames(len);
    } else {
      UnresolvedType[] paramTypes = getParameterTypes();
      String[] paramNames = new String[len];
      int index = isStatic() ? 0 : 1;
      for (int i = 0; i < len; i++) {
        LocalVariable lv = varTable.getLocalVariable(index);
        if (lv == null) {
          paramNames[i] = "arg" + i;
        } else {
          paramNames[i] = lv.getName();
        }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.LocalVariableTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.