Package org.aspectj.weaver

Examples of org.aspectj.weaver.BCException


        } else if (e instanceof StringLiteral) {
          return new String(((StringLiteral) e).source());
        } else if (e instanceof IntLiteral) {
          return Integer.toString(((IntConstant) e.constant).intValue());
        } else {
          throw new BCException("EclipseResolvedMember.getAnnotationDefaultValue() not implemented for value of type '"
              + e.getClass() + "' - raise an AspectJ bug !");
        }
      }
    }
    return null;
View Full Code Here


  public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
    ExactAnnotationTypePattern ret;
    byte version = s.readByte();
    if (version > VERSION) {
      throw new BCException("ExactAnnotationTypePattern was written by a newer version of AspectJ");
    }
    boolean isBindingPattern = s.readBoolean();
    if (isBindingPattern) {
      ret = new ExactAnnotationTypePattern(s.readUTF());
    } else {
View Full Code Here

        String className = classFile.getClassName();
        ResolvedType theType = world.resolve(className);
        if (theType.isAnnotationStyleAspect()) {
          BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
          if (classType == null) {
            throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
          }
          LazyClassGen clazz = classType.getLazyClassGen();
          BcelPerClauseAspectAdder selfMunger = new BcelPerClauseAspectAdder(theType, theType.getPerClause().getKind());
          selfMunger.forceMunge(clazz, true);
          classType.finishedWith();
          UnwovenClassFile[] newClasses = getClassFilesFor(clazz);
          for (int news = 0; news < newClasses.length; news++) {
            requestor.acceptResult(newClasses[news]);
          }
          wovenClassNames.add(classFile.getClassName());
        }
      }
      requestor.weaveCompleted();
      CompilationAndWeavingContext.leavingPhase(atAspectJMungersOnly);
      return wovenClassNames;
    }

    requestor.processingReweavableState();
    ContextToken reweaveToken = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, "");
    prepareToProcessReweavableState();
    // clear all state from files we'll be reweaving
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      BcelObjectType classType = getClassType(className);

      // null return from getClassType() means the delegate is an eclipse
      // source type - so
      // there *cant* be any reweavable state... (he bravely claimed...)
      if (classType != null) {
        ContextToken tok = CompilationAndWeavingContext.enteringPhase(
            CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, className);
        processReweavableStateIfPresent(className, classType);
        CompilationAndWeavingContext.leavingPhase(tok);
      }
    }

    CompilationAndWeavingContext.leavingPhase(reweaveToken);

    ContextToken typeMungingToken = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, "");
    requestor.addingTypeMungers();

    // We process type mungers in two groups, first mungers that change the
    // type
    // hierarchy, then 'normal' ITD type mungers.

    // Process the types in a predictable order (rather than the order
    // encountered).
    // For class A, the order is superclasses of A then superinterfaces of A
    // (and this mechanism is applied recursively)
    List<String> typesToProcess = new ArrayList<String>();
    for (Iterator<UnwovenClassFile> iter = input.getClassFileIterator(); iter.hasNext();) {
      UnwovenClassFile clf = iter.next();
      typesToProcess.add(clf.getClassName());
    }
    while (typesToProcess.size() > 0) {
      weaveParentsFor(typesToProcess, typesToProcess.get(0), null);
    }

    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      addNormalTypeMungers(className);
    }

    CompilationAndWeavingContext.leavingPhase(typeMungingToken);

    requestor.weavingAspects();
    ContextToken aspectToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
    // first weave into aspects
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
      if (theType.isAspect()) {
        BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
        if (classType == null) {

          // Sometimes.. if the Bcel Delegate couldn't be found then a
          // problem occurred at compile time - on
          // a previous compiler run. In this case I assert the
          // delegate will still be an EclipseSourceType
          // and we can ignore the problem here (the original compile
          // error will be reported again from
          // the eclipse source type) - pr113531
          ReferenceTypeDelegate theDelegate = ((ReferenceType) theType).getDelegate();
          if (theDelegate.getClass().getName().endsWith("EclipseSourceType")) {
            continue;
          }

          throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
        }
        weaveAndNotify(classFile, classType, requestor);
        wovenClassNames.add(className);
      }
    }

    CompilationAndWeavingContext.leavingPhase(aspectToken);

    requestor.weavingClasses();
    ContextToken classToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_CLASSES, "");
    // then weave into non-aspects
    for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
      UnwovenClassFile classFile = i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
      if (!theType.isAspect()) {
        BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
        if (classType == null) {

          // bug 119882 - see above comment for bug 113531
          ReferenceTypeDelegate theDelegate = ((ReferenceType) theType).getDelegate();

          // TODO urgh - put a method on the interface to check this,
          // string compare is hideous
          if (theDelegate.getClass().getName().endsWith("EclipseSourceType")) {
            continue;
          }

          throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
        }
        weaveAndNotify(classFile, classType, requestor);
        wovenClassNames.add(className);
      }
    }
View Full Code Here

      resolved = false;
    }
  }

  public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) {
    throw new BCException("Parameterization not implemented for annotation field binding construct (compiler limitation)");
    // UnresolvedType newAnnotationType = annotationType;
    // if (annotationType.isTypeVariableReference()) {
    // TypeVariableReference t = (TypeVariableReference) annotationType;
    // String key = t.getTypeVariable().getName();
    // if (typeVariableMap.containsKey(key)) {
View Full Code Here

    return (annotationType.hashCode() * 37 + formalIndex * 37) + formalType.hashCode();
  }

  public AnnotationTypePattern remapAdviceFormals(IntMap bindings) {
    if (!bindings.hasKey(formalIndex)) {
      throw new BCException("Annotation field binding reference must be bound (compiler limitation)");
      // must be something like returning the unbound form: return new ExactAnnotationTypePattern(annotationType,
      // null);
    } else {
      int newFormalIndex = bindings.get(formalIndex);
      return new BindingAnnotationFieldTypePattern(formalType, newFormalIndex, annotationType);
View Full Code Here

  }

  public static TypePattern readTypePattern150(VersionedDataInputStream s, ISourceContext context) throws IOException {
    byte version = s.readByte();
    if (version > EXACT_VERSION) {
      throw new BCException("ExactTypePattern was written by a more recent version of AspectJ");
    }
    TypePattern ret = new ExactTypePattern(s.isAtLeast169() ? s.readSignatureAsUnresolvedType() : UnresolvedType.read(s), s
        .readBoolean(), s.readBoolean());
    ret.setAnnotationTypePattern(AnnotationTypePattern.read(s, context));
    ret.setTypeParameters(TypePatternList.read(s, context));
View Full Code Here

    return buff.toString();
  }

  @Override
  public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) {
    throw new BCException("trying to re-resolve");

  }
View Full Code Here

  }

  private static void assertGoodHandle(InstructionHandle ih, Set body, Stack<Range> ranges, String from) {
    Instruction inst = ih.getInstruction();
    if ((inst instanceof InstructionBranch) ^ (ih instanceof BranchHandle)) {
      throw new BCException("bad instruction/handle pair in " + from);
    }
    if (Range.isRangeHandle(ih)) {
      assertGoodRangeHandle(ih, body, ranges, from);
    } else if (inst instanceof InstructionBranch) {
      assertGoodBranchInstruction((BranchHandle) ih, (InstructionBranch) inst, body, ranges, from);
View Full Code Here

  }

  private static void assertGoodBranchInstruction(BranchHandle ih, InstructionBranch inst, Set body, Stack<Range> ranges,
      String from) {
    if (ih.getTarget() != inst.getTarget()) {
      throw new BCException("bad branch instruction/handle pair in " + from);
    }
    InstructionHandle target = ih.getTarget();
    assertInBody(target, body, from);
    assertTargetedBy(target, inst, from);
    if (inst instanceof InstructionSelect) {
View Full Code Here

  }

  /** ih is an InstructionHandle or a BranchInstruction */
  private static void assertInBody(Object ih, Set body, String from) {
    if (!body.contains(ih)) {
      throw new BCException("thing not in body in " + from);
    }
  }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.BCException

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.