Re: Are there real use cases with the Java access modes?
Gregg Wonderly via Concurrency-interest <[email protected]> Sun, 18 Jul 2021 00:10:21 -0400
| Newsgroups | gmane.comp.java.jsr.166-concurrency |
|---|---|
| Message-ID | <[email protected]> |
Yes this was changed at the sane time the JMM defined and caused implementation of volatile to happen. While this is legal because of the JMM, it causes broken code to happen without the user really understanding why it could happen and that it will happen. It’s different in significant ways from cache coherency, and it worked prior to JDK1.5. I still believe that volatile creates a giant surprise. This is an optimization behavior that “breaks” code without the user electing to have such an optimization performed! The default variable declaration should be volatile and a different mechanism should be necessary to get non-volatile optimizations to happen. A user should never, ever, be able to write non-working code using default language constructs. Look at the past examples in C-Language and C++ etc. Things like Register optimizations and many other constructs required the user to break their code, rather than that being the default behavior! Gregg Wonderly Sent from my iPhone > On Jul 17, 2021, at 5:05 PM, Shuyang Liu <[email protected]> wrote: > > Thanks you! > > I guess this is before Java 9? So I think “nonVolatileRefExpr” is equivalent to a plain access in this case. The compiler probably identified it as a local access since it is not marked as volatile (then its indeed equivalent to an infinite loop, which makes the transformation valid). Do you know if there’s any applications/bug report with this pattern? > > Best Regards, > Shuyang > >>> On Jul 17, 2021, at 1:46 PM, Gregg Wonderly <[email protected]> wrote: >>> >> One of the standing problems I have is optimizations around non-volatile value references. Currently, there are visibility optimizations that turn >> >> while( nonVolatileRefExpr ) {} >> >> Into >> >> if( nonVolatileRefExpr ) { while( true ) {} } >> >> Which creates infinite loops. This makes one of the most common types of applications written in Swing to fail to work as the code is written. >> >> Gregg Wonderly >> >> Sent from my iPhone >> >>>> On Jul 17, 2021, at 4:33 PM, Shuyang Liu via Concurrency-interest <[email protected]> wrote: >>>> >>> >>> Hello, >>> >>> My colleagues and I have been working on a formal model for the Java access modes that is added since Java 9 [1]. Are there any popular use cases of access modes in real world applications/frameworks/libraries? We would like to see how our current formal model works in real examples. >>> >>> Thanks you, >>> Shuyang Liu >>> >>> [1]. Using JDK 9 Memory Order Modes >>> http://gee.cs.oswego.edu/dl/html/j9mm.html >>> _______________________________________________ >>> Concurrency-interest mailing list >>> [email protected] >>> http://cs.oswego.edu/mailman/listinfo/concurrency-interest _______________________________________________ Concurrency-interest mailing list [email protected] http://cs.oswego.edu/mailman/listinfo/concurrency-interest