From 502a6bcbf71545cea2109fa6ceb8a60ad5fdfb82 Mon Sep 17 00:00:00 2001 From: Scokart Gilles Date: Thu, 21 Aug 2008 19:06:43 +0000 Subject: [PATCH] add some final keyword to immutable things git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@687832 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/IntrospectionHelper.java | 18 ++++++++++-------- src/main/org/apache/tools/ant/Location.java | 6 +++--- .../tools/ant/TaskConfigurationChecker.java | 2 +- .../org/apache/tools/ant/UnknownElement.java | 2 +- .../ant/UnsupportedAttributeException.java | 2 +- .../tools/ant/UnsupportedElementException.java | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index cc55e6d92..44c973b4f 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -90,40 +90,40 @@ public final class IntrospectionHelper { * Map from attribute names to attribute types * (String to Class). */ - private Hashtable attributeTypes = new Hashtable(); + private final Hashtable attributeTypes = new Hashtable(); /** * Map from attribute names to attribute setter methods * (String to AttributeSetter). */ - private Hashtable attributeSetters = new Hashtable(); + private final Hashtable attributeSetters = new Hashtable(); /** * Map from attribute names to nested types * (String to Class). */ - private Hashtable nestedTypes = new Hashtable(); + private final Hashtable nestedTypes = new Hashtable(); /** * Map from attribute names to methods to create nested types * (String to NestedCreator). */ - private Hashtable nestedCreators = new Hashtable(); + private final Hashtable nestedCreators = new Hashtable(); /** * Vector of methods matching add[Configured](Class) pattern. */ - private List addTypeMethods = new ArrayList(); + private final List addTypeMethods = new ArrayList(); /** * The method to invoke to add PCDATA. */ - private Method addText = null; + private final Method addText; /** * The class introspected by this instance. */ - private Class bean; + private final Class bean; /** * Sole constructor, which is private to ensure that all @@ -178,6 +178,7 @@ public final class IntrospectionHelper { private IntrospectionHelper(final Class bean) { this.bean = bean; Method[] methods = bean.getMethods(); + Method addTextMethod = null; for (int i = 0; i < methods.length; i++) { final Method m = methods[i]; final String name = m.getName(); @@ -202,7 +203,7 @@ public final class IntrospectionHelper { } if ("addText".equals(name) && java.lang.Void.TYPE.equals(returnType) && args.length == 1 && java.lang.String.class.equals(args[0])) { - addText = methods[i]; + addTextMethod = methods[i]; } else if (name.startsWith("set") && java.lang.Void.TYPE.equals(returnType) && args.length == 1 && !args[0].isArray()) { String propName = getPropertyName(name, "set"); @@ -294,6 +295,7 @@ public final class IntrospectionHelper { } } } + addText = addTextMethod; } /** diff --git a/src/main/org/apache/tools/ant/Location.java b/src/main/org/apache/tools/ant/Location.java index 7ad311984..75f3ea38b 100644 --- a/src/main/org/apache/tools/ant/Location.java +++ b/src/main/org/apache/tools/ant/Location.java @@ -31,11 +31,11 @@ import org.xml.sax.Locator; public class Location implements Serializable { /** Name of the file. */ - private String fileName; + private final String fileName; /** Line number within the file. */ - private int lineNumber; + private final int lineNumber; /** Column number within the file. */ - private int columnNumber; + private final int columnNumber; /** Location to use when one is needed but no information is available */ public static final Location UNKNOWN_LOCATION = new Location(); diff --git a/src/main/org/apache/tools/ant/TaskConfigurationChecker.java b/src/main/org/apache/tools/ant/TaskConfigurationChecker.java index 39ea0d043..8cf6a4a1f 100644 --- a/src/main/org/apache/tools/ant/TaskConfigurationChecker.java +++ b/src/main/org/apache/tools/ant/TaskConfigurationChecker.java @@ -59,7 +59,7 @@ public class TaskConfigurationChecker { private List/**/ errors = new ArrayList(); /** Task for which the configuration should be checked. */ - private Task task; + private final Task task; /** * Constructor. diff --git a/src/main/org/apache/tools/ant/UnknownElement.java b/src/main/org/apache/tools/ant/UnknownElement.java index 6aa9eb41c..10d0ca3f8 100644 --- a/src/main/org/apache/tools/ant/UnknownElement.java +++ b/src/main/org/apache/tools/ant/UnknownElement.java @@ -39,7 +39,7 @@ public class UnknownElement extends Task { * task/type that hasn't been defined at parser time or has * been redefined since original creation. */ - private String elementName; + private final String elementName; /** * Holds the namespace of the element. diff --git a/src/main/org/apache/tools/ant/UnsupportedAttributeException.java b/src/main/org/apache/tools/ant/UnsupportedAttributeException.java index 7d082d2ff..09205998a 100644 --- a/src/main/org/apache/tools/ant/UnsupportedAttributeException.java +++ b/src/main/org/apache/tools/ant/UnsupportedAttributeException.java @@ -24,7 +24,7 @@ package org.apache.tools.ant; */ public class UnsupportedAttributeException extends BuildException { - private String attribute; + private final String attribute; /** * Constructs an unsupported attribute exception. diff --git a/src/main/org/apache/tools/ant/UnsupportedElementException.java b/src/main/org/apache/tools/ant/UnsupportedElementException.java index a03bb47ac..8ec49ffce 100644 --- a/src/main/org/apache/tools/ant/UnsupportedElementException.java +++ b/src/main/org/apache/tools/ant/UnsupportedElementException.java @@ -33,7 +33,7 @@ package org.apache.tools.ant; */ public class UnsupportedElementException extends BuildException { - private String element; + private final String element; /** * Constructs an unsupported element exception.