• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TypeValidation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: giveDynamicSubclass

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static synchronized <S> Class<S> giveDynamicSubclass(Class<S> superclass) {
    boolean isSystemClass = isSystemClass(superclass.getName());
    String namePrefix = isSystemClass ? "$" : "";
    String name = namePrefix + superclass.getName() + "$$DynamicSubclass";

    Class<S> existsAlready = (Class<S>)classForName(name);
    if (existsAlready != null) {
        return existsAlready;
    }

    Class<?> context = isSystemClass ? Instantiator.class : superclass;
    return (Class<S>)new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .subclass(superclass)
            .name(name)
            .make()
            .load(context.getClassLoader(), ClassLoadingStrategy.Default.INJECTION.with(context.getProtectionDomain()))
            .getLoaded();
}
 
开发者ID:jqno,项目名称:equalsverifier,代码行数:21,代码来源:Instantiator.java


示例2: agent

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
private static synchronized void agent(final boolean shouldRedefine, final Instrumentation instrumentation)
{
    BufferAlignmentAgent.instrumentation = instrumentation;
    // all Int methods, and all String method other than
    // XXXStringWithoutLengthXXX or getStringXXX(int, int)
    final Junction<MethodDescription> intVerifierMatcher = nameContains("Int")
        .or(nameMatches(".*String[^W].*").and(not(ElementMatchers.takesArguments(int.class, int.class))));

    alignmentTransformer = new AgentBuilder.Default(new ByteBuddy().with(TypeValidation.DISABLED))
        .with(LISTENER)
        .disableClassFormatChanges()
        .with(shouldRedefine ?
            AgentBuilder.RedefinitionStrategy.RETRANSFORMATION :
            AgentBuilder.RedefinitionStrategy.DISABLED)
        .type(isSubTypeOf(DirectBuffer.class).and(not(isInterface())))
        .transform((builder, typeDescription, classLoader, module) -> builder
            .visit(to(LongVerifier.class).on(nameContains("Long")))
            .visit(to(DoubleVerifier.class).on(nameContains("Double")))
            .visit(to(IntVerifier.class).on(intVerifierMatcher))
            .visit(to(FloatVerifier.class).on(nameContains("Float")))
            .visit(to(ShortVerifier.class).on(nameContains("Short")))
            .visit(to(CharVerifier.class).on(nameContains("Char"))))
        .installOn(instrumentation);
}
 
开发者ID:real-logic,项目名称:agrona,代码行数:25,代码来源:BufferAlignmentAgent.java


示例3: ByteBuddy

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Creates a new Byte Buddy instance.
 *
 * @param classFileVersion             The class file version to use for types that are not based on an existing class file.
 * @param namingStrategy               The naming strategy to use.
 * @param auxiliaryTypeNamingStrategy  The naming strategy to use for naming auxiliary types.
 * @param annotationValueFilterFactory The annotation value filter factory to use.
 * @param annotationRetention          The annotation retention strategy to use.
 * @param implementationContextFactory The implementation context factory to use.
 * @param methodGraphCompiler          The method graph compiler to use.
 * @param instrumentedTypeFactory      The instrumented type factory to use.
 * @param typeValidation               Determines if a type should be explicitly validated.
 * @param ignoredMethods               A matcher for identifying methods that should be excluded from instrumentation.
 */
protected ByteBuddy(ClassFileVersion classFileVersion,
                    NamingStrategy namingStrategy,
                    AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                    AnnotationValueFilter.Factory annotationValueFilterFactory,
                    AnnotationRetention annotationRetention,
                    Implementation.Context.Factory implementationContextFactory,
                    MethodGraph.Compiler methodGraphCompiler,
                    InstrumentedType.Factory instrumentedTypeFactory,
                    TypeValidation typeValidation,
                    LatentMatcher<? super MethodDescription> ignoredMethods) {
    this.classFileVersion = classFileVersion;
    this.namingStrategy = namingStrategy;
    this.auxiliaryTypeNamingStrategy = auxiliaryTypeNamingStrategy;
    this.annotationValueFilterFactory = annotationValueFilterFactory;
    this.annotationRetention = annotationRetention;
    this.implementationContextFactory = implementationContextFactory;
    this.methodGraphCompiler = methodGraphCompiler;
    this.instrumentedTypeFactory = instrumentedTypeFactory;
    this.ignoredMethods = ignoredMethods;
    this.typeValidation = typeValidation;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:36,代码来源:ByteBuddy.java


示例4: createAgentBuilder

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
private static AgentBuilder createAgentBuilder(AutoEvictingCachingBinaryLocator binaryLocator) {
	final ByteBuddy byteBuddy = new ByteBuddy()
			.with(TypeValidation.of(corePlugin.isDebugInstrumentation()))
			.with(MethodGraph.Compiler.ForDeclaredMethods.INSTANCE);
	return new AgentBuilder.Default(byteBuddy)
			.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
			.with(getListener())
			.with(binaryLocator)
			.ignore(any(), timed("classloader", "reflection", isReflectionClassLoader()))
			.or(any(), timed("classloader", "groovy-call-site", classLoaderWithName("org.codehaus.groovy.runtime.callsite.CallSiteClassLoader")))
			.or(any(), new IsIgnoredClassLoaderElementMatcher())
			.or(timed("type", "global-exclude", nameStartsWith("org.aspectj.")
					.or(nameStartsWith("org.groovy."))
					.or(nameStartsWith("com.p6spy."))
					.or(nameStartsWith("net.bytebuddy."))
					.or(nameStartsWith("org.slf4j.").and(not(nameStartsWith("org.slf4j.impl."))))
					.or(nameContains("javassist"))
					.or(nameContains(".asm."))
					.or(nameStartsWith("org.stagemonitor")
							.and(not(nameContains("Test")
									.or(nameContains("benchmark"))
									.or(nameStartsWith("org.stagemonitor.demo")))))
			))
			.disableClassFormatChanges();
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:26,代码来源:AgentAttacher.java


示例5: generatedClassWithGeneratedFieldWithSuppressedWarning

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
@Test
public void generatedClassWithGeneratedFieldWithSuppressedWarning() {
    class Super {}
    Class<?> sub = new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .subclass(Super.class)
            .defineField("dynamicField", int.class, Visibility.PRIVATE)
            .make()
            .load(Super.class.getClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded();
    AnnotationAccessor accessor = new AnnotationAccessor(TestSupportedAnnotations.values(), sub, NO_INGORED_ANNOTATIONS, true);
    assertFalse(accessor.fieldHas("dynamicField", FIELD_RUNTIME_RETENTION));
}
 
开发者ID:jqno,项目名称:equalsverifier,代码行数:14,代码来源:AnnotationAccessorTest.java


示例6: with

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Creates a new configuration that applies the supplied type validation. By default, explicitly type validation is applied
 * by Byte Buddy but it might be disabled for performance reason or for voluntarily creating illegal types. The Java virtual
 * machine applies its own type validation where some {@link Error} is thrown if a type is invalid, while Byte Buddy throws
 * some {@link RuntimeException}.
 *
 * @param typeValidation The type validation to apply during type creation.
 * @return A new Byte Buddy instance that applies the supplied type validation.
 */
public ByteBuddy with(TypeValidation typeValidation) {
    return new ByteBuddy(classFileVersion,
            namingStrategy,
            auxiliaryTypeNamingStrategy,
            annotationValueFilterFactory,
            annotationRetention,
            implementationContextFactory,
            methodGraphCompiler,
            instrumentedTypeFactory,
            typeValidation,
            ignoredMethods);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:ByteBuddy.java


示例7: testNonGenericResolutionIsLazyForSimpleCreationNonFrozen

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
@Test
public void testNonGenericResolutionIsLazyForSimpleCreationNonFrozen() throws Exception {
    ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
    new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .with(MethodGraph.Empty.INSTANCE)
            .with(InstrumentedType.Factory.Default.MODIFIABLE)
            .redefine(describe(NonGenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()), classFileLocator)
            .make();
    verify(classFileLocator, times(2)).locate(NonGenericType.class.getName());
    verifyNoMoreInteractions(classFileLocator);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:13,代码来源:TypePoolDefaultWithLazyResolutionTypeDescriptionTest.java


示例8: testNonGenericResolutionIsLazyForSimpleCreation

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
@Test
public void testNonGenericResolutionIsLazyForSimpleCreation() throws Exception {
    ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
    new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .with(MethodGraph.Empty.INSTANCE)
            .with(InstrumentedType.Factory.Default.FROZEN)
            .redefine(describe(NonGenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()), classFileLocator)
            .make();
    verify(classFileLocator, times(2)).locate(NonGenericType.class.getName());
    verifyNoMoreInteractions(classFileLocator);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:13,代码来源:TypePoolDefaultWithLazyResolutionTypeDescriptionTest.java


示例9: testGenericResolutionIsLazyForSimpleCreation

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
@Test
public void testGenericResolutionIsLazyForSimpleCreation() throws Exception {
    ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
    new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .with(MethodGraph.Empty.INSTANCE)
            .with(InstrumentedType.Factory.Default.FROZEN)
            .redefine(describe(GenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()), classFileLocator)
            .make();
    verify(classFileLocator, times(2)).locate(GenericType.class.getName());
    verifyNoMoreInteractions(classFileLocator);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:13,代码来源:TypePoolDefaultWithLazyResolutionTypeDescriptionTest.java


示例10: testDelegationToInvisibleFieldTypeThrowsException

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testDelegationToInvisibleFieldTypeThrowsException() throws Exception {
    new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .subclass(Object.class)
            .defineField("foo", Foo.class)
            .method(isToString())
            .intercept(MethodDelegation.toField("foo"))
            .make();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:MethodDelegationOtherTest.java


示例11: benchmarkByteBuddy

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark for a trivial class creation using Byte Buddy.
 *
 * @return The created instance, in order to avoid JIT removal.
 */
@Benchmark
public Class<?> benchmarkByteBuddy() {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(any())
            .subclass(baseClass)
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:16,代码来源:TrivialClassCreationBenchmark.java


示例12: benchmarkByteBuddy

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of an interface implementation using Byte Buddy.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws java.lang.Exception If the reflective invocation causes an exception.
 */
@Benchmark
public ExampleInterface benchmarkByteBuddy() throws Exception {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClass)
            .method(isDeclaredBy(baseClass)).intercept(StubMethod.INSTANCE)
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:20,代码来源:ClassByImplementationBenchmark.java


示例13: benchmarkByteBuddyWithTypePool

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of an interface implementation using Byte Buddy. 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 java.lang.Exception If the reflective invocation causes an exception.
 */
@Benchmark
public ExampleInterface benchmarkByteBuddyWithTypePool() throws Exception {
    return (ExampleInterface) new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClassDescription)
            .method(isDeclaredBy(baseClassDescription)).intercept(StubMethod.INSTANCE)
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:ClassByImplementationBenchmark.java


示例14: benchmarkByteBuddyWithProxy

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark creates proxy classes for the invocation
 * of super methods which requires the creation of auxiliary classes.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws java.lang.Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkByteBuddyWithProxy() throws Exception {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClass)
            .method(isDeclaredBy(baseClass)).intercept(MethodDelegation.to(ByteBuddyProxyInterceptor.class))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:ClassByExtensionBenchmark.java


示例15: benchmarkByteBuddyWithProxyAndReusedDelegator

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark also uses the annotation-based approach
 * but creates delegation methods which do not require the creation of additional classes. 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 benchmarkByteBuddyWithProxyAndReusedDelegator() throws Exception {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClass)
            .method(isDeclaredBy(baseClass)).intercept(proxyInterceptor)
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:ClassByExtensionBenchmark.java


示例16: benchmarkByteBuddyWithProxyWithTypePool

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark creates proxy classes for the invocation
 * of super methods which requires the creation of auxiliary classes. 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 java.lang.Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkByteBuddyWithProxyWithTypePool() throws Exception {
    return (ExampleClass) new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClassDescription)
            .method(isDeclaredBy(baseClassDescription)).intercept(MethodDelegation.to(proxyClassDescription))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:ClassByExtensionBenchmark.java


示例17: benchmarkByteBuddyWithProxyAndReusedDelegatorWithTypePool

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark also uses the annotation-based approach
 * but creates delegation methods which do not require the creation of additional classes. 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 benchmarkByteBuddyWithProxyAndReusedDelegatorWithTypePool() throws Exception {
    return (ExampleClass) new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClassDescription)
            .method(isDeclaredBy(baseClassDescription)).intercept(proxyInterceptorDescription)
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:ClassByExtensionBenchmark.java


示例18: benchmarkByteBuddyWithAccessor

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark also uses the annotation-based approach
 * but creates delegation methods which do not require the creation of additional classes.
 *
 * @return The created instance, in order to avoid JIT removal.
 * @throws Exception If the invocation causes an exception.
 */
@Benchmark
public ExampleClass benchmarkByteBuddyWithAccessor() throws Exception {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClass)
            .method(isDeclaredBy(baseClass)).intercept(MethodDelegation.to(ByteBuddyAccessInterceptor.class))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:ClassByExtensionBenchmark.java


示例19: benchmarkByteBuddyWithAccessorAndReusedDelegator

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark also uses the annotation-based approach
 * but creates delegation methods which do not require the creation of additional classes. 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 benchmarkByteBuddyWithAccessorAndReusedDelegator() throws Exception {
    return new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClass)
            .method(isDeclaredBy(baseClass)).intercept(accessInterceptor)
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:ClassByExtensionBenchmark.java


示例20: benchmarkByteBuddyWithAccessorWithTypePool

import net.bytebuddy.dynamic.scaffold.TypeValidation; //导入依赖的package包/类
/**
 * Performs a benchmark of a class extension using Byte Buddy. This benchmark also uses the annotation-based approach
 * but creates delegation methods which do not require the creation of additional classes. 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 benchmarkByteBuddyWithAccessorWithTypePool() throws Exception {
    return (ExampleClass) new ByteBuddy()
            .with(TypeValidation.DISABLED)
            .ignore(none())
            .subclass(baseClassDescription)
            .method(isDeclaredBy(baseClassDescription)).intercept(MethodDelegation.to(accessClassDescription))
            .make()
            .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded()
            .getDeclaredConstructor()
            .newInstance();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:ClassByExtensionBenchmark.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LogicalSchema类代码示例发布时间:2022-05-22
下一篇:
Java FeaturePropertyType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap