@Override public StringBuilder appendErasedDescription(final StringBuilder sb) { if (_baseMethod != null) { return _baseMethod.appendErasedDescription(sb); } return super.appendErasedDescription(sb); }
public MethodInfo findOverriddenMethod() { final Type baseType = getDeclaringType().getBaseType(); if (baseType == null || baseType == Type.NullType) { return null; } return findBaseMethod(baseType); }
@Override public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) { return _methodInfo.getAnnotation(annotationClass); }
public final boolean isDefault() { if (isAbstract() || isStatic()) { return false; } final Type declaringType = getDeclaringType(); return declaringType != null && declaringType.isInterface(); }
public final boolean isDefault() { if (isAbstract()) { return false; } final Type declaringType = getDeclaringType(); return declaringType != null && declaringType.isInterface(); }
final Type<?> declaringType = getDeclaringType(); BindingFlags.fromMember(this), Type.FilterRawMember, getRawMethod() ); _erasedMethodDefinition = ((MethodInfo) members.get(0)).getErasedMethodDefinition(); if (isGenericMethod()) { if (isGenericMethodDefinition()) { final ParameterList oldParameters = getParameters(); final TypeList parameterTypes = Helper.erasure(oldParameters.getParameterTypes()); getReflectedType(), getRawMethod(), new ParameterList(parameters), Helper.erasure(getReturnType()), Helper.erasure(getThrownTypes()), TypeBindings.empty() ); _erasedMethodDefinition = getGenericMethodDefinition().getErasedMethodDefinition();
public MethodInfo visitMethod(final Type<?> declaringType, final MethodInfo method, final TypeBindings bindings) { if (method.isGenericMethod()) { boolean hasChanged = false; if (!method.isGenericMethodDefinition()) { final MethodInfo oldDefinition = method.getGenericMethodDefinition(); newDefinition = method.getGenericMethodDefinition(); final TypeBindings oldBindings = method.getTypeBindings(); final TypeBindings newBindings; return newDefinition.makeGenericMethod(newBindings.getBoundTypes()); final Type<?> oldReturnType = method.getReturnType(); final Type<?> returnType = visit(oldReturnType, bindings); final ParameterList oldParameters = method.getParameters(); final ParameterList newParameters = visitParameters(oldParameters, bindings); final TypeList oldThrownTypes = method.getThrownTypes(); final Type<?>[] newThrownTypes = new Type<?>[oldThrownTypes.size()]; final Type oldDeclaringType = method.getDeclaringType(); actualDeclaringType, declaringType, method.getRawMethod(), oldParameters, method.getReturnType(), method.getThrownTypes(), method.getTypeBindings()
@Override public StringBuilder appendErasedDescription(final StringBuilder sb) { if (isGenericMethod() && !isGenericMethodDefinition()) { return getGenericMethodDefinition().appendErasedDescription(sb); } for (final javax.lang.model.element.Modifier modifier : Flags.asModifierSet(getModifiers())) { sb.append(modifier.toString()); sb.append(' '); } final TypeList parameterTypes = getParameters().getParameterTypes(); StringBuilder s = getReturnType().appendErasedDescription(sb); s.append(' '); s.append(getName()); s.append('('); for (int i = 0, n = parameterTypes.size(); i < n; ++i) { if (i != 0) { s.append(", "); } s = parameterTypes.get(i).appendErasedDescription(s); } s.append(')'); return s; }
public static boolean overrides(final MethodInfo baseMethod, final MethodInfo ancestorMethod) { if (ancestorMethod.isFinal() || ancestorMethod.isPrivate()) { return false; final int baseModifier = baseMethod.getModifiers() & Flags.AccessFlags; final int ancestorModifier = ancestorMethod.getModifiers() & Flags.AccessFlags; final Method rawMethod = baseMethod.getRawMethod(); if (rawMethod != null && rawMethod == ancestorMethod.getRawMethod()) { return true; final ParameterList baseParameters = baseMethod.getParameters(); final ParameterList ancestorParameters = ancestorMethod.getParameters(); if (!StringUtilities.equals(baseMethod.getName(), ancestorMethod.getName())) { return false; final Type baseDeclaringType = erasure(baseMethod.getDeclaringType()); final Type ancestorDeclaringType = erasure(ancestorMethod.getDeclaringType()); final Type ancestorReturnType = erasure(ancestorMethod.getReturnType()); final Type baseReturnType = erasure(baseMethod.getReturnType());
VerifyArgument.notNull(baseMethod, "baseMethod"); if (override.getDeclaringType() != this) { throw Error.methodBuilderBelongsToAnotherType(); if (override.isStatic() || baseMethod.isStatic()) { throw Error.staticInstanceMethodMismatch(); if (baseMethod.isFinal()) { throw Error.cannotOverrideFinalMethod(); if (!StringUtilities.equals(override.getName(), baseMethod.getName())) { throw Error.methodNameMismatch(); baseParameterCount = baseMethod.getParameters().size(); (baseMethod.getReturnType() == PrimitiveTypes.Void)) { verifyNotCreated(); final Type<?> baseDeclaringType = baseMethod.getDeclaringType().isGenericType() ? baseMethod.getDeclaringType().getGenericTypeDefinition() : baseMethod.getDeclaringType().getErasedType(); BindingFlags.AllDeclared, RawMethodMatcher, baseMethod.getRawMethod() );
public MethodInfo visitMethod(final Type<?> declaringType, final MethodInfo method, final TypeBindings bindings) { if (method.isGenericMethodDefinition()) { boolean hasChanged = false; if (!method.isGenericMethodDefinition()) { final MethodInfo oldDefinition = method.getGenericMethodDefinition(); newDefinition = method.getGenericMethodDefinition(); final TypeBindings oldBindings = method.getTypeBindings(); final TypeBindings newBindings; return visitMethod(declaringType, newDefinition.makeGenericMethod(newBindings.getBoundTypes()), newBindings); final Type<?> oldReturnType = method.getReturnType(); final Type<?> returnType = visit(oldReturnType, bindings); final ParameterList oldParameters = method.getParameters(); final ParameterList newParameters = visitParameters(oldParameters, bindings); final TypeList oldThrownTypes = method.getThrownTypes(); final Type<?>[] newThrownTypes = new Type<?>[oldThrownTypes.size()]; if (!TypeUtils.areEquivalent(method.getDeclaringType(), declaringType)) { return MethodInfo.declaredOn(method, declaringType, method.getReflectedType()); method, declaringType, method.getReflectedType(), method.getRawMethod(), newParameters, returnType,
public MethodInfo findBaseMethod(final Type<?> relativeTo) { VerifyArgument.notNull(relativeTo, "relativeTo"); final Type<?> declaringType = getDeclaringType(); if (!relativeTo.isAssignableFrom(declaringType)) { throw Error.invalidAncestorType(relativeTo, declaringType); } if (isStatic() || isPrivate()) { return null; } final ParameterList parameters = getParameters(); return relativeTo.getMethod( getName(), BindingFlags.AllInstance, getCallingConvention(), parameters.getParameterTypes().toArray(new Type[parameters.size()]) ); }
@Override public MethodInfo visitMethod(final Type<?> declaringType, final MethodInfo method, final TypeBindings bindings) { final Type<?> oldReturnType = method.getReturnType(); final Type<?> returnType = visit(oldReturnType, bindings); final ParameterList oldParameters = method.getParameters(); final ParameterList newParameters = visitParameters(oldParameters, bindings); final TypeList oldThrownTypes = method.getThrownTypes(); final Type<?>[] newThrownTypes = new Type<?>[oldThrownTypes.size()]; if (!TypeUtils.areEquivalent(method.getDeclaringType(), declaringType)) { return MethodInfo.declaredOn(method, declaringType, method.getReflectedType());
public InterfaceMethodReference getInterfaceMethodReference(final MethodInfo method) { final TypeInfo typeInfo = getTypeInfo(method.getDeclaringType()); final NameAndTypeDescriptor nameAndDescriptor = getNameAndTypeDescriptor( method.getName(), method.getErasedSignature() ); _lookupKey.set(Tag.InterfaceMethodReference, typeInfo.index, nameAndDescriptor.index); Entry entry = _entryMap.get(_lookupKey); if (entry == null) { entry = new InterfaceMethodReference(this, typeInfo.index, nameAndDescriptor.index); } _lookupKey.clear(); return (InterfaceMethodReference)entry; }
final Type<?> declaringType = this.getDeclaringType(); final Type<?> actualDeclaringType; this.isGenericMethod() ? this.getGenericMethodDefinition() : this, getTypeBindings() );
if ((method.getModifiers() & Flags.ACC_BRIDGE) == 0) { methodLookup.put( Pair.create( method.getName(), method.getErasedSignature() ), method final TypeList generatedMethodTypeParameters = generatedMethod.getGenericMethodParameters();
private static boolean isOverridableIn(final MethodInfo method, final Type origin) { VerifyArgument.notNull(method, "method"); VerifyArgument.notNull(origin, "origin"); switch (method.getModifiers() & Flags.AccessFlags) { case 0: // for package private: can only override in the same package. return method.getDeclaringType().getPackage() == origin.getPackage() && !origin.isInterface(); case Flags.PRIVATE: return false; case Flags.PUBLIC: return true; case Flags.PROTECTED: return !origin.isInterface(); default: return false; } }
(declaringMethod == null || declaringMethod.getDeclaringType() .isEquivalentTo(otherDeclaringMethod.getDeclaringType()) && declaringMethod.getRawMethod() == otherDeclaringMethod.getRawMethod());
public void call(final MethodInfo method) { VerifyArgument.notNull(method, "method"); final OpCode opCode; if (method.isStatic()) { emit(OpCode.INVOKESTATIC, method); } else if (method.isPrivate()) { emit(OpCode.INVOKESPECIAL, method); } else if (method.getDeclaringType().isInterface()) { emit(OpCode.INVOKEINTERFACE, method); } else { emit(OpCode.INVOKEVIRTUAL, method); } }
static boolean isBridgeMethodNeeded(final MethodInfo baseMethod, final MethodInfo override) { final MethodInfo erasedBase = baseMethod.getErasedMethodDefinition(); final MethodInfo erasedOverride = override.getErasedMethodDefinition(); final Type<?> baseReturnType = erasedBase.getReturnType().getErasedType(); final Type<?> overrideReturnType = erasedOverride.getReturnType().getErasedType(); if ((baseReturnType == PrimitiveTypes.Void) != (overrideReturnType == PrimitiveTypes.Void)) { throw Error.incompatibleReturnTypes(); } if (!TypeUtils.areEquivalent(overrideReturnType, baseReturnType)) { return true; } final TypeList parameterTypes = (erasedOverride instanceof MethodBuilder) ? ((MethodBuilder) erasedOverride).getParameterTypes().getErasedTypes() : erasedOverride.getParameters().getParameterTypes().getErasedTypes(); final TypeList baseParameters = (erasedBase instanceof MethodBuilder) ? ((MethodBuilder) erasedBase).getParameterTypes().getErasedTypes() : erasedBase.getParameters().getParameterTypes().getErasedTypes(); if (baseParameters.size() != parameterTypes.size()) { throw Error.parameterCountMismatch(); } for (int i = 0, n = parameterTypes.size(); i < n; i++) { final Type<?> t1 = parameterTypes.get(i); final Type<?> t2 = baseParameters.get(i); if (!t1.isEquivalentTo(t2)) { return true; } } return false; }