@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); } }
new LazyFieldList(instrumentedType), methods, new MethodList.Empty<MethodDescription>(), LoadedTypeInitializer.NoOp.INSTANCE, TypeInitializer.None.INSTANCE,
/** * Resolves a special method invocation for a constructor invocation. * * @param token A token describing the constructor to be invoked. * @return A special method invocation for a constructor representing the given method token, if available. */ private Implementation.SpecialMethodInvocation invokeConstructor(MethodDescription.SignatureToken token) { TypeDescription.Generic superClass = instrumentedType.getSuperClass(); MethodList<?> candidates = superClass == null ? new MethodList.Empty<MethodDescription.InGenericShape>() : superClass.getDeclaredMethods().filter(hasSignature(token).and(isVisibleTo(instrumentedType))); return candidates.size() == 1 ? Implementation.SpecialMethodInvocation.Simple.of(candidates.getOnly(), instrumentedType.getSuperClass().asErasure()) : Implementation.SpecialMethodInvocation.Illegal.INSTANCE; }
/** * {@inheritDoc} */ public MethodList<MethodDescription.InDefinedShape> getDeclaredMethods() { return new MethodList.Empty<MethodDescription.InDefinedShape>(); }
@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)); }
/** * {@inheritDoc} */ public MethodList<MethodDescription.InGenericShape> getDeclaredMethods() { return new MethodList.Empty<MethodDescription.InGenericShape>(); }
@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)); }
/** * {@inheritDoc} */ public MethodList<MethodDescription.InDefinedShape> getDeclaredMethods() { return new MethodList.Empty<MethodDescription.InDefinedShape>(); }