use of net.bytebuddy.dynamic.loading.ByteArrayClassLoader in project byte-buddy by raphw.
the class AbstractDynamicTypeBuilderForInliningTest method 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));
}
use of net.bytebuddy.dynamic.loading.ByteArrayClassLoader in project byte-buddy by raphw.
the class AbstractDynamicTypeBuilderForInliningTest method testNoVisibilityBridgeForNonPublicType.
@Test
public void testNoVisibilityBridgeForNonPublicType() throws Exception {
ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassFileExtraction.of(PackagePrivateVisibilityBridgeExtension.class, VisibilityBridge.class, FooBar.class));
Class<?> type = create(PackagePrivateVisibilityBridgeExtension.class).modifiers(0).make().load(classLoader, ClassLoadingStrategy.Default.INJECTION).getLoaded();
assertThat(type.getDeclaredConstructors().length, is(1));
assertThat(type.getDeclaredMethods().length, is(0));
}
use of net.bytebuddy.dynamic.loading.ByteArrayClassLoader in project byte-buddy by raphw.
the class AbstractDynamicTypeBuilderForInliningTest method 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));
}
use of net.bytebuddy.dynamic.loading.ByteArrayClassLoader in project morphia by mongodb.
the class TestClassLoader method useClassLoading.
private void useClassLoading(Function<ClassLoader, MongoCollection<BasicEntity>> collectionCreator) {
storePreviousInstance();
ClassLoader classLoader = new ByteArrayClassLoader(new AppClassLoader(), false, Map.of());
Class<?> childClass = loadDynamicClass(classLoader);
BasicEntity res = collectionCreator.apply(classLoader).find().first();
assertTrue(childClass.isInstance(res.data));
}
use of net.bytebuddy.dynamic.loading.ByteArrayClassLoader in project byte-buddy by raphw.
the class AbstractTypeDescriptionTest method testIsAssignableClassLoader.
@Test
public void testIsAssignableClassLoader() throws Exception {
ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassFileExtraction.of(SimpleType.class), ByteArrayClassLoader.PersistenceHandler.MANIFEST);
Class<?> otherSimpleType = classLoader.loadClass(SimpleType.class.getName());
assertThat(describe(SimpleType.class).isAssignableFrom(describe(otherSimpleType)), is(true));
assertThat(describe(SimpleType.class).isAssignableTo(describe(otherSimpleType)), is(true));
assertThat(describe(Object.class).isAssignableFrom(describe(otherSimpleType)), is(true));
assertThat(describe(otherSimpleType).isAssignableTo(describe(Object.class)), is(true));
}
Aggregations