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


Java ClassLoadingStrategy.BOOTSTRAP_LOADER属性代码示例

本文整理汇总了Java中net.bytebuddy.dynamic.loading.ClassLoadingStrategy.BOOTSTRAP_LOADER属性的典型用法代码示例。如果您正苦于以下问题:Java ClassLoadingStrategy.BOOTSTRAP_LOADER属性的具体用法?Java ClassLoadingStrategy.BOOTSTRAP_LOADER怎么用?Java ClassLoadingStrategy.BOOTSTRAP_LOADER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.bytebuddy.dynamic.loading.ClassLoadingStrategy的用法示例。


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

示例1: testStorageKeyBootstrapLoaderReference

@Test
public void testStorageKeyBootstrapLoaderReference() throws Exception {
    AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey key = new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey(ClassLoadingStrategy.BOOTSTRAP_LOADER);
    assertThat(key.isBootstrapLoader(), is(true));
    assertThat(key.hashCode(), is(0));
    assertThat(key.get(), nullValue(ClassLoader.class));
    AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey other = new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey(new URLClassLoader(new URL[0]));
    System.gc();
    assertThat(other.get(), nullValue(ClassLoader.class));
    assertThat(key, not(is(other)));
    assertThat(key, is(new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey(ClassLoadingStrategy.BOOTSTRAP_LOADER)));
    assertThat(key, is((Object) new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey(ClassLoadingStrategy.BOOTSTRAP_LOADER)));
    assertThat(key, not(is((Object) new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey(new URLClassLoader(new URL[0])))));
    assertThat(key, is(key));
    assertThat(key, not(is(new Object())));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:16,代码来源:AgentBuilderRedefinitionStrategyResubmissionStrategyTest.java

示例2: testPreparedMethod

@Test
public void testPreparedMethod() throws Exception {
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassFileExtraction.of(SampleAnnotation.class));
    Class<?> type = createPlain()
            .defineMethod(BAR, String.class, Visibility.PUBLIC)
            .intercept(new PreparedMethod())
            .make()
            .load(classLoader, ClassLoadingStrategy.Default.WRAPPER)
            .getLoaded();
    assertThat(type.getDeclaredMethods().length, is(2));
    assertThat(type.getDeclaredMethod(FOO, Object.class).getName(), is(FOO));
    assertThat(type.getDeclaredMethod(FOO, Object.class).getReturnType(), CoreMatchers.<Class<?>>is(Object.class));
    assertThat(type.getDeclaredMethod(FOO, Object.class).getParameterTypes().length, is(1));
    assertThat(type.getDeclaredMethod(FOO, Object.class).getParameterTypes()[0], CoreMatchers.<Class<?>>is(Object.class));
    assertThat(type.getDeclaredMethod(FOO, Object.class).getModifiers(), is(MODIFIERS));
    assertThat(type.getDeclaredMethod(FOO, Object.class).getAnnotations().length, is(1));
    Annotation methodAnnotation = type.getDeclaredMethod(FOO, Object.class).getAnnotations()[0];
    assertThat(methodAnnotation.annotationType().getName(), is(SampleAnnotation.class.getName()));
    Method methodMethod = methodAnnotation.annotationType().getDeclaredMethod(FOO);
    assertThat(methodMethod.invoke(methodAnnotation), is((Object) BAR));
    assertThat(type.getDeclaredMethod(FOO, Object.class).getParameterAnnotations()[0].length, is(1));
    Annotation parameterAnnotation = type.getDeclaredMethod(FOO, Object.class).getParameterAnnotations()[0][0];
    assertThat(parameterAnnotation.annotationType().getName(), is(SampleAnnotation.class.getName()));
    Method parameterMethod = parameterAnnotation.annotationType().getDeclaredMethod(FOO);
    assertThat(parameterMethod.invoke(parameterAnnotation), is((Object) QUX));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:26,代码来源:AbstractDynamicTypeBuilderTest.java

示例3: testVisibilityBridge

@Test
public void testVisibilityBridge() throws Exception {
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER,
            ClassFileExtraction.of(PackagePrivateVisibilityBridgeExtension.class, VisibilityBridge.class, FooBar.class));
    Class<?> type = create(PackagePrivateVisibilityBridgeExtension.class)
            .modifiers(Opcodes.ACC_PUBLIC)
            .make()
            .load(classLoader, ClassLoadingStrategy.Default.INJECTION)
            .getLoaded();
    assertThat(type.getDeclaredConstructors().length, is(1));
    Constructor<?> constructor = type.getDeclaredConstructor();
    constructor.setAccessible(true);
    assertThat(type.getDeclaredMethods().length, is(2));
    Method foo = type.getDeclaredMethod(FOO, String.class);
    foo.setAccessible(true);
    assertThat(foo.isBridge(), is(true));
    assertThat(foo.getDeclaredAnnotations().length, is(1));
    assertThat(foo.getDeclaredAnnotations()[0].annotationType().getName(), is(FooBar.class.getName()));
    assertThat(foo.invoke(constructor.newInstance(), BAR), is((Object) (FOO + BAR)));
    assertThat(foo.getParameterAnnotations()[0].length, is(1));
    assertThat(foo.getParameterAnnotations()[0][0].annotationType().getName(), is(FooBar.class.getName()));
    assertThat(foo.invoke(constructor.newInstance(), BAR), is((Object) (FOO + BAR)));
    Method bar = type.getDeclaredMethod(BAR, List.class);
    bar.setAccessible(true);
    assertThat(bar.isBridge(), is(true));
    assertThat(bar.getDeclaredAnnotations().length, is(0));
    List<?> list = new ArrayList<Object>();
    assertThat(bar.invoke(constructor.newInstance(), list), sameInstance((Object) list));
    assertThat(bar.getGenericReturnType(), instanceOf(Class.class));
    assertThat(bar.getGenericParameterTypes()[0], instanceOf(Class.class));
    assertThat(bar.getGenericExceptionTypes()[0], instanceOf(Class.class));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:32,代码来源:AbstractDynamicTypeBuilderForInliningTest.java

示例4: testNoVisibilityBridgeForAbstractMethod

@Test
public void testNoVisibilityBridgeForAbstractMethod() throws Exception {
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER,
            ClassFileExtraction.of(PackagePrivateVisibilityBridgeExtensionAbstractMethod.class, VisibilityBridgeAbstractMethod.class));
    Class<?> type = create(PackagePrivateVisibilityBridgeExtensionAbstractMethod.class)
            .modifiers(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT)
            .make()
            .load(classLoader, ClassLoadingStrategy.Default.INJECTION)
            .getLoaded();
    assertThat(type.getDeclaredConstructors().length, is(1));
    assertThat(type.getDeclaredMethods().length, is(0));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:AbstractDynamicTypeBuilderForInliningTest.java

示例5: testLookupKeyBootstrapLoaderReference

@Test
public void testLookupKeyBootstrapLoaderReference() throws Exception {
    AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey key = new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey(ClassLoadingStrategy.BOOTSTRAP_LOADER);
    assertThat(key.hashCode(), is(0));
    AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey other = new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey(new URLClassLoader(new URL[0]));
    System.gc();
    assertThat(key, not(is(other)));
    assertThat(key, is(new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey(ClassLoadingStrategy.BOOTSTRAP_LOADER)));
    assertThat(key, is((Object) new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey(ClassLoadingStrategy.BOOTSTRAP_LOADER)));
    assertThat(key, not(is((Object) new AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey(new URLClassLoader(new URL[0])))));
    assertThat(key, is(key));
    assertThat(key, not(is(new Object())));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:13,代码来源:AgentBuilderRedefinitionStrategyResubmissionStrategyTest.java

示例6: setUp

@Before
public void setUp() throws Exception {
    classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER,
            ClassFileExtraction.of(Foo.class, Bar.class, AgentBuilderDefaultApplicationSuperTypeLoadingTest.class),
            ByteArrayClassLoader.PersistenceHandler.MANIFEST);
    executorService = Executors.newCachedThreadPool();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:7,代码来源:AgentBuilderDefaultApplicationSuperTypeLoadingTest.java

示例7: testNoVisibilityBridgeForInheritedType

@Test
public void testNoVisibilityBridgeForInheritedType() throws Exception {
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER,
            ClassFileExtraction.of(PublicVisibilityBridgeExtension.class, VisibilityBridge.class, FooBar.class));
    Class<?> type = new ByteBuddy().subclass(PublicVisibilityBridgeExtension.class)
            .modifiers(Opcodes.ACC_PUBLIC)
            .make()
            .load(classLoader, ClassLoadingStrategy.Default.INJECTION)
            .getLoaded();
    assertThat(type.getDeclaredConstructors().length, is(1));
    assertThat(type.getDeclaredMethods().length, is(0));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:AbstractDynamicTypeBuilderForInliningTest.java

示例8: testImplicitStrategyNonBootstrap

@Test
public void testImplicitStrategyNonBootstrap() throws Exception {
    ClassLoader classLoader = new URLClassLoader(new URL[0], ClassLoadingStrategy.BOOTSTRAP_LOADER);
    Class<?> type = new ByteBuddy()
            .subclass(Object.class)
            .make()
            .load(classLoader)
            .getLoaded();
    assertThat(type.getClassLoader(), is(classLoader));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:10,代码来源:ByteBuddyTest.java

示例9: testImplicitStrategyInjectable

@Test
public void testImplicitStrategyInjectable() throws Exception {
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER, Collections.<String, byte[]>emptyMap());
    Class<?> type = new ByteBuddy()
            .subclass(Object.class)
            .make()
            .load(classLoader)
            .getLoaded();
    assertThat(type.getClassLoader(), is(classLoader));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:10,代码来源:ByteBuddyTest.java

示例10: setUp

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER,
            ClassFileExtraction.of(Sample.class, SampleDefault.class, Other.class, SampleEnumeration.class, ExplicitTarget.class));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:7,代码来源:AnnotationDescriptionForLoadedAnnotationDifferentClassLoaderTest.java

示例11: malform

public static Class<?> malform(Class<?> type) throws Exception {
    ClassReader classReader = new ClassReader(type.getName());
    ClassWriter classWriter = new ClassWriter(classReader, 0);
    classReader.accept(new SignatureMalformer(classWriter), 0);
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER,
            Collections.singletonMap(type.getName(), classWriter.toByteArray()),
            ByteArrayClassLoader.PersistenceHandler.MANIFEST);
    return classLoader.loadClass(type.getName());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:AbstractTypeDescriptionTest.java

示例12: testFinalType

@Test
public void testFinalType() throws Exception {
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassFileExtraction.of(SimpleInterceptor.class));
    Class<?> type = new ByteBuddy()
            .rebase(FinalType.class)
            .modifiers(TypeManifestation.PLAIN, Visibility.PUBLIC)
            .method(named(FOO)).intercept(ExceptionMethod.throwing(RuntimeException.class))
            .method(named(BAR)).intercept(MethodDelegation.to(SimpleInterceptor.class))
            .make()
            .load(classLoader, ClassLoadingStrategy.Default.INJECTION)
            .getLoaded();
    assertThat(type.getDeclaredMethod(BAR).invoke(type.getDeclaredConstructor().newInstance()), is((Object) FOO));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:13,代码来源:MethodDelegationSuperTest.java

示例13: testTypeInitializer

@Test
public void testTypeInitializer() throws Exception {
    ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassFileExtraction.of(Bar.class));
    Class<?> type = createPlain()
            .invokable(isTypeInitializer()).intercept(MethodCall.invoke(Bar.class.getDeclaredMethod("invoke")))
            .make()
            .load(classLoader, ClassLoadingStrategy.Default.WRAPPER)
            .getLoaded();
    assertThat(type.getDeclaredConstructor().newInstance(), notNullValue(Object.class));
    Class<?> foo = classLoader.loadClass(Bar.class.getName());
    assertThat(foo.getDeclaredField(FOO).get(null), is((Object) FOO));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:AbstractDynamicTypeBuilderTest.java

示例14: testInitializerWithDisabledContext

@Test
public void testInitializerWithDisabledContext() throws Exception {
    ClassLoader classLoader = new URLClassLoader(new URL[0], ClassLoadingStrategy.BOOTSTRAP_LOADER);
    Class.forName(new ByteBuddy()
            .with(Implementation.Context.Disabled.Factory.INSTANCE)
            .redefine(type)
            .invokable(isTypeInitializer()).intercept(StubMethod.INSTANCE)
            .make()
            .load(classLoader)
            .getLoaded().getName(), true, classLoader);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:TypeWriterInitializerRemapperTest.java

示例15: testNoInitializerWithEnabledContext

@Test
public void testNoInitializerWithEnabledContext() throws Exception {
    ClassLoader classLoader = new URLClassLoader(new URL[0], ClassLoadingStrategy.BOOTSTRAP_LOADER);
    Class.forName(new ByteBuddy()
            .redefine(type)
            .make()
            .load(classLoader)
            .getLoaded().getName(), true, classLoader);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:TypeWriterInitializerRemapperTest.java


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