Search in sources :

Example 1 with AnonymousClassInfo

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfo in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfosTest method testTransitionsSignatrues.

@Test
public void testTransitionsSignatrues() throws Exception {
    AnonymousClassInfos stateInfo = getClassPoolInfos(AnonymousTestClass2.class);
    stateInfo.mapPreviousState(getClassPoolInfos(AnonymousTestClass1.class));
    Map<AnonymousClassInfo, AnonymousClassInfo> mappings = stateInfo.getCompatibleTransitions();
    for (Map.Entry<AnonymousClassInfo, AnonymousClassInfo> mapping : mappings.entrySet()) {
        assertNotNull("Class not mapped " + mapping.getKey(), mapping.getValue());
        assertEquals(mapping.getKey().getClassName(), AnonymousTestClass1.class.getName() + "$1");
        assertEquals(mapping.getValue().getClassName(), AnonymousTestClass2.class.getName() + "$1");
    }
}
Also used : AnonymousClassInfos(org.hotswap.agent.plugin.jvm.AnonymousClassInfos) AnonymousClassInfo(org.hotswap.agent.plugin.jvm.AnonymousClassInfo) Map(java.util.Map) Test(org.junit.Test)

Example 2 with AnonymousClassInfo

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfo in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfoTest method getAnonymousCtClassInfo.

public AnonymousClassInfo getAnonymousCtClassInfo() throws NotFoundException, ClassNotFoundException, IOException, CannotCompileException {
    Class clazz = getClass().getClassLoader().loadClass(AnonymousTestClass1.class.getName() + "$1");
    ClassPool classPool = new ClassPool();
    classPool.appendClassPath(new LoaderClassPath(getClass().getClassLoader()));
    return new AnonymousClassInfo(classPool.get(clazz.getName()));
}
Also used : ClassPool(org.hotswap.agent.javassist.ClassPool) LoaderClassPath(org.hotswap.agent.javassist.LoaderClassPath) AnonymousClassInfo(org.hotswap.agent.plugin.jvm.AnonymousClassInfo)

Example 3 with AnonymousClassInfo

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfo in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfosTest method testTransitionsSameClass.

@Test
public void testTransitionsSameClass() throws Exception {
    AnonymousClassInfos stateInfo = getClassPoolInfos(AnonymousTestClass1.class);
    stateInfo.mapPreviousState(getClassPoolInfos(AnonymousTestClass1.class));
    Map<AnonymousClassInfo, AnonymousClassInfo> mappings = stateInfo.getCompatibleTransitions();
    for (Map.Entry<AnonymousClassInfo, AnonymousClassInfo> mapping : mappings.entrySet()) {
        assertNotNull("Class not mapped " + mapping.getKey(), mapping.getValue());
        assertTrue("Class not exact match " + mapping.getKey(), mapping.getKey().matchExact(mapping.getValue()));
        assertEquals(mapping.getKey().getClassName(), AnonymousTestClass1.class.getName() + "$1");
        assertEquals(mapping.getValue().getClassName(), AnonymousTestClass1.class.getName() + "$1");
    }
}
Also used : AnonymousClassInfos(org.hotswap.agent.plugin.jvm.AnonymousClassInfos) AnonymousClassInfo(org.hotswap.agent.plugin.jvm.AnonymousClassInfo) Map(java.util.Map) Test(org.junit.Test)

Aggregations

AnonymousClassInfo (org.hotswap.agent.plugin.jvm.AnonymousClassInfo)3 Map (java.util.Map)2 AnonymousClassInfos (org.hotswap.agent.plugin.jvm.AnonymousClassInfos)2 Test (org.junit.Test)2 ClassPool (org.hotswap.agent.javassist.ClassPool)1 LoaderClassPath (org.hotswap.agent.javassist.LoaderClassPath)1