@Test public void testLoadFromJar() throws Exception { File jar = Files.createTempFile("battlecode-test", ".jar").toFile(); jar.deleteOnExit(); ZipOutputStream z = new ZipOutputStream(new FileOutputStream(jar)); ZipEntry classEntry = new ZipEntry("instrumentertest/Nothing.class"); z.putNextEntry(classEntry); IOUtils.copy( getClass().getClassLoader().getResourceAsStream("instrumentertest/Nothing.class"), z); z.closeEntry(); z.close(); IndividualClassLoader jarLoader = new IndividualClassLoader( "instrumentertest", new IndividualClassLoader.Cache(jar.toURI().toURL())); Class<?> jarClass = jarLoader.loadClass("instrumentertest.Nothing"); URL jarClassLocation = jarClass.getResource("Nothing.class"); // EXTREMELY scientific assertTrue(jarClassLocation.toString().startsWith("jar:")); assertTrue(jarClassLocation.toString().contains(jar.toURI().toURL().toString())); }