MigratedInspection { private MigrationResult migrate() throws InspectionTransformationException { byte[] oldClassFile = transformed.toBytecode(); String oldClassName = transformed.getTransformedClass().getName(); String newClassName = transformed.getOriginalClass().getName(); Inspection serverInspection = transformed.getTransformedInspection(); NamedAsset transformedAsset = transformed.toShrinkWrapAsset(); try { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); JavaArchive archive = ShrinkWrap.create(JavaArchive.class).add(transformedAsset); ShrinkWrapClassLoader shrinkWrapClassLoader = new ShrinkWrapClassLoader(ClassLoaderUtils.getBootstrapClassLoader(), archive); SeparatedClassLoader separatedClassLoader = new SeparatedClassLoader(shrinkWrapClassLoader, contextClassLoader); return SeparateInvocator.<Migration, MigrationImpl>invoke(MigrationImpl.class, separatedClassLoader).process( oldClassName, newClassName, oldClassFile, serverInspection); } catch (Throwable e) { throw new IllegalStateException("Cannot migrate transformed inspection back to original name", e); } } MigratedInspection(TransformedInspection transformed); byte[] toBytecode(); byte[] toSerializedForm();  }
@Test public void testMigrate() throws Throwable { Inspection originalInspection = TestTransformedInspection.getAnonymousServerInspection(); assertTrue(originalInspection.getClass().isAnonymousClass()); TransformedInspection transformedInspection = new TransformedInspection(originalInspection); MigratedInspection migratedInspection = new MigratedInspection(transformedInspection); byte[] bytecode = migratedInspection.toBytecode(); Class<?> migratedClass = SeparateInvocator.<MigrationTest, MigrationTestImpl>invoke(MigrationTestImpl.class, classPath()).process(bytecode); assertEquals(originalInspection.getClass().getName(), migratedClass.getName()); }