首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于DCEVM和java.beans.Introspector的WebLogic上奇怪的HotSwapAgent行为

基于DCEVM和java.beans.Introspector的WebLogic上奇怪的HotSwapAgent行为
EN

Stack Overflow用户
提问于 2015-02-27 15:16:52
回答 1查看 437关注 0票数 4

我使用DCEVM (完全实现)在JVM1.7上运行WebLogic,使用在每个onClassLoad上触发的定制插件运行HotSwapAgent。

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

这似乎是一些线程本地实现,但我无法在java.beans.Introspector的文档中找到指向该假设的任何内容。

有没有人知道为什么会发生这种情况,以及如何解决这个问题?

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

谢谢你的任何线索。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-01 17:24:53

这要感谢@ddekany和他对Freemarker removeIntrospectionInfo does not work with DCEVM after model hotswap相关问题的回答。

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

当我对应用程序中的所有ThreadGroups执行此操作时,一切都再次正常工作。

我无法找到任何文件,为什么java.beans.Introspector被缓存在每个ThreadGroup,所以如果有人有可靠的信息,请添加一个链接的评论。

谢谢。

更新:

从JDK7源开始

代码语言:javascript
复制
/**
     * 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;
    }

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28768348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档