EntryPointTransformer implements LightClassFileTransformer { @Override public byte[] transform(final ClassLoader classLoader, final String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) { if (!filter.allow(classLoader, className)) { return null; } try { return transform(classLoader, className, classfileBuffer); } catch (Exception exception) { logger.info(exception); } return null; } EntryPointTransformer(TraceRegisterBinder traceRegisterBinder, TraceContext traceContext);  EntryPointTransformer(TraceRegisterBinder traceRegisterBinder, TraceContext traceContext, TraceRepository traceRepository); private  EntryPointTransformer(TraceRegisterBinder traceRegisterBinder, TraceContext traceContext, TraceRepository traceRepository, String ownerClassName, String begin, String beginDescriptor, String end, String endDescriptor); private  EntryPointTransformer(TraceRegisterBinder traceRegisterBinder, TraceContext traceContext, String ownerClassName, String begin, String beginDescriptor, String end, String endDescriptor); @Override byte[] transform(final ClassLoader classLoader, final String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer); @Override ClassNodeWrapper transform(ClassLoader classLoader, Class<?> classBeingRedefined, byte[] classfileBuffer, ClassNodeWrapper classNodeWrapper); void refresh();  }
@Test public void testTransform() throws Exception { String className = TestMethods.class.getName(); LightClassFileTransformer transformer = new EntryPointTransformer(new DefaultTraceRegisterBinder(), new AgentTraceContext(ProfilerConfig.load(getClass().getClassLoader(), "light.conf"))); byte[] original = TestUtil.load(className); ClassNodeWrapper classNodeWrapper = ASMUtil.parse(original); transformer.transform(getClass().getClassLoader(), null, original, classNodeWrapper); byte[] transform = ASMUtil.toBytes(classNodeWrapper); assertThat(original, not(transform)); TestClassLoader classLoader = new TestClassLoader(getClass().getClassLoader()); Class<?> clazz = classLoader.findClass(className, transform); assertThat(clazz, notNullValue()); assertThat(clazz.getName(), is(className)); Object instance = clazz.newInstance(); Method method = clazz.getDeclaredMethod("doWithObject", String.class); assertThat((String) method.invoke(instance, "A"), is("A")); assertThat((String) method.invoke(instance, "B"), is("B")); method = clazz.getDeclaredMethod("doWithNothing"); assertThat(method.invoke(instance), nullValue()); }