<Beans Dev> Fwd: Re: [PATCH] test/jdk/java/beans/PropertyEditor/Test6397609.java failed in JITed code

Fu Jie fujie at loongson.cn
Mon Jan 7 01:26:04 UTC 2019


Hi,

Thanks Alan for your guidance. I like this patch and it seems very nice.
Do you think we need to trigger a GC after 
"PropertyEditorManager.registerEditor(targetClass, editorClass);"?

Best regards,
Jie


> Here's an alternative to consider:
>
>         Class<?> targetClass = Object.class;
>         Class<?> editorClass = new MemoryClassLoader().compile("Editor",
>                 "public class Editor extends 
> java.beans.PropertyEditorSupport {}");
>         PropertyEditorManager.registerEditor(targetClass, editorClass);
>
>         if (PropertyEditorManager.findEditor(targetClass) == null) {
>             throw new Error("the editor is lost");
>         }
>
>         // allow, and wait for, Editor class to be unloaded
>         var ref = new WeakReference<Class<?>>(editorClass);
>         editorClass = null;
>         while (ref.get() != null) {
>             Thread.sleep(100);
>             System.gc();
>         }
>
>         if (PropertyEditorManager.findEditor(targetClass) != null) {
>             throw new Error("unexpected editor is found");
>         }
>
> As regards looping until a weak ref has been cleared then we do this 
> in many tests. I've no doubt that many tests and features would fail 
> with -DisableExplicitGC but this shouldn't be a concern here.
>
> -Alan



More information about the beans-dev mailing list