Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 00C42200D0B for ; Mon, 28 Aug 2017 14:15:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F36741646AE; Mon, 28 Aug 2017 12:15:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 475881646AC for ; Mon, 28 Aug 2017 14:15:06 +0200 (CEST) Received: (qmail 11372 invoked by uid 500); 28 Aug 2017 12:15:05 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 11308 invoked by uid 99); 28 Aug 2017 12:15:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Aug 2017 12:15:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F29261A2DC9 for ; Mon, 28 Aug 2017 12:15:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id CBJAjMAvrbhs for ; Mon, 28 Aug 2017 12:15:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id ED3B05FC43 for ; Mon, 28 Aug 2017 12:15:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 5A199E0295 for ; Mon, 28 Aug 2017 12:15:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 49F5825387 for ; Mon, 28 Aug 2017 12:15:00 +0000 (UTC) Date: Mon, 28 Aug 2017 12:15:00 +0000 (UTC) From: "Paul King (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (GROOVY-8300) Groovy should have an @AutoFinal annotation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 28 Aug 2017 12:15:07 -0000 [ https://issues.apache.org/jira/browse/GROOVY-8300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16143608#comment-16143608 ] Paul King edited comment on GROOVY-8300 at 8/28/17 12:14 PM: ------------------------------------------------------------- I suspect we won't ever introduce that ability to apply to fields but if we did it might be something like {{@AutoFinal(includeFields=true)}} rather than {{@AutoFinalFields}}. You could imagine an annotation definition something like: {code} public @interface AutoFinal { boolean includeFields() default false boolean includeProperties() default false /** should all methods be marked final */ boolean includeMethods() default false boolean includeConstructors() default false boolean includeMethodParams() default true boolean includeConstructorParams() default true } {code} Or instead of all these booleans, we could use something similar to the {{PackageScopeTarget}} enum that {{@PackageScope}} uses. was (Author: paulk): I suspect we won't ever introduce that ability to apply to fields but if we did it might be something like {{@AutoFinal(includeFields=true)}} rather than {{@AutoFinalFields}}. You could imagine an annotation definition something like: {code} public @interface AutoFinal { boolean includeFields() default false boolean includeProperties() default false /** should all methods be marked final */ boolean includeMethods() default false boolean includeConstructors() default false boolean includeMethodParams() default true boolean includeConstructorParams() default true } {code} > Groovy should have an @AutoFinal annotation > ------------------------------------------- > > Key: GROOVY-8300 > URL: https://issues.apache.org/jira/browse/GROOVY-8300 > Project: Groovy > Issue Type: New Feature > Reporter: Paul King > > When defined on a method or constructor, all parameters of that method/constructor will be final. When applied on a class, the annotation applies to all methods/constructors. > Discussion points: > # Should visibility matter, e.g. would it apply to all public, protected, private, etc. members, or does there need to be some ability to customise? *Current thinking*: it should apply to all methods. We can always introduce an additional annotation attribute at a later point if there is demand. > # Should there be support for 'includes' or 'excludes' functionality? *Current thinking*: don't support this for now. The annotation can be applied on multiple methods/constructors if finer granularity than the class level is required. > # Should the annotation apply to fields/properties? Applying 'final' to a field/property seems to be more efficient than applying @AutoFinal but would there ever be a desire to apply such an annotation to all fields/properties? *Current thinking*: don't support this for now. An annotation attribute could be added later if we wanted to optionally turn such extra cases on. > # Should it apply to synthetic methods/constructors added by the compiler/other transforms? > # What phase should this run at? It needs to be before the (incubating) final variable analyser is run. > # We should have tests to confirm that there are no adverse interactions with other language features, e.g. default parameter values. -- This message was sent by Atlassian JIRA (v6.4.14#64029)