Loosening requirements for super() invocation

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Jan 27 21:55:43 UTC 2023


(resending with right formatting, sorry)


I see that you have basically left the discussion on remapping exception 
(even though there’s no section on it).

IMHO that is still confusing. The first example ends up like this:

|public PositiveBigInteger(long value) { super(value); // potentially 
doing useless work here if (value <= 0) throw new 
IllegalArgumentException("non-positive value"); } |

|

The second example ends up like this:

|public class CustomDeflaterInputStream extends DeflaterInputStream { 
public CustomDeflaterInputStream(InputStream in) { if (in == null) throw 
new IllegalArgumentException("null input"); super(in); // we avoided 
NullPointerException thrown here } } |

Both are in the form “if (something) throw”. To me that is just 
parameter vaildation. The exact reason as to why parameter validation 
might be helpful in each case is irrelevant here - the two examples are 
morally equivalent - or, at the very least, the second example doesn’t 
deserve “all that space” in the JEP.

You have three very very nice examples:

  * parameter validation
  * passing argument twice
  * complex initialization

I’d say just add three sections with one example each and call it a day. 
Unless you can thing of something that looks more “qualitatively” different.

Maurizio

On 27/01/2023 20:52, Archie Cobbs wrote:

    On Fri, Jan 27, 2023 at 12:16 PM Archie Cobbs <archie.cobbs at gmail.com

    archie.cobbs at gmail.com <http://mailto:archie.cobbs@gmail.com>> wrote:

    On Thu, Jan 26, 2023 at 5:51 PM Brian Goetz <brian.goetz at oracle.com

    brian.goetz at oracle.com <http://mailto:brian.goetz@oracle.com>> wrote:

    I think that’s where we should start; if we are spectacularly
    successful, we can come back for more.

    OK thanks. Proceeding…

    JEP is updated https://bugs.openjdk.org/browse/JDK-8300786. Not
    surprisingly, it has gotten a good bit simpler.

    Change log…

      * Removed discussions of ‘this’ escape, try { } blocks and
        initialization order - Removed if/then example choosing between two
        different superclass constructors - Restate JLS changes

    The updated JLS changes are:

     1. Change the grammar for |ConstructorBody| to:

    ConstructorBody: { [BlockStatements] } ; { [BlockStatements]
    ExplicitConstructorInvocation [BlockStatements] } ;

     1. Specify that the BlockStatements prior to
        ExplicitConstructorInvocation are in a static context (§8.1.3)

    Reload & resume firing… :)

    -Archie

    — Archie L. Cobbs

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230127/5fee5b19/attachment.htm>


More information about the amber-dev mailing list