<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 14:24:30 UTC 2019


Hi,

A gc was added after "PropertyEditorManager.registerEditor(targetClass, 
editorClass);" based on Alan's patch.
Would you please review it and give me some advice? Thanks.
-------------------------------------------------------------
public class Test6397609 {
     public static void main(String[] args) throws Exception {
         Class<?> targetClass = Object.class;
         Class<?> editorClass = new MemoryClassLoader().compile("Editor",
                 "public class Editor extends 
java.beans.PropertyEditorSupport {}");
         PropertyEditorManager.registerEditor(targetClass, editorClass);

         // trigger a gc
         Object object = new Object();
         var r = new WeakReference<Object>(object);
         object = null;
         while (r.get() != null) {
             System.gc();
             Thread.sleep(100);
         }

         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) {
             System.gc();
             Thread.sleep(100);
         }

         if (PropertyEditorManager.findEditor(targetClass) != null) {
             throw new Error("unexpected editor is found");
         }
     }
}
-------------------------------------------------------------
For the full patch, please see the attachment.
I benefit a lot from the technical discussion with Alan and Sergey.
Thanks again.

Best regards,
Jie


On 2019年01月07日 20:02, Alan Bateman wrote:
> On 07/01/2019 01:26, Fu Jie wrote:
>> 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);"?
> Okay, probably add a sleep too so that there is some time for 
> reference processing (the original test didn't do this).
>
> Also in my patch I see I put the sleep before the GC, it should be the 
> other way around.
>
> -Alan.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test6397609.diff
Type: text/x-patch
Size: 2245 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/beans-dev/attachments/20190107/54a63add/Test6397609.diff>


More information about the beans-dev mailing list