From mskoruppa at ripstech.com Thu Mar 29 14:15:53 2018 From: mskoruppa at ripstech.com (Malte Skoruppa) Date: Thu, 29 Mar 2018 16:15:53 +0200 Subject: Mistake in JLS 8.4.1 (Java SE 8 / 9 /10) Message-ID: <1b781713-c25f-97e4-f163-20044d73243d@ripstech.com> Dear JLS Team, I found what I believe to be a small mistake in section 8.4.1 of the JLS for Java SE 8, 9, and 10. In this section it is stated: > If a method or constructor has no formal parameters, only an empty > pair of parentheses appears in the declaration of the method or > constructor. > I believe this statement to be incorrect for the following reason: If a method or constructor that has no formal parameters uses a receiver parameter in its declaration, then no empty pair of parentheses appears in the declaration, even though the method or constructor has no formal parameters. This directly contradicts the above statement. For example, the method: class A { ? foo(A this) { ... } } has no formal parameters, yet no empty pair of parentheses appears in its declaration. I can tell from personal experience that the statement is indeed confusing: When I read it at first, I implicitly inferred from it that a receiver parameter must also be (a special kind of) formal parameter (since otherwise the statement would be incorrect). However, this is not true. Later in the same section (8.4.1), it is explicitly stated that: > The receiver parameter is not a formal parameter Therefore I propose to rephrase the statement as follows: > If a method or constructor has no formal parameters *and does not > specify a receiver parameter*, only an empty pair of parentheses > appears in the declaration of the method or constructor. > ...or similar. Best, -- *Dr. Malte Skoruppa* *Lead Software Engineer* mskoruppa at ripstech.com *RIPS TECHNOLOGIES GMBH* Universitaetsstrasse 142 44799 Bochum Germany www.ripstech.com RIPS Technologies GmbH