Package org.aspectj.weaver

Examples of org.aspectj.weaver.UnresolvedType


    annotationType = scope.getWorld().resolve(annotationType, true);

    // May not be directly found if in a package, so go looking if that is the case:
    if (ResolvedType.isMissing(annotationType)) {
      String cleanname = annotationType.getName();
      UnresolvedType type = null;
      while (ResolvedType.isMissing(type = scope.lookupType(cleanname, this))) {
        int lastDot = cleanname.lastIndexOf('.');
        if (lastDot == -1) {
          break;
        }
View Full Code Here


  }

  public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
    ExactAnnotationFieldTypePattern ret;
    String formalName = s.readUTF();
    UnresolvedType annotationType = UnresolvedType.read(s);
    ret = new ExactAnnotationFieldTypePattern(annotationType, formalName);
    ret.readLocation(context, s);
    return ret;
  }
View Full Code Here

   */
  protected Test findResidueInternal(Shadow shadow, ExposedState state) {

    if (annotationTypePattern instanceof BindingAnnotationTypePattern) {
      BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern;
      UnresolvedType annotationType = btp.annotationType;
      Var var = shadow.getWithinCodeAnnotationVar(annotationType);

      // This should not happen, we shouldn't have gotten this far
      // if we weren't going to find the annotation
      if (var == null) {
View Full Code Here

    if (typePattern == TypePattern.NO) {
      return null; // already had an error here
    }

    // isWildChild = (child instanceof WildTypePattern);
    UnresolvedType iType = typePattern.getExactType();
    ResolvedType parentType = iType.resolve(world);

    if (targetType.equals(world.getCoreType(UnresolvedType.OBJECT))) {
      world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.DECP_OBJECT), this.getSourceLocation(), null);
      return null;
    }

    // Ensure the target doesn't already have an
    // alternate parameterization of the generic type on it
    if (parentType.isParameterizedType() || parentType.isRawType()) {
      // Let's take a look at the parents we already have
      boolean isOK = verifyNoInheritedAlternateParameterization(targetType, parentType, world);
      if (!isOK) {
        return null;
      }
    }

    if (parentType.isAssignableFrom(targetType)) {
      return null; // already a parent
    }

    // Enum types that are targetted for decp through a wild type pattern get linted
    if (reportErrors && isWildChild && targetType.isEnum()) {
      world.getLint().enumAsTargetForDecpIgnored.signal(targetType.toString(), getSourceLocation());
    }

    // Annotation types that are targetted for decp through a wild type pattern get linted
    if (reportErrors && isWildChild && targetType.isAnnotation()) {
      world.getLint().annotationAsTargetForDecpIgnored.signal(targetType.toString(), getSourceLocation());
    }

    // 1. Can't use decp to make an enum/annotation type implement an interface
    if (targetType.isEnum() && parentType.isInterface()) {
      if (reportErrors && !isWildChild) {
        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ENUM_TO_IMPL_INTERFACE,
            targetType), getSourceLocation(), null);
      }
      return null;
    }
    if (targetType.isAnnotation() && parentType.isInterface()) {
      if (reportErrors && !isWildChild) {
        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ANNOTATION_TO_IMPL_INTERFACE,
            targetType), getSourceLocation(), null);
      }
      return null;
    }

    // 2. Can't use decp to change supertype of an enum/annotation
    if (targetType.isEnum() && parentType.isClass()) {
      if (reportErrors && !isWildChild) {
        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ENUM_TO_EXTEND_CLASS,
            targetType), getSourceLocation(), null);
      }
      return null;
    }
    if (targetType.isAnnotation() && parentType.isClass()) {
      if (reportErrors && !isWildChild) {
        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ANNOTATION_TO_EXTEND_CLASS,
            targetType), getSourceLocation(), null);
      }
      return null;
    }

    // 3. Can't use decp to declare java.lang.Enum/java.lang.annotation.Annotation as the parent of a type
    if (parentType.getSignature().equals(UnresolvedType.ENUM.getSignature())) {
      if (reportErrors && !isWildChild) {
        world.showMessage(IMessage.ERROR, WeaverMessages
            .format(WeaverMessages.CANT_DECP_TO_MAKE_ENUM_SUPERTYPE, targetType), getSourceLocation(), null);
      }
      return null;
    }
    if (parentType.getSignature().equals(UnresolvedType.ANNOTATION.getSignature())) {
      if (reportErrors && !isWildChild) {
        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_TO_MAKE_ANNOTATION_SUPERTYPE,
            targetType), getSourceLocation(), null);
      }
      return null;
    }

    if (parentType.isAssignableFrom(targetType)) {
      return null; // already a parent
    }

    if (targetType.isAssignableFrom(parentType)) {
      world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_EXTEND_SELF, targetType.getName()), this
          .getSourceLocation(), null);
      return null;
    }

    if (parentType.isClass()) {
      if (targetType.isInterface()) {
        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.INTERFACE_CANT_EXTEND_CLASS), this
            .getSourceLocation(), null);
        return null;
        // how to handle xcutting errors???
      }

      if (!targetType.getSuperclass().isAssignableFrom(parentType)) {
        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.DECP_HIERARCHY_ERROR, iType.getName(),
            targetType.getSuperclass().getName()), this.getSourceLocation(), null);
        return null;
      } else {
        return parentType;
      }
View Full Code Here

    exceptionType = exceptionType.resolveBindings(scope, bindings, false, false);
    boolean invalidParameterization = false;
    if (exceptionType.getTypeParameters().size() > 0) {
      invalidParameterization = true;
    }
    UnresolvedType exactType = exceptionType.getExactType();
    if (exactType != null && exactType.isParameterizedType()) {
      invalidParameterization = true;
    }
    if (invalidParameterization) {
      // no parameterized or generic types for handler
      scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.HANDLER_PCD_DOESNT_SUPPORT_PARAMETERS),
View Full Code Here

    }

    World world = shadow.getIWorld();

    // warning never needed if the declaring type is any
    UnresolvedType exactDeclaringType = signature.getDeclaringType().getExactType();

    ResolvedType shadowDeclaringType = shadow.getSignature().getDeclaringType().resolve(world);

    if (signature.getDeclaringType().isStar() || ResolvedType.isMissing(exactDeclaringType)
        || exactDeclaringType.resolve(world).isMissing()) {
      return;
    }

    // warning not needed if match type couldn't ever be the declaring type
    if (!shadowDeclaringType.isAssignableFrom(exactDeclaringType.resolve(world))) {
      return;
    }

    // if the method in the declaring type is *not* visible to the
    // exact declaring type then warning not needed.
    ResolvedMember rm = shadow.getSignature().resolve(world);
    // rm can be null in the case where we are binary weaving, and looking at a class with a call to a method in another class,
    // but because of class incompatibilities, the method does not exist on the target class anymore.
    // this will be reported elsewhere.
    if (rm == null) {
      return;
    }

    int shadowModifiers = rm.getModifiers();
    if (!ResolvedType.isVisible(shadowModifiers, shadowDeclaringType, exactDeclaringType.resolve(world))) {
      return;
    }

    if (!signature.getReturnType().matchesStatically(shadow.getSignature().getReturnType().resolve(world))) {
      // Covariance issue...
      // The reason we didn't match is that the type pattern for the pointcut (Car) doesn't match the
      // return type for the specific declaration at the shadow. (FastCar Sub.getCar())
      // XXX Put out another XLINT in this case?
      return;
    }
    // PR60015 - Don't report the warning if the declaring type is object and 'this' is an interface
    if (exactDeclaringType.resolve(world).isInterface() && shadowDeclaringType.equals(world.resolve("java.lang.Object"))) {
      return;
    }

    SignaturePattern nonConfusingPattern = new SignaturePattern(signature.getKind(), signature.getModifiers(),
        signature.getReturnType(), TypePattern.ANY, signature.getName(), signature.getParameterTypes(),
View Full Code Here

    signature = signature.resolveBindings(scope, bindings);

    if (kind == Shadow.ConstructorExecution) { // Bug fix 60936
      if (signature.getDeclaringType() != null) {
        World world = scope.getWorld();
        UnresolvedType exactType = signature.getDeclaringType().getExactType();
        if (signature.getKind() == Member.CONSTRUCTOR && !ResolvedType.isMissing(exactType)
            && exactType.resolve(world).isInterface() && !signature.getDeclaringType().isIncludeSubtypes()) {
          world.getLint().noInterfaceCtorJoinpoint.signal(exactType.toString(), getSourceLocation());
        }
      }
    }

    // no parameterized types
    if (kind == Shadow.StaticInitialization) {
      HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor visitor = new HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor();
      signature.getDeclaringType().traverse(visitor, null);
      if (visitor.wellHasItThen/* ? */()) {
        scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.NO_STATIC_INIT_JPS_FOR_PARAMETERIZED_TYPES),
            getSourceLocation()));
      }
    }

    // no parameterized types in declaring type position
    if ((kind == Shadow.FieldGet) || (kind == Shadow.FieldSet)) {
      HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor visitor = new HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor();
      signature.getDeclaringType().traverse(visitor, null);
      if (visitor.wellHasItThen/* ? */()) {
        scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.GET_AND_SET_DONT_SUPPORT_DEC_TYPE_PARAMETERS),
            getSourceLocation()));
      }

      // fields can't have a void type!
      UnresolvedType returnType = signature.getReturnType().getExactType();
      if (returnType.equals(UnresolvedType.VOID)) {
        scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.FIELDS_CANT_HAVE_VOID_TYPE),
            getSourceLocation()));
      }
    }

View Full Code Here

    annotationName.append(parseIdentifier());
    while (maybeEat(".")) {
      annotationName.append('.');
      annotationName.append(parseIdentifier());
    }
    UnresolvedType type = UnresolvedType.forName(annotationName.toString());
    p = new ExactAnnotationTypePattern(type, null);
    return p;
  }
View Full Code Here

    out.writeBoolean(isVarArgs);
    writeLocation(out);
  }

  public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
    UnresolvedType type = UnresolvedType.read(s);
    int index = s.readShort();
    boolean isVarargs = false;
    if (s.getMajorVersion() >= AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) {
      isVarargs = s.readBoolean();
    }
View Full Code Here

    // Look at erasures of parameters (List<String> erased is List)
    boolean sameParams = true;
    for (int p = 0, max = methodThatMightBeGettingOverridden.getParameterTypes().length; p < max; p++) {

      UnresolvedType mtmbgoParameter = methodThatMightBeGettingOverridden.getParameterTypes()[p];
      UnresolvedType ptype = methodParamsArray[p];

      if (mtmbgoParameter.isTypeVariableReference()) {
        if (!mtmbgoParameter.resolve(w).isAssignableFrom(ptype.resolve(w))) {
          sameParams = false;
        }
      } else {
        // old condition:
        boolean b = !methodThatMightBeGettingOverridden.getParameterTypes()[p].getErasureSignature().equals(
            methodParamsArray[p].getErasureSignature());

        UnresolvedType parameterType = methodThatMightBeGettingOverridden.getParameterTypes()[p];

        // Collapse to first bound (isn't that the same as erasure!
        if (parameterType instanceof UnresolvedTypeVariableReferenceType) {
          parameterType = ((UnresolvedTypeVariableReferenceType) parameterType).getTypeVariable().getFirstBound();
        }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.UnresolvedType

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.