Package org.aspectj.weaver

Examples of org.aspectj.weaver.UnresolvedType


    }
    // out.println("classPath: " + classPath);

    BcelWorld world = new BcelWorld(path);

    UnresolvedType ut = UnresolvedType.forName(name);
    ut.setNeedsModifiableDelegate(true);
    LazyClassGen clazz = new LazyClassGen(BcelWorld.getBcelObjectType(world.resolve(ut)));
    clazz.print(out);
    out.println();
  }
View Full Code Here


    } else if (sig.getKind().equals(Member.FIELD)) {
      BcelWorld w = shadow.getWorld();
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getModifiers(w))));
      list.append(InstructionFactory.PUSH(cp, sig.getName()));
      // see pr227401
      UnresolvedType dType = sig.getDeclaringType();
      if (dType.getTypekind() == TypeKind.PARAMETERIZED || dType.getTypekind() == TypeKind.GENERIC) {
        dType = sig.getDeclaringType().resolve(world).getGenericType();
      }
      list.append(InstructionFactory.PUSH(cp, makeString(dType)));
      list.append(InstructionFactory.PUSH(cp, makeString(sig.getReturnType())));
      list.append(fact.createInvoke(factoryType.getClassName(), signatureMakerName, signatureType, Type.STRINGARRAY4,
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

    }

    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 == ResolvedType.VOID) {
        scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.FIELDS_CANT_HAVE_VOID_TYPE),
            getSourceLocation()));
      }
    }
View Full Code Here

    }

    // handle arrays since the component type may need special treatment too...
    if (binding instanceof ArrayBinding) {
      ArrayBinding aBinding = (ArrayBinding) binding;
      UnresolvedType componentType = fromBinding(aBinding.leafComponentType);
      return UnresolvedType.makeArray(componentType, aBinding.dimensions);
    }

    if (binding instanceof WildcardBinding) {
      WildcardBinding eWB = (WildcardBinding) binding;
      // Repair the bound
      // e.g. If the bound for the wildcard is a typevariable, e.g. '? extends E' then
      // the type variable in the unresolvedtype will be correct only in name. In that
      // case let's set it correctly based on the one in the eclipse WildcardBinding
      UnresolvedType theBound = null;
      if (eWB.bound instanceof TypeVariableBinding) {
        theBound = fromTypeVariableBinding((TypeVariableBinding) eWB.bound);
      } else {
        theBound = fromBinding(eWB.bound);
      }
      // if (eWB.boundKind == WildCard.SUPER) {
      //
      // }
      WildcardedUnresolvedType theType = (WildcardedUnresolvedType) TypeFactory.createTypeFromSignature(CharOperation
          .charToString(eWB.genericTypeSignature()));
      // if (theType.isGenericWildcard() && theType.isSuper()) theType.setLowerBound(theBound);
      // if (theType.isGenericWildcard() && theType.isExtends()) theType.setUpperBound(theBound);
      return theType;
    }

    if (binding instanceof ParameterizedTypeBinding) {
      if (binding instanceof RawTypeBinding) {
        // special case where no parameters are specified!
        return UnresolvedType.forRawTypeName(getName(binding));
      }
      ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) binding;

      UnresolvedType[] arguments = null;

      if (ptb.arguments != null) { // null can mean this is an inner type of a Parameterized Type with no bounds of its own
        // (pr100227)
        arguments = new UnresolvedType[ptb.arguments.length];
        for (int i = 0; i < arguments.length; i++) {
          arguments[i] = fromBinding(ptb.arguments[i]);
        }
      }

      String baseTypeSignature = null;

      ResolvedType baseType = getWorld().resolve(UnresolvedType.forName(getName(binding)), true);
      if (!baseType.isMissing()) {
        // can legitimately be missing if a bound refers to a type we haven't added to the world yet...
        // pr168044 - sometimes (whilst resolving types) we are working with 'half finished' types and so (for example) the
        // underlying generic type for a raw type hasnt been set yet
        // if (!baseType.isGenericType() && arguments!=null) baseType = baseType.getGenericType();
        baseTypeSignature = baseType.getErasureSignature();
      } else {
        baseTypeSignature = UnresolvedType.forName(getName(binding)).getSignature();
      }

      // Create an unresolved parameterized type. We can't create a resolved one as the
      // act of resolution here may cause recursion problems since the parameters may
      // be type variables that we haven't fixed up yet.
      if (arguments == null) {
        arguments = new UnresolvedType[0];
      }
      // StringBuffer parameterizedSig = new StringBuffer();
      // parameterizedSig.append(ResolvedType.PARAMETERIZED_TYPE_IDENTIFIER);
      //
      // // String parameterizedSig = new
      // StringBuffer().append(ResolvedType.PARAMETERIZED_TYPE_IDENTIFIER).append(CharOperation
      // .charToString(binding.genericTypeSignature()).substring(1)).toString();
      // return TypeFactory.createUnresolvedParameterizedType(parameterizedSig,baseTypeSignature,arguments);
      return TypeFactory.createUnresolvedParameterizedType(baseTypeSignature, arguments);
    }

    // Convert the source type binding for a generic type into a generic UnresolvedType
    // notice we can easily determine the type variables from the eclipse object
    // and we can recover the generic signature from it too - so we pass those
    // to the forGenericType() method.
    if (binding.isGenericType() && !binding.isParameterizedType() && !binding.isRawType()) {
      TypeVariableBinding[] tvbs = binding.typeVariables();
      TypeVariable[] tVars = new TypeVariable[tvbs.length];
      for (int i = 0; i < tvbs.length; i++) {
        TypeVariableBinding eclipseV = tvbs[i];
        tVars[i] = ((TypeVariableReference) fromTypeVariableBinding(eclipseV)).getTypeVariable();
      }
      // TODO asc generics - temporary guard....
      if (!(binding instanceof SourceTypeBinding)) {
        throw new RuntimeException("Cant get the generic sig for " + binding.debugName());
      }
      return UnresolvedType.forGenericType(getName(binding), tVars,
          CharOperation.charToString(((SourceTypeBinding) binding).genericSignature()));
    }

    // LocalTypeBinding have a name $Local$, we can get the real name by using the signature....
    if (binding instanceof LocalTypeBinding) {
      LocalTypeBinding ltb = (LocalTypeBinding) binding;
      if (ltb.constantPoolName() != null && ltb.constantPoolName().length > 0) {
        return UnresolvedType.forSignature(new String(binding.signature()));
      } else {
        // we're reporting a problem and don't have a resolved name for an
        // anonymous local type yet, report the issue on the enclosing type
        return UnresolvedType.forSignature(new String(ltb.enclosingType.signature()));
      }
    }

    // was: UnresolvedType.forName(getName(binding));
    UnresolvedType ut = UnresolvedType.forSignature(new String(binding.signature()));
    return ut;
  }
View Full Code Here

    TypeVariable tv = new TypeVariable(name);
    ret.setTypeVariable(tv);
    // Dont set any bounds here, you'll get in a recursive mess
    // TODO -- what about lower bounds??
    UnresolvedType superclassType = fromBinding(aTypeVariableBinding.superclass());
    UnresolvedType[] superinterfaces = null;
    if (aTypeVariableBinding == null || aTypeVariableBinding.superInterfaces == null) {
      // sign of another bug that will be reported elsewhere
      superinterfaces = UnresolvedType.NONE;
    } else {
View Full Code Here

  public void addTypeBinding(TypeBinding binding) {
    typexToBinding.put(fromBinding(binding), binding);
  }

  public void addTypeBindingAndStoreInWorld(TypeBinding binding) {
    UnresolvedType ut = fromBinding(binding);
    typexToBinding.put(ut, binding);
    world.lookupOrCreateName(ut);
  }
View Full Code Here

  public void addSourceTypeBinding(SourceTypeBinding binding, CompilationUnitDeclaration unit) {
    TypeDeclaration decl = binding.scope.referenceContext;

    // Deal with the raw/basic type to give us an entry in the world type map
    UnresolvedType simpleTx = null;
    if (binding.isGenericType()) {
      simpleTx = UnresolvedType.forRawTypeName(getName(binding));
    } else if (binding.isLocalType()) {
      LocalTypeBinding ltb = (LocalTypeBinding) binding;
      if (ltb.constantPoolName() != null && ltb.constantPoolName().length > 0) {
        simpleTx = UnresolvedType.forSignature(new String(binding.signature()));
      } else {
        simpleTx = UnresolvedType.forName(getName(binding));
      }
    } else {
      simpleTx = UnresolvedType.forName(getName(binding));
    }

    ReferenceType name = getWorld().lookupOrCreateName(simpleTx);

    // A type can change from simple > generic > simple across a set of compiles. We need
    // to ensure the entry in the typemap is promoted and demoted correctly. The call
    // to setGenericType() below promotes a simple to a raw. This call demotes it back
    // to simple
    // pr125405
    if (!binding.isRawType() && !binding.isGenericType() && name.getTypekind() == TypeKind.RAW) {
      name.demoteToSimpleType();
    }

    EclipseSourceType t = new EclipseSourceType(name, this, binding, decl, unit);

    // For generics, go a bit further - build a typex for the generic type
    // give it the same delegate and link it to the raw type
    if (binding.isGenericType()) {
      UnresolvedType complexTx = fromBinding(binding); // fully aware of any generics info
      ResolvedType cName = world.resolve(complexTx, true);
      ReferenceType complexName = null;
      if (!cName.isMissing()) {
        complexName = (ReferenceType) cName;
        complexName = (ReferenceType) complexName.getGenericType();
View Full Code Here

          ResolvedMember method = (ResolvedMember) memberIter.next();
          if (def.getName().equals(method.getName())
              && def.getParameterTypes().length == method.getParameterTypes().length) {
            boolean sameSig = true;
            for (int j = 0; j < method.getParameterTypes().length; j++) {
              UnresolvedType argJ = method.getParameterTypes()[j];
              if (!argJ.equals(def.getParameterTypes()[j])) {
                sameSig = false;
                break;
              }
            }
            if (sameSig) {
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.