public void clearInterTypeMungers() { if (isRawType()) { ResolvedType genericType = getGenericType(); if (genericType.isRawType()) { // ERROR SITUATION: PR341926 // For some reason the raw type is pointing to another raw form (possibly itself) System.err.println("DebugFor341926: Type " + this.getName() + " has an incorrect generic form"); } else { genericType.clearInterTypeMungers(); } } // interTypeMungers.clear(); // BUG? Why can't this be clear() instead: 293620 c6 interTypeMungers = new ArrayList<ConcreteTypeMunger>(); }
private boolean addSuperInitializer(ResolvedType onType) { if (onType.isRawType() || onType.isParameterizedType()) { onType = onType.getGenericType(); } IfaceInitList l = addedSuperInitializers.get(onType); if (l != null) { return false; } l = new IfaceInitList(onType); addedSuperInitializers.put(onType, l); return true; }
public static Member interfaceConstructor(ResolvedType resolvedTypeX) { // AMC next two lines should not be needed when sig for generic type is changed ResolvedType declaringType = resolvedTypeX; if (declaringType.isRawType()) { declaringType = declaringType.getGenericType(); } return new ResolvedMemberImpl(Member.CONSTRUCTOR, declaringType, Modifier.PUBLIC, "<init>", "()V"); }
/** * Returns the generic type, regardless of the resolvedType we 'know about' */ public ResolvedType getGenericResolvedType() { ResolvedType rt = getResolvedTypeX(); if (rt.isParameterizedType() || rt.isRawType()) { return rt.getGenericType(); } return rt; }
/** * Checks if the generic type for 'this' and the generic type for 'other' are the same - it can be passed raw or parameterized * versions and will just compare the underlying generic type. */ private boolean genericTypeEquals(ResolvedType other) { ResolvedType rt = other; if (rt.isParameterizedType() || rt.isRawType()) { rt.getGenericType(); } if (((isParameterizedType() || isRawType()) && getGenericType().equals(rt)) || (this.equals(other))) { return true; } return false; }
public List<ResolvedType> findMatchingNewParents(ResolvedType onType, boolean reportErrors) { if (onType.isRawType()) { onType = onType.getGenericType(); } if (!match(onType)) { return Collections.emptyList(); } List<ResolvedType> ret = new ArrayList<ResolvedType>(); for (int i = 0; i < parents.size(); i++) { ResolvedType t = maybeGetNewParent(onType, parents.get(i), onType.getWorld(), reportErrors); if (t != null) { ret.add(t); } } return ret; }
public void addInitializer(ConcreteTypeMunger cm) { NewFieldTypeMunger m = (NewFieldTypeMunger) cm.getMunger(); ResolvedType onType = m.getSignature().getDeclaringType().resolve(world); if (onType.isRawType()) { onType = onType.getGenericType(); } if (Modifier.isStatic(m.getSignature().getModifiers())) { addedClassInitializers.add(cm); } else { if (onType == ty.getResolvedTypeX()) { addedThisInitializers.add(cm); } else { IfaceInitList l = addedSuperInitializers.get(onType); l.list.add(cm); } } }
protected boolean matchesSubtypes(ResolvedType superType, ResolvedType annotatedType) { // System.out.println("matching2: " + this + " to " + superType); if (matchesExactly(superType, annotatedType)) { // System.out.println(" true"); return true; } // If an ITD is applied, it will be put onto the generic type, not the parameterized or raw form if (superType.isParameterizedType() || superType.isRawType()) { superType = superType.getGenericType(); } // FuzzyBoolean ret = FuzzyBoolean.NO; // ??? -eh for (Iterator<ResolvedType> i = superType.getDirectSupertypes(); i.hasNext();) { ResolvedType superSuperType = (ResolvedType) i.next(); if (matchesSubtypes(superSuperType, annotatedType)) { return true; } } return false; }
if (!aBaseType.isGenericType()) { if (someTypeParameters != null && someTypeParameters.length > 0) { if (!aBaseType.isRawType()) { throw new IllegalStateException("Expecting raw type, but " + aBaseType+" is of type "+aBaseType.getTypekind());
private boolean mungeNewMemberType(BcelClassWeaver classWeaver, NewMemberClassTypeMunger munger) { World world = classWeaver.getWorld(); ResolvedType onType = world.resolve(munger.getTargetType()); if (onType.isRawType()) { onType = onType.getGenericType(); } return onType.equals(classWeaver.getLazyClassGen().getType()); }
protected boolean matchesSubtypes(ResolvedType type) { // System.out.println("matching: " + this + " to " + type); if (matchesExactly(type)) { return true; } // pr124808 Iterator<ResolvedType> typesIterator = null; if (type.isTypeVariableReference()) { typesIterator = ((TypeVariableReference) type).getTypeVariable().getFirstBound().resolve(type.getWorld()) .getDirectSupertypes(); } else { // pr223605 if (type.isRawType()) { type = type.getGenericType(); } typesIterator = type.getDirectSupertypes(); } for (Iterator<ResolvedType> i = typesIterator; i.hasNext();) { ResolvedType superType = i.next(); if (matchesSubtypes(superType, type)) { return true; } } return false; }
public void weaveNormalTypeMungers(ResolvedType onType) { ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, onType.getName()); if (onType.isRawType() || onType.isParameterizedType()) { onType = onType.getGenericType(); } for (ConcreteTypeMunger m : typeMungerList) { if (!m.isLateMunger() && m.matches(onType)) { onType.addInterTypeMunger(m, false); } } CompilationAndWeavingContext.leavingPhase(tok); }
/** * Member resolution is achieved by resolving the declaring type and then looking up the member in the resolved declaring type. */ public ResolvedMember resolve(Member member) { ResolvedType declaring = member.getDeclaringType().resolve(this); if (declaring.isRawType()) { declaring = declaring.getGenericType(); } ResolvedMember ret; if (member.getKind() == Member.FIELD) { ret = declaring.lookupField(member); } else { ret = declaring.lookupMethod(member); } if (ret != null) { return ret; } return declaring.lookupSyntheticMember(member); }
/** * When the world is operating in 1.5 mode, the TypeMap should only contain RAW types and never directly generic types. The RAW * type will contain a reference to the generic type. * * @param type a possibly generic type for which the raw needs creating as it is not currently in the world * @return a type suitable for putting into the world */ private ResolvedType ensureRawTypeIfNecessary(ResolvedType type) { if (!isInJava5Mode() || type.isRawType()) { return type; } // Key requirement here is if it is generic, create a RAW entry to be put in the map that points to it if (type instanceof ReferenceType && ((ReferenceType) type).getDelegate() != null && type.isGenericType()) { ReferenceType rawType = new ReferenceType(type.getSignature(), this); rawType.typeKind = UnresolvedType.TypeKind.RAW; ReferenceTypeDelegate delegate = ((ReferenceType) type).getDelegate(); rawType.setDelegate(delegate); rawType.setGenericType((ReferenceType) type); return rawType; } // probably parameterized... return type; }
if (onType.isRawType()) { onType = onType.getGenericType();
/** * see ResolvedTypeMunger.parameterizedFor(ResolvedType) */ @Override public ResolvedTypeMunger parameterizedFor(ResolvedType target) { ResolvedType genericType = target; if (target.isRawType() || target.isParameterizedType()) { genericType = genericType.getGenericType(); } ResolvedMember parameterizedSignature = null; // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used // in the original ITD declaration to the ones used in the actual target type declaration. if (target.isGenericType()) { TypeVariable vars[] = target.getTypeVariables(); UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length]; for (int i = 0; i < vars.length; i++) { varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]); } parameterizedSignature = getSignature().parameterizedWith(varRefs, genericType, true, typeVariableAliases); } else { // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>) parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(), genericType, target.isParameterizedType(), typeVariableAliases); } NewConstructorTypeMunger nctm = new NewConstructorTypeMunger(parameterizedSignature, syntheticConstructor, explicitConstructor, getSuperMethodsCalled(), typeVariableAliases); nctm.setSourceLocation(getSourceLocation()); return nctm; }
/** * see ResolvedTypeMunger.parameterizedFor(ResolvedType) */ public ResolvedTypeMunger parameterizedFor(ResolvedType target) { ResolvedType genericType = target; if (target.isRawType() || target.isParameterizedType()) { genericType = genericType.getGenericType(); } ResolvedMember parameterizedSignature = null; // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used // in the original ITD declaration to the ones used in the actual target type declaration. if (target.isGenericType()) { TypeVariable vars[] = target.getTypeVariables(); UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length]; for (int i = 0; i < vars.length; i++) { varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]); } parameterizedSignature = getSignature().parameterizedWith(varRefs, genericType, true, typeVariableAliases); } else { // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>) parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(), genericType, target.isParameterizedType(), typeVariableAliases); } NewFieldTypeMunger nftm = new NewFieldTypeMunger(parameterizedSignature, getSuperMethodsCalled(), typeVariableAliases); nftm.setDeclaredSignature(getSignature()); nftm.setSourceLocation(getSourceLocation()); return nftm; }
/** * see ResolvedTypeMunger.parameterizedFor(ResolvedType) */ public ResolvedTypeMunger parameterizedFor(ResolvedType target) { ResolvedType genericType = target; if (target.isRawType() || target.isParameterizedType()) { genericType = genericType.getGenericType(); } ResolvedMember parameterizedSignature = null; // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used // in the original ITD declaration to the ones used in the actual target type declaration. if (target.isGenericType()) { TypeVariable vars[] = target.getTypeVariables(); UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length]; for (int i = 0; i < vars.length; i++) { varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]); } parameterizedSignature = getSignature().parameterizedWith(varRefs, genericType, true, typeVariableAliases); } else { // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>) parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(), genericType, target.isParameterizedType(), typeVariableAliases); } NewMethodTypeMunger nmtm = new NewMethodTypeMunger(parameterizedSignature, getSuperMethodsCalled(), typeVariableAliases); nmtm.setDeclaredSignature(getSignature()); nmtm.setSourceLocation(getSourceLocation()); return nmtm; }
public boolean matches(ResolvedType matchType, ResolvedType aspectType) { if (onType == null) { onType = matchType.getWorld().resolve(getDeclaringType()); if (onType.isRawType()) { onType = onType.getGenericType(); } } // System.err.println("matching: " + this + " to " + matchType + " onType = " + onType); if (matchType.equals(onType)) { if (!onType.isExposedToWeaver()) { // if the onType is an interface, and it already has the member we are about // to munge, then this is ok... boolean ok = (onType.isInterface() && (onType.lookupMemberWithSupersAndITDs(getSignature()) != null)); if (!ok && onType.getWeaverState() == null) { if (matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) { matchType.getWorld().getLint().typeNotExposedToWeaver.signal(matchType.getName(), signature .getSourceLocation()); } } } return true; } // System.err.println("NO MATCH DIRECT"); if (onType.isInterface()) { return matchType.isTopmostImplementor(onType); } else { return false; } }
public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) { // ??? might give a field where a method is expected ResolvedType onType = aspectType.getWorld().resolve(getSignature().getDeclaringType()); if (onType.isRawType()) { onType = onType.getGenericType(); } ResolvedMember ret = AjcMemberMaker.interFieldGetDispatcher(getSignature(), aspectType); if (ResolvedType.matches(ret, member)) { return getSignature(); } ret = AjcMemberMaker.interFieldSetDispatcher(getSignature(), aspectType); if (ResolvedType.matches(ret, member)) { return getSignature(); } ret = AjcMemberMaker.interFieldInterfaceGetter(getSignature(), onType, aspectType); if (ResolvedType.matches(ret, member)) { return getSignature(); } ret = AjcMemberMaker.interFieldInterfaceSetter(getSignature(), onType, aspectType); if (ResolvedType.matches(ret, member)) { return getSignature(); } return super.getMatchingSyntheticMember(member, aspectType); }