当前位置: 首页>>代码示例>>Java>>正文


Java SuperMethodCall类代码示例

本文整理汇总了Java中net.bytebuddy.implementation.SuperMethodCall的典型用法代码示例。如果您正苦于以下问题:Java SuperMethodCall类的具体用法?Java SuperMethodCall怎么用?Java SuperMethodCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SuperMethodCall类属于net.bytebuddy.implementation包,在下文中一共展示了SuperMethodCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transformClasses

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
private static void transformClasses(Instrumentation instrumentation) {

		new AgentBuilder.Default().withListener(new AgentListener()).type(geTypeMatchers())
				.transform(new Transformer() {

					@Override
					public Builder<?> transform(Builder<?> builder, TypeDescription typeDescription) {

						return builder
								.invokable(isAnnotatedWith(named(INJECT_ANNOTATION))
										.or(isAnnotatedWith(named(AUTOWIRED_ANNOTATION))))
								.intercept(SuperMethodCall.INSTANCE
										.andThen(MethodDelegation.to(InjectionInterceptor.class)));
					}

				}).installOn(instrumentation);
	}
 
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:18,代码来源:DIAgent.java

示例2: extendClass

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
public static Class extendClass(Class<?> extend, final LuaTable delegations, Class<?>... inherit) {
	long startTime = System.nanoTime();

	ArrayDeque<Class> toCheck = new ArrayDeque<Class>();
	toCheck.add(extend);
	toCheck.addAll(Arrays.asList(inherit));
	extendClassWhile(toCheck, delegations);

	try {
		ReceiverTypeDefinition<?> build = b.subclass(extend).implement(inherit)
				.method(not(isConstructor()).and(isAbstract()))
				.intercept(MethodDelegation.to(new AbstractInterceptor(delegations)));
		if (!delegations.get("__new__").isnil()) {
			build = build.constructor(isConstructor()).intercept(
					SuperMethodCall.INSTANCE.andThen(MethodDelegation.to(new ConstructorInterceptor(delegations))));
		}
		Junction<MethodDescription> publicMethods = not(isConstructor().or(isAbstract())).and(isPublic())
				.and(new ElementMatcher<MethodDescription>() {
					@Override
					public boolean matches(MethodDescription target) {
						return !delegations.get(target.getName()).isnil();
					}
				});
		build = build.method(publicMethods).intercept(MethodDelegation.to(new PublicInterceptor(delegations)));

		Unloaded unloaded = build.make();
		Loaded loaded = Compatibility.get().load(unloaded);
		Class c = loaded.getLoaded();
		Log.debug("Created dynamic class " + c.getName() + " in " + ((System.nanoTime() - startTime) / 1000000)
				+ "ms");
		return c;
	} catch (Exception e) {
		Log.error("Failed to create dynamic class " + extend.getName() + " " + Arrays.toString(inherit));
		throw new CubesException("Failed to make dynamic class", e);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:37,代码来源:LuaGeneration.java

示例3: makeEnumeration

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
/**
 * <p>
 * Creates a new {@link Enum} type.
 * </p>
 * <p>
 * <b>Note</b>: Byte Buddy does not cache previous subclasses but will attempt the generation of a new subclass. For caching
 * types, a external cache or {@link TypeCache} should be used.
 * </p>
 *
 * @param values The names of the type's enumeration constants
 * @return A type builder for creating an enumeration type.
 */
public DynamicType.Builder<? extends Enum<?>> makeEnumeration(Collection<? extends String> values) {
    if (values.isEmpty()) {
        throw new IllegalArgumentException("Require at least one enumeration constant");
    }
    TypeDescription.Generic enumType = TypeDescription.Generic.Builder.parameterizedType(Enum.class, TargetType.class).build();
    return new SubclassDynamicTypeBuilder<Enum<?>>(instrumentedTypeFactory.subclass(namingStrategy.subclass(enumType),
            ModifierContributor.Resolver.of(Visibility.PUBLIC, TypeManifestation.FINAL, EnumerationState.ENUMERATION).resolve(),
            enumType),
            classFileVersion,
            auxiliaryTypeNamingStrategy,
            annotationValueFilterFactory,
            annotationRetention,
            implementationContextFactory,
            methodGraphCompiler,
            typeValidation,
            ignoredMethods,
            ConstructorStrategy.Default.NO_CONSTRUCTORS)
            .defineConstructor(Visibility.PRIVATE).withParameters(String.class, int.class)
            .intercept(SuperMethodCall.INSTANCE)
            .defineMethod(EnumerationImplementation.ENUM_VALUE_OF_METHOD_NAME,
                    TargetType.class,
                    Visibility.PUBLIC, Ownership.STATIC).withParameters(String.class)
            .intercept(MethodCall.invoke(enumType.getDeclaredMethods()
                    .filter(named(EnumerationImplementation.ENUM_VALUE_OF_METHOD_NAME).and(takesArguments(Class.class, String.class))).getOnly())
                    .withOwnType().withArgument(0)
                    .withAssigner(Assigner.DEFAULT, Assigner.Typing.DYNAMIC))
            .defineMethod(EnumerationImplementation.ENUM_VALUES_METHOD_NAME,
                    TargetType[].class,
                    Visibility.PUBLIC, Ownership.STATIC)
            .intercept(new EnumerationImplementation(new ArrayList<String>(values)));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:44,代码来源:ByteBuddy.java

示例4: doInject

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Override
protected MethodRegistry doInject(MethodRegistry methodRegistry, MethodAttributeAppender.Factory methodAttributeAppenderFactory) {
    return methodRegistry.append(new LatentMatcher.Resolved<MethodDescription>(isConstructor()),
            new MethodRegistry.Handler.ForImplementation(SuperMethodCall.INSTANCE),
            methodAttributeAppenderFactory,
            Transformer.NoOp.<MethodDescription>make());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:ConstructorStrategy.java

示例5: transform

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder,
                                        TypeDescription typeDescription,
                                        ClassLoader classLoader,
                                        JavaModule module) {
    return builder.constructor(ElementMatchers.any()).intercept(SuperMethodCall.INSTANCE);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:AgentBuilderDefaultApplicationTest.java

示例6: testConstructorRebaseSingleAuxiliaryType

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Test
public void testConstructorRebaseSingleAuxiliaryType() throws Exception {
    DynamicType.Unloaded<?> dynamicType = new ByteBuddy()
            .rebase(Bar.class)
            .constructor(any()).intercept(SuperMethodCall.INSTANCE)
            .make();
    assertThat(dynamicType.getAuxiliaryTypes().size(), is(1));
    Class<?> type = dynamicType.load(new URLClassLoader(new URL[0], null), ClassLoadingStrategy.Default.WRAPPER).getLoaded();
    assertThat(type.getDeclaredConstructors().length, is(2));
    assertThat(type.getDeclaredMethods().length, is(0));
    Field field = type.getDeclaredField(BAR);
    assertThat(field.get(type.getDeclaredConstructor(String.class).newInstance(FOO)), is((Object) FOO));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:14,代码来源:RebaseDynamicTypeBuilderTest.java

示例7: testRebaseOfRenamedType

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Test
public void testRebaseOfRenamedType() throws Exception {
    Class<?> rebased = new ByteBuddy()
            .rebase(Sample.class)
            .name(Sample.class.getName() + FOO)
            .constructor(ElementMatchers.any())
            .intercept(SuperMethodCall.INSTANCE)
            .make()
            .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER)
            .getLoaded();
    assertThat(rebased.getName(), is(Sample.class.getName() + FOO));
    assertThat(rebased.getDeclaredConstructors().length, is(2));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:14,代码来源:RebaseDynamicTypeBuilderTest.java

示例8: testCannotRebaseDefinedMethod

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testCannotRebaseDefinedMethod() throws Exception {
    new ByteBuddy()
            .rebase(Foo.class)
            .defineMethod(FOO, void.class).intercept(SuperMethodCall.INSTANCE)
            .make();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:RebaseDynamicTypeBuilderTest.java

示例9: testConstructorOnInterfaceAssertion

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testConstructorOnInterfaceAssertion() throws Exception {
    new ByteBuddy()
            .makeInterface()
            .defineConstructor(Visibility.PUBLIC)
            .intercept(SuperMethodCall.INSTANCE)
            .make();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:TypeWriterDefaultTest.java

示例10: testConstructorOnAnnotationAssertion

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testConstructorOnAnnotationAssertion() throws Exception {
    new ByteBuddy()
            .makeAnnotation()
            .defineConstructor(Visibility.PUBLIC)
            .intercept(SuperMethodCall.INSTANCE)
            .make();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:TypeWriterDefaultTest.java

示例11: testDefaultMethodCallFromLegacyType

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
@JavaVersionRule.Enforce(8)
public void testDefaultMethodCallFromLegacyType() throws Exception {
    new ByteBuddy(ClassFileVersion.JAVA_V7)
            .subclass(Class.forName("net.bytebuddy.test.precompiled.SingleDefaultMethodInterface"))
            .method(isDefaultMethod())
            .intercept(SuperMethodCall.INSTANCE)
            .make();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:10,代码来源:TypeWriterDefaultTest.java

示例12: benchmarkByteBuddyWithPrefix

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark uses delegation but completes with a
 * hard-coded super method call.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkByteBuddyWithPrefix() throws Exception {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClass)
            .method(isDeclaredBy(baseClass)).intercept(MethodDelegation.to(ByteBuddyPrefixInterceptor.class).andThen(SuperMethodCall.INSTANCE))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:ClassByExtensionBenchmark.java

示例13: benchmarkByteBuddyWithPrefixAndReusedDelegator

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark uses delegation but completes with a
 * hard-coded super method call. This benchmark reuses a precomputed delegator.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkByteBuddyWithPrefixAndReusedDelegator() throws Exception {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClass)
            .method(isDeclaredBy(baseClass)).intercept(prefixInterceptor.andThen(SuperMethodCall.INSTANCE))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:ClassByExtensionBenchmark.java

示例14: benchmarkByteBuddyWithPrefixWithTypePool

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark uses delegation but completes with a
 * hard-coded super method call. This benchmark uses a type pool to compare against usage of the reflection API.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkByteBuddyWithPrefixWithTypePool() throws Exception {
    return (ExampleClass) new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClassDescription)
            .method(isDeclaredBy(baseClassDescription)).intercept(MethodDelegation.to(prefixClassDescription).andThen(SuperMethodCall.INSTANCE))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:ClassByExtensionBenchmark.java

示例15: benchmarkByteBuddyWithPrefixAndReusedDelegatorWithTypePool

import net.bytebuddy.implementation.SuperMethodCall; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark uses delegation but completes with a
 * hard-coded super method call. This benchmark reuses a precomputed delegator. This benchmark uses a type pool to
 * compare against usage of the reflection API.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkByteBuddyWithPrefixAndReusedDelegatorWithTypePool() throws Exception {
    return (ExampleClass) new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClassDescription)
            .method(isDeclaredBy(baseClassDescription)).intercept(prefixInterceptorDescription.andThen(SuperMethodCall.INSTANCE))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:ClassByExtensionBenchmark.java


注:本文中的net.bytebuddy.implementation.SuperMethodCall类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。