Re: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-26 Thread Peter Levart
On 04/26/2016 04:56 PM, Alan Bateman wrote: On 26/04/2016 15:42, Peter Levart wrote: I increased the timeout to 30 seconds. It is not exactly 30 seconds, but 300 iterations with sleep(100L) + check in each iteration. If the system is really overloaded then this loop should stretch automatic

Re: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-26 Thread Alan Bateman
On 26/04/2016 15:42, Peter Levart wrote: I increased the timeout to 30 seconds. It is not exactly 30 seconds, but 300 iterations with sleep(100L) + check in each iteration. If the system is really overloaded then this loop should stretch automatically: http://cr.openjdk.java.net/~plevart/jdk

Re: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-26 Thread Peter Levart
Hi Alan, On 04/25/2016 02:58 PM, Alan Bateman wrote: On 25/04/2016 12:13, Peter Levart wrote: Hi Alan, I created an issue for this: JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe https://bugs.openjdk.java.net/browse/JDK-8155005 I did what you suggested, renamed

Re: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-25 Thread Claes Redestad
On 2016-04-25 15:02, Alan Bateman wrote: On 25/04/2016 13:54, Claes Redestad wrote: Hi, I think this looks good, but since these WeakPairMaps won't be used for many applications I wonder if it's worth keeping the implementation lazy, for example by moving the maps to a holder class: http:

Re: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-25 Thread Alan Bateman
On 25/04/2016 13:54, Claes Redestad wrote: Hi, I think this looks good, but since these WeakPairMaps won't be used for many applications I wonder if it's worth keeping the implementation lazy, for example by moving the maps to a holder class: http://cr.openjdk.java.net/~redestad/scratch/tran

Re: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-25 Thread Alan Bateman
On 25/04/2016 12:13, Peter Levart wrote: Hi Alan, I created an issue for this: JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe https://bugs.openjdk.java.net/browse/JDK-8155005 I did what you suggested, renamed type parameters to , split long line in Module and

Re: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-25 Thread Claes Redestad
ds loading the WeakPairMap class for various small programs and should be neutral in other regards. Thanks! /Claes On 2016-04-25 13:13, Peter Levart wrote: Hi Alan, I created an issue for this: JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe https://bugs.openjd

RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-25 Thread Peter Levart
Hi Alan, I created an issue for this: JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe https://bugs.openjdk.java.net/browse/JDK-8155005 I did what you suggested, renamed type parameters to , split long line in Module and modified the test so that it now waits for

Re: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-24 Thread Alan Bateman
On 22/04/2016 14:42, Peter Levart wrote: : I tried to reduce the complexity of WeakPairMap as much as I could. I added some docs that describe the architecture. Hopefully this is now easier to grasp: http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.03/

Re: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-22 Thread Peter Levart
Hi Alan, Thanks for taking a look. On 04/21/2016 10:41 PM, Alan Bateman wrote: On 21/04/2016 20:52, Rémi Forax wrote: I remember seeing this codd an thinking that synchronized should do the job. I don't believe this use case requires something more complex. Remi I've taken a first pass over

Re: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-21 Thread Alan Bateman
On 21/04/2016 20:52, Rémi Forax wrote: I remember seeing this codd an thinking that synchronized should do the job. I don't believe this use case requires something more complex. Remi I've taken a first pass over it and WeakPairMap seems straight-forward to use but its implementation, with Pai

Re: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-21 Thread Rémi Forax
I remember seeing this codd an thinking that synchronized should do the job. I don't believe this use case requires something more complex. Remi Le 21 avril 2016 18:21:55 CEST, Alan Bateman a écrit : > > >On 21/04/2016 17:07, Peter Levart wrote: >> : >> >> ...while this seems OK from 1st look,

Re: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-21 Thread Peter Levart
On 04/21/2016 06:07 PM, Peter Levart wrote: I propose to add a thread-safe WeakPairMap data structure which associates a pair of weakly-reachable keys with a strongly-reachable value based on ConcurrentHashMap. Such data structure is footprint-friendly, since only a single instance exists for

Re: java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-21 Thread Alan Bateman
On 21/04/2016 17:07, Peter Levart wrote: : ...while this seems OK from 1st look, it is not. WeakHashMap is not thread-safe even for seemingly read-only operations. All its operations can mutate internal state in a non-thread-safe way. The simplest way to fix this is to use a writeLock for c

java.lang.reflect.Module.WeakSet is not thread-safe

2016-04-21 Thread Peter Levart
Hi, While browsing code in java.lang.reflect.Module (I sometimes do that just to see how thinks work ;-) I stumbled on the following nested class: private static class WeakSet { private final ReadWriteLock lock = new ReentrantReadWriteLock(); private final Lock readLock = l