使用DCEVM和HotSwapAgent的WebLogic上奇怪的java.beans.Introspector行为

使用DCEVM和HotSwapAgent的WebLogic上奇怪的java.beans.Introspector行为,weblogic,hotswap,dcevm,Weblogic,Hotswap,Dcevm,我在JVM 1.7上运行WebLogic,使用DCEVM(完整实现)和HotSwapAgent,使用在每次onClassLoad上触发的自定义插件 我遇到了Freemarker的问题,它使用java.beans.Introspector。我发现的事实是,当我调用HotSwapAgent(通过ReflectionCommand)调用的方法的Introspector.flushCaches时,Introspector中的BeanInfo会正确失效(通过该线程中的调试器进行检查)。但是,当我向WLS

我在JVM 1.7上运行WebLogic,使用DCEVM(完整实现)和HotSwapAgent,使用在每次onClassLoad上触发的自定义插件

我遇到了Freemarker的问题,它使用java.beans.Introspector。我发现的事实是,当我调用HotSwapAgent(通过ReflectionCommand)调用的方法的Introspector.flushCaches时,Introspector中的BeanInfo会正确失效(通过该线程中的调试器进行检查)。但是,当我向WLS appserver发出请求时,工作线程的内省程序将显示旧值

这看起来像是一些线程本地实现,但我在java.beans.Introspector的文档中找不到任何可以指向该假设的东西

有人知道为什么会发生这种情况以及如何解决吗

目前,我将有关重新加载的类的信息存储在单独的类中,并从请求线程重新加载缓存中的所有内容,这是可行的


感谢您提供的任何线索。

找到这一点要感谢@ddekany和他对相关问题的回答

JVM(至少是HotSpot 1.7)似乎会为每个线程组缓存Introspector的缓存。这意味着必须在相应的
ThreadGroup
中运行的线程中调用
Introspector.flushCaches

当我对应用程序中的所有线程组执行此操作时,一切又开始正常工作

我找不到任何文档说明为什么
java.beans.Introspector
是按照
ThreadGroup
缓存的,因此如果任何人对此有可靠的信息,请添加带有链接的注释

谢谢

更新:

来自JDK7源代码的提交

/**
     * Introspect on a Java Bean and learn about all its properties, exposed
     * methods, and events.
     * <p>
     * If the BeanInfo class for a Java Bean has been previously Introspected
     * then the BeanInfo class is retrieved from the BeanInfo cache.
     *
     * @param beanClass  The bean class to be analyzed.
     * @return  A BeanInfo object describing the target bean.
     * @exception IntrospectionException if an exception occurs during
     *              introspection.
     * @see #flushCaches
     * @see #flushFromCaches
     */
    public static BeanInfo getBeanInfo(Class<?> beanClass)
        throws IntrospectionException
    {
        if (!ReflectUtil.isPackageAccessible(beanClass)) {
            return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
        }
        ThreadGroupContext context = ThreadGroupContext.getContext();
        BeanInfo beanInfo;
        synchronized (declaredMethodCache) {
            beanInfo = context.getBeanInfo(beanClass);
        }
        if (beanInfo == null) {
            beanInfo = new Introspector(beanClass, null, USE_ALL_BEANINFO).getBeanInfo();
            synchronized (declaredMethodCache) {
                context.putBeanInfo(beanClass, beanInfo);
            }
        }
        return beanInfo;
    }
/**
*对JavaBean进行内省并了解其所有属性,包括
*方法和事件。
*
*如果Java Bean的BeanInfo类之前已被内省
*然后从BeanInfo缓存中检索BeanInfo类。
*
*@param bean对要分析的bean类进行分类。
*@返回一个描述目标bean的BeanInfo对象。
*@exception内省异常如果在
*内省。
*@see#flushCaches
*@see#冲洗缓存
*/
公共静态BeanInfo getBeanInfo(类beanClass)
抛出内省异常
{
如果(!reflecture.isPackageAccessible(beanClass)){
return(new Introspector(beanClass,null,USE_ALL_BEANINFO)).getBeanInfo();
}
ThreadGroupContext=ThreadGroupContext.getContext();
BeanInfo BeanInfo;
已同步(declaredMethodCache){
beanInfo=context.getBeanInfo(beanClass);
}
if(beanInfo==null){
beanInfo=new Introspector(beanClass,null,使用所有beanInfo);
已同步(declaredMethodCache){
上下文。putBeanInfo(beanClass,beanInfo);
}
}
返回beanInfo;
}

这肯定是在JDK7中添加的,因为我检查了JDK6代码,但它不在那里

如果将此功能作为插件嵌入到HotSwapAgent中,那就太好了。我会调查一下。