/** * {@inheritDoc} */ public Generic getSuperClass() { return typeDescription.getSuperClass(); }
@Override protected TypeDefinition identify(TypeDescription typeDescription) { return typeDescription.getSuperClass(); } },
/** * {@inheritDoc} */ public Generic getSuperClass() { return delegate().getSuperClass(); }
/** * {@inheritDoc} */ public Generic getSuperClass() { Generic superClass = delegate.getSuperClass(); return superClass == null ? Generic.UNDEFINED : new ClassLoadingTypeProjection(superClass, classLoader, classLoadingDelegate); }
/** * {@inheritDoc} */ public MethodInvoker make(TypeDescription instrumentedType) { if (instrumentedType.getSuperClass() == null) { throw new IllegalStateException("Cannot invoke super method for " + instrumentedType); } return new ForSuperMethodInvocation(instrumentedType); } }
/** * {@inheritDoc} */ public Generic getSuperClass() { Generic superClass = typeDescription.getSuperClass(); return superClass == null ? Generic.UNDEFINED : new LazyProjection.WithResolvedErasure(superClass, Visitor.Reifying.INHERITING); }
/** * Resolves a lazy super class description. * * @param delegate The lazy projection for which this description is a delegate. * @return A lazy description of the super class or {@code null} if the delegate does not define a super class. */ protected static Generic of(LazyProjection delegate) { return delegate.asErasure().getSuperClass() == null ? Generic.UNDEFINED : new LazySuperClass(delegate); }
/** * {@inheritDoc} */ public TypeDescription asErasure() { return delegate.asErasure().getSuperClass().asErasure(); }
/** * {@inheritDoc} */ public List<MethodDescription.Token> extractConstructors(TypeDescription instrumentedType) { if (instrumentedType.getSuperClass().getDeclaredMethods().filter(isConstructor()).isEmpty()) { throw new IllegalStateException("Cannot define default constructor for class without super class constructor"); } return Collections.singletonList(new MethodDescription.Token(Opcodes.ACC_PUBLIC)); }
@Override protected List<MethodDescription.Token> doExtractConstructors(TypeDescription instrumentedType) { TypeDescription.Generic superClass = instrumentedType.getSuperClass(); MethodList<?> defaultConstructors = superClass == null ? new MethodList.Empty<MethodDescription.InGenericShape>() : superClass.getDeclaredMethods().filter(isConstructor().and(takesArguments(0)).<MethodDescription>and(isVisibleTo(instrumentedType))); if (defaultConstructors.size() == 1) { return Collections.singletonList(new MethodDescription.Token(Opcodes.ACC_PUBLIC)); } else { throw new IllegalArgumentException(instrumentedType.getSuperClass() + " declares no constructor that is visible to " + instrumentedType); } }
/** * {@inheritDoc} */ public Generic getSuperClass() { TypeDescription erasure = asErasure(); Generic superClass = erasure.getSuperClass(); if (TypeDescription.AbstractBase.RAW_TYPES) { return superClass; } return superClass == null ? Generic.UNDEFINED : new Generic.LazyProjection.WithResolvedErasure(superClass, new Visitor.ForRawType(erasure), Empty.INSTANCE); }
/** * {@inheritDoc} */ public Generic getSuperClass() { Generic superClass = asErasure().getSuperClass(); return superClass == null ? Generic.UNDEFINED : new LazyProjection.WithResolvedErasure(superClass, new Visitor.Substitutor.ForTypeVariableBinding(this)); }
/** * Creates a special method invocation for the given node. * * @param node The node for which a special method invocation is to be created. * @return A special method invocation for the provided node. */ private Implementation.SpecialMethodInvocation invokeSuper(MethodGraph.Node node) { return node.getSort().isResolved() ? Implementation.SpecialMethodInvocation.Simple.of(node.getRepresentative(), instrumentedType.getSuperClass().asErasure()) : Implementation.SpecialMethodInvocation.Illegal.INSTANCE; }
@Override protected StackManipulation resolve(TypeDescription instrumentedType) { TypeDefinition superClass = instrumentedType.getSuperClass(); if (superClass == null) { throw new IllegalStateException(instrumentedType + " does not declare a super class"); } return new StackManipulation.Compound(MethodVariableAccess.loadThis(), MethodVariableAccess.REFERENCE.loadFrom(1), MethodInvocation.invoke(EQUALS).special(superClass.asErasure()), ConditionalReturn.onZeroInteger()); } };
@Override protected HashCodeMethod hashCodeMethod(TypeDescription instrumentedType) { TypeDefinition superClass = instrumentedType.getSuperClass(); return superClass != null && superClass.asErasure().getDeclaredAnnotations().isAnnotationPresent(Enhance.class) ? HashCodeMethod.usingSuperClassOffset() : HashCodeMethod.usingDefaultOffset(); }
@Override protected EqualsMethod equalsMethod(TypeDescription instrumentedType) { TypeDefinition superClass = instrumentedType.getSuperClass(); return superClass != null && superClass.asErasure().getDeclaredAnnotations().isAnnotationPresent(Enhance.class) ? EqualsMethod.requiringSuperClassEquality() : EqualsMethod.isolated(); } },
/** * Resolves a special method invocation for a non-constructor invocation. * * @param token A token describing the method to be invoked. * @return A special method invocation for a method representing the given method token, if available. */ private Implementation.SpecialMethodInvocation invokeMethod(MethodDescription.SignatureToken token) { MethodGraph.Node methodNode = methodGraph.getSuperClassGraph().locate(token); return methodNode.getSort().isUnique() ? Implementation.SpecialMethodInvocation.Simple.of(methodNode.getRepresentative(), instrumentedType.getSuperClass().asErasure()) : Implementation.SpecialMethodInvocation.Illegal.INSTANCE; }
@Override protected List<MethodDescription.Token> doExtractConstructors(TypeDescription instrumentedType) { TypeDescription.Generic superClass = instrumentedType.getSuperClass(); return (superClass == null ? new MethodList.Empty<MethodDescription.InGenericShape>() : superClass.getDeclaredMethods().filter(isConstructor().and(isVisibleTo(instrumentedType)))).asTokenList(is(instrumentedType)); }
@Override protected List<MethodDescription.Token> doExtractConstructors(TypeDescription instrumentedType) { TypeDescription.Generic superClass = instrumentedType.getSuperClass(); return (superClass == null ? new MethodList.Empty<MethodDescription.InGenericShape>() : superClass.getDeclaredMethods().filter(isPublic().and(isConstructor()))).asTokenList(is(instrumentedType)); }
@Override protected List<MethodDescription.Token> doExtractConstructors(TypeDescription instrumentedType) { TypeDescription.Generic superClass = instrumentedType.getSuperClass(); return (superClass == null ? new MethodList.Empty<MethodDescription.InGenericShape>() : superClass.getDeclaredMethods().filter(isConstructor().and(isVisibleTo(instrumentedType)))).asTokenList(is(instrumentedType)); }