From some-java-user-99206970363698485155 at vodafonemail.de Wed Apr 2 19:58:47 2025 From: some-java-user-99206970363698485155 at vodafonemail.de (some-java-user-99206970363698485155 at vodafonemail.de) Date: Wed, 2 Apr 2025 21:58:47 +0200 Subject: JLS: Clarify that assignment result does not re-read variable Message-ID: Hello, the JLS 23 ??15.26 "Assignment Operators" [1] says this about the result of assignments: > Thus, |a=b=c| means |a=(b=c)|, which assigns the value of |c| to |b| > and then assigns the value of |b| to |a|. > At run time, the result of the assignment expression is the value of > the variable after the assignment has occurred. This creates some ambiguity because these sentences sound as if there is (or at least there is permitted to be) an additional read of the assigned variable. That is, |a=b=c| is equivalent to: ``` b = c a = b ``` However, what is actually happening is (if I understand it correctly): ``` temp = c b = temp a = temp ``` (respectively the compiler just emits a `dup` before assigning the value to the variables) This does make a difference for concurrent programs where a racy write is (intentionally) happening to the intermediate variable, in the example above 'b'. Therefore it would probably be good to reword that JLS section, or clarify that the assigned variable is not read again for the result value (unless JVMs are actually permitted to do that). [1] https://docs.oracle.com/javase/specs/jls/se23/html/jls-15.html#jls-15.26 -------------- next part -------------- An HTML attachment was scrubbed... URL: From chand at apache.org Thu Apr 3 23:13:32 2025 From: chand at apache.org (chandpriyankara) Date: Fri, 4 Apr 2025 10:13:32 +1100 Subject: jls.1.1 ambiguity Message-ID: Hi, Regarding v24 of JLS.1.1 'Classes support concurrent programming with synchronized methods' *Should't we use 'multi-threaded' instead 'concurrent'?* In my understanding, there's no need for a 'synchronized' keyword unless multi-threaded. Using 'concurrent' may be to emphasis it's used in "java's concurrency", but not all concurrent use cases require 'synchronized' keyword. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pietro.braione at unimib.it Thu Apr 24 22:34:57 2025 From: pietro.braione at unimib.it (Pietro Braione) Date: Fri, 25 Apr 2025 00:34:57 +0200 Subject: Discrepancy between JVMS and Hotspot Message-ID: Hello to everyone. The JVMS v24 (but also all the JVMS since v8) at section 4.7.13 says that: "There may be no more than one LocalVariableTable attribute per local variable in the attributes table of a Code attribute.? (Something similar holds for the LocalVariableTypeTable attribute). But there are compilers (ecj) that, when a method has zero local variables, emit a single, zero-length LocalVariableTable attribute, and Hotspot happily accepts these classfiles. Best, Pietro Braione University of Milano-Bicocca