本文整理汇总了Java中net.bytebuddy.implementation.Implementation.SpecialMethodInvocation方法的典型用法代码示例。如果您正苦于以下问题:Java Implementation.SpecialMethodInvocation方法的具体用法?Java Implementation.SpecialMethodInvocation怎么用?Java Implementation.SpecialMethodInvocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.implementation.Implementation
的用法示例。
在下文中一共展示了Implementation.SpecialMethodInvocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSuperConstructorIsInvokable
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Test
public void testSuperConstructorIsInvokable() throws Exception {
when(invokableMethod.isConstructor()).thenReturn(true);
when(definedSuperClassConstructor.isSpecializableFor(rawSuperClass)).thenReturn(true);
Implementation.SpecialMethodInvocation specialMethodInvocation = makeImplementationTarget().invokeSuper(superConstructorToken);
assertThat(specialMethodInvocation.isValid(), is(true));
assertThat(specialMethodInvocation.getMethodDescription(), is((MethodDescription) superClassConstructor));
assertThat(specialMethodInvocation.getTypeDescription(), is(rawSuperClass));
MethodVisitor methodVisitor = mock(MethodVisitor.class);
Implementation.Context implementationContext = mock(Implementation.Context.class);
StackManipulation.Size size = specialMethodInvocation.apply(methodVisitor, implementationContext);
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKESPECIAL, BAR, QUX, BAZ, false);
verifyNoMoreInteractions(methodVisitor);
verifyZeroInteractions(implementationContext);
assertThat(size.getSizeImpact(), is(0));
assertThat(size.getMaximalSize(), is(0));
}
示例2: testSuperTypeMethodIsInvokable
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Test
public void testSuperTypeMethodIsInvokable() throws Exception {
when(invokableMethod.isSpecializableFor(rawSuperClass)).thenReturn(true);
Implementation.SpecialMethodInvocation specialMethodInvocation = makeImplementationTarget().invokeSuper(invokableToken);
assertThat(specialMethodInvocation.isValid(), is(true));
assertThat(specialMethodInvocation.getMethodDescription(), is((MethodDescription) invokableMethod));
assertThat(specialMethodInvocation.getTypeDescription(), is(rawSuperClass));
MethodVisitor methodVisitor = mock(MethodVisitor.class);
Implementation.Context implementationContext = mock(Implementation.Context.class);
StackManipulation.Size size = specialMethodInvocation.apply(methodVisitor, implementationContext);
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKESPECIAL, BAR, FOO, QUX, false);
verifyNoMoreInteractions(methodVisitor);
verifyZeroInteractions(implementationContext);
assertThat(size.getSizeImpact(), is(0));
assertThat(size.getMaximalSize(), is(0));
}
示例3: testRebasedConstructorIsInvokable
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Test
public void testRebasedConstructorIsInvokable() throws Exception {
when(rebasedMethod.isConstructor()).thenReturn(true);
when(invokableMethod.getDeclaringType()).thenReturn(instrumentedType);
when(resolution.isRebased()).thenReturn(true);
when(resolution.getResolvedMethod()).thenReturn(rebasedMethod);
when(resolution.getAdditionalArguments()).thenReturn(NullConstant.INSTANCE);
when(rebasedMethod.isSpecializableFor(instrumentedType)).thenReturn(true);
Implementation.SpecialMethodInvocation specialMethodInvocation = makeImplementationTarget().invokeSuper(rebasedSignatureToken);
assertThat(specialMethodInvocation.isValid(), is(true));
assertThat(specialMethodInvocation.getMethodDescription(), is((MethodDescription) rebasedMethod));
assertThat(specialMethodInvocation.getTypeDescription(), is(instrumentedType));
MethodVisitor methodVisitor = mock(MethodVisitor.class);
Implementation.Context implementationContext = mock(Implementation.Context.class);
StackManipulation.Size size = specialMethodInvocation.apply(methodVisitor, implementationContext);
verify(methodVisitor).visitInsn(Opcodes.ACONST_NULL);
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKESPECIAL, BAZ, QUX, FOO, false);
verifyNoMoreInteractions(methodVisitor);
verifyZeroInteractions(implementationContext);
assertThat(size.getSizeImpact(), is(1));
assertThat(size.getMaximalSize(), is(1));
}
示例4: testAccessorIsValid
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testAccessorIsValid() throws Exception {
TypeProxy typeProxy = new TypeProxy(mock(TypeDescription.class),
mock(Implementation.Target.class),
mock(TypeProxy.InvocationFactory.class),
false,
false);
TypeProxy.MethodCall methodCall = typeProxy.new MethodCall(mock(MethodAccessorFactory.class));
TypeDescription instrumentedType = mock(TypeDescription.class);
FieldList<FieldDescription.InDefinedShape> fieldList = mock(FieldList.class);
when(fieldList.filter(any(ElementMatcher.class))).thenReturn(fieldList);
when(fieldList.getOnly()).thenReturn(mock(FieldDescription.InDefinedShape.class));
when(instrumentedType.getDeclaredFields()).thenReturn(fieldList);
TypeProxy.MethodCall.Appender appender = methodCall.new Appender(instrumentedType);
Implementation.SpecialMethodInvocation specialMethodInvocation = mock(Implementation.SpecialMethodInvocation.class);
when(specialMethodInvocation.isValid()).thenReturn(true);
StackManipulation stackManipulation = appender.new AccessorMethodInvocation(mock(MethodDescription.class), specialMethodInvocation);
assertThat(stackManipulation.isValid(), is(true));
verify(specialMethodInvocation).isValid();
verifyNoMoreInteractions(specialMethodInvocation);
}
示例5: testNonRebasedMethodIsInvokable
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Test
public void testNonRebasedMethodIsInvokable() throws Exception {
when(invokableMethod.getDeclaringType()).thenReturn(instrumentedType);
when(invokableMethod.isSpecializableFor(instrumentedType)).thenReturn(true);
when(resolution.isRebased()).thenReturn(false);
when(resolution.getResolvedMethod()).thenReturn(invokableMethod);
Implementation.SpecialMethodInvocation specialMethodInvocation = makeImplementationTarget().invokeSuper(rebasedSignatureToken);
assertThat(specialMethodInvocation.isValid(), is(true));
assertThat(specialMethodInvocation.getMethodDescription(), is((MethodDescription) invokableMethod));
assertThat(specialMethodInvocation.getTypeDescription(), is(instrumentedType));
MethodVisitor methodVisitor = mock(MethodVisitor.class);
Implementation.Context implementationContext = mock(Implementation.Context.class);
StackManipulation.Size size = specialMethodInvocation.apply(methodVisitor, implementationContext);
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKESPECIAL, BAZ, FOO, QUX, false);
verifyNoMoreInteractions(methodVisitor);
verifyZeroInteractions(implementationContext);
assertThat(size.getSizeImpact(), is(0));
assertThat(size.getMaximalSize(), is(0));
}
示例6: testNonSpecializableSuperClassMethodIsNotInvokable
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Test
public void testNonSpecializableSuperClassMethodIsNotInvokable() throws Exception {
when(invokableMethod.isSpecializableFor(rawSuperClass)).thenReturn(false);
when(resolution.isRebased()).thenReturn(false);
when(resolution.getResolvedMethod()).thenReturn(invokableMethod);
Implementation.SpecialMethodInvocation specialMethodInvocation = makeImplementationTarget().invokeSuper(invokableToken);
assertThat(specialMethodInvocation.isValid(), is(false));
}
示例7: of
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
/**
* Creates a special method invocation for the given method.
*
* @param resolvedMethod The rebased method to be invoked.
* @param instrumentedType The instrumented type on which the method is to be invoked if it is non-static.
* @param additionalArguments Any additional arguments that are to be provided to the rebased method.
* @return A special method invocation of the rebased method.
*/
protected static Implementation.SpecialMethodInvocation of(MethodDescription resolvedMethod,
TypeDescription instrumentedType,
StackManipulation additionalArguments) {
StackManipulation stackManipulation = resolvedMethod.isStatic()
? MethodInvocation.invoke(resolvedMethod)
: MethodInvocation.invoke(resolvedMethod).special(instrumentedType);
return stackManipulation.isValid()
? new RebasedMethodInvocation(resolvedMethod, instrumentedType, new Compound(additionalArguments, stackManipulation))
: Illegal.INSTANCE;
}
示例8: invokeSuper
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Override
public Implementation.SpecialMethodInvocation invokeSuper(MethodDescription.SignatureToken token) {
MethodRebaseResolver.Resolution resolution = rebaseableMethods.get(token);
return resolution == null
? invokeSuper(methodGraph.getSuperClassGraph().locate(token))
: invokeSuper(resolution);
}
示例9: registerAccessorFor
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Override
public MethodDescription.InDefinedShape registerAccessorFor(Implementation.SpecialMethodInvocation specialMethodInvocation, AccessType accessType) {
throw new AssertionError("Did not expect method call");
}
示例10: invoke
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Override
public Implementation.SpecialMethodInvocation invoke(Implementation.Target implementationTarget,
TypeDescription proxiedType,
MethodDescription instrumentedMethod) {
return implementationTarget.invokeDefault(instrumentedMethod.asSignatureToken(), proxiedType);
}
示例11: make
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Override
protected Implementation.SpecialMethodInvocation make(MethodDescription methodDescription, TypeDescription typeDescription) {
return new RebaseImplementationTarget.RebasedMethodInvocation(methodDescription, typeDescription, mock(StackManipulation.class));
}
示例12: testNonSpecializableSuperClassMethodIsNotInvokable
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
@Test
public void testNonSpecializableSuperClassMethodIsNotInvokable() throws Exception {
when(invokableMethod.isSpecializableFor(rawSuperClass)).thenReturn(false);
Implementation.SpecialMethodInvocation specialMethodInvocation = makeImplementationTarget().invokeSuper(invokableToken);
assertThat(specialMethodInvocation.isValid(), is(false));
}
示例13: AssignableSignatureCall
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
/**
* Creates an operand stack assignment that creates a
* {@link net.bytebuddy.implementation.auxiliary.MethodCallProxy} for the
* {@code targetMethod} and pushes this proxy object onto the stack.
*
* @param specialMethodInvocation The special method invocation which should be invoked by the created method
* call proxy.
* @param serializable Determines if the generated proxy should be serializableProxy.
*/
public AssignableSignatureCall(Implementation.SpecialMethodInvocation specialMethodInvocation,
boolean serializable) {
this.specialMethodInvocation = specialMethodInvocation;
this.serializable = serializable;
}
示例14: DelegationMethod
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
/**
* Creates a new delegation method.
*
* @param specialMethodInvocation The special method invocation that represents the super method call.
* @param cached {@code true} if the method constant should be cached.
*/
protected DelegationMethod(Implementation.SpecialMethodInvocation specialMethodInvocation, boolean cached) {
this.specialMethodInvocation = specialMethodInvocation;
this.cached = cached;
}
示例15: resolve
import net.bytebuddy.implementation.Implementation; //导入方法依赖的package包/类
/**
* Locates the correct default method to a given source method.
*
* @param implementationTarget The current implementation target.
* @param source The source method for which a default method should be looked up.
* @return A special method invocation of the default method or an illegal special method invocation,
* if no suitable invocation could be located.
*/
Implementation.SpecialMethodInvocation resolve(Implementation.Target implementationTarget,
MethodDescription source);