You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Gilles Scokart <gs...@gmail.com> on 2009/09/03 20:51:46 UTC

Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java

What is the benefits of having the parameters final ?


Gilles Scokart


2009/9/3 <bo...@apache.org>

> Author: bodewig
> Date: Thu Sep  3 07:26:20 2009
> New Revision: 810793
>
> URL: http://svn.apache.org/viewvc?rev=810793&view=rev
> Log:
> whitespace and make method paarameters final
>
> Modified:
>
>  ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
>
> Modified:
> ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
> URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java?rev=810793&r1=810792&r2=810793&view=diff
>
> ==============================================================================
> ---
> ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
> (original)
> +++
> ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
> Thu Sep  3 07:26:20 2009
> @@ -141,20 +141,20 @@
>         if (filtersCount > 0) {
>             boolean success = false;
>             try {
> -            for (int i = 0; i < filtersCount; i++) {
> -                Object o = finalFilters.elementAt(i);
> +                for (int i = 0; i < filtersCount; i++) {
> +                    Object o = finalFilters.elementAt(i);
>
> -                if (o instanceof AntFilterReader) {
> -                    instream =
> -                        expandReader((AntFilterReader)
> finalFilters.elementAt(i),
> -                                     instream, classLoadersToCleanUp);
> -                } else if (o instanceof ChainableReader) {
> -                    setProjectOnObject(o);
> -                    instream = ((ChainableReader) o).chain(instream);
> -                    setProjectOnObject(instream);
> +                    if (o instanceof AntFilterReader) {
> +                        instream =
> +                            expandReader((AntFilterReader)
> finalFilters.elementAt(i),
> +                                         instream, classLoadersToCleanUp);
> +                    } else if (o instanceof ChainableReader) {
> +                        setProjectOnObject(o);
> +                        instream = ((ChainableReader) o).chain(instream);
> +                        setProjectOnObject(instream);
> +                    }
>                 }
> -            }
> -            success = true;
> +                success = true;
>             } finally {
>                 if (!success && classLoadersToCleanUp.size() > 0) {
>                     cleanUpClassLoaders(classLoadersToCleanUp);
> @@ -221,8 +221,9 @@
>      *
>      * @since Ant 1.8.0
>      */
> -    private Reader expandReader(AntFilterReader filter, Reader ancestor,
> -                                List/*<AntClassLoader>*/
> classLoadersToCleanUp) {
> +    private Reader expandReader(final AntFilterReader filter,
> +                                final Reader ancestor,
> +                                final List/*<AntClassLoader>*/
> classLoadersToCleanUp) {
>         final String className = filter.getClassName();
>         final Path classpath = filter.getClasspath();
>         final Project pro = filter.getProject();
>
>
>

Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java

Posted by Jeffrey E Care <ca...@us.ibm.com>.
Gilles Scokart <gs...@gmail.com> wrote on 09/03/2009 02:51:46 PM:

> Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/
> ant/filters/util/ChainReaderHelper.java
> 
> What is the benefits of having the parameters final ?

It prevents you from inadvertently changing which object the parameter 
name points to *within the method body*.

Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java

Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-09-03, Gilles Scokart <gs...@gmail.com> wrote:

> What is the benefits of having the parameters final ?

Apart from what Jeffrey said, the local variables that became parameters
when I extracted the method have been final in the first place - and I
wanted to stay true to the original code.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org