@Test
public void testMemoryClassLoader() throws IOException, ReflectiveOperationException, URISyntaxException {

    final String className = "/" + MemoryClassLoaderTest.class.getName().replace('.', '/');
    URL url = MemoryClassLoaderTest.class.getResource(className.concat(".class"));
    MemoryFileSystem fs = new MemoryFileSystem();
    try(ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        InputStream input = Files.newInputStream(Paths.get(url.toURI()))) {
        transferTo(input, bytes);
        fs.write(className.concat(".class"), bytes.toByteArray());
    }
    MemoryClassLoader cl = new MemoryClassLoader(fs,null);
    Class<?> clazz = cl.loadClass(MemoryClassLoaderTest.class.getName());
    assertTrue(Modifier.isPublic(clazz.getMethod("testMemoryClassLoader").getModifiers()));
    assertThrows(NoSuchFieldException.class, () -> clazz.getField("otherField"));
}