Author: mbenson Date: Tue Jun 27 15:23:39 2006 New Revision: 417600 URL: http://svn.apache.org/viewvc?rev=417600&view=rev Log: make helpers final (HELPERS); put static stuff before instance-level stuff.
Modified: ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java?rev=417600&r1=417599&r2=417600&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java Tue Jun 27 15:23:39 2006 @@ -47,6 +47,32 @@ = Collections.unmodifiableMap(new HashMap(0)); /** + * Helper instances we've already created (Class to IntrospectionHelper). + */ + private static final Hashtable HELPERS = new Hashtable(); + + /** + * Map from primitive types to wrapper classes for use in + * createAttributeSetter (Class to Class). Note that char + * and boolean are in here even though they get special treatment + * - this way we only need to test for the wrapper class. + */ + private static final Map PRIMITIVE_TYPE_MAP = new HashMap(8); + + // Set up PRIMITIVE_TYPE_MAP + static { + Class[] primitives = {Boolean.TYPE, Byte.TYPE, Character.TYPE, + Short.TYPE, Integer.TYPE, Long.TYPE, + Float.TYPE, Double.TYPE}; + Class[] wrappers = {Boolean.class, Byte.class, Character.class, + Short.class, Integer.class, Long.class, + Float.class, Double.class}; + for (int i = 0; i < primitives.length; i++) { + PRIMITIVE_TYPE_MAP.put (primitives[i], wrappers[i]); + } + } + + /** * Map from attribute names to attribute types * (String to Class). */ @@ -85,32 +111,6 @@ */ private Class bean; - /** - * Helper instances we've already created (Class to IntrospectionHelper). - */ - private static Hashtable helpers = new Hashtable(); - - /** - * Map from primitive types to wrapper classes for use in - * createAttributeSetter (Class to Class). Note that char - * and boolean are in here even though they get special treatment - * - this way we only need to test for the wrapper class. - */ - private static final Map PRIMITIVE_TYPE_MAP = new HashMap(8); - - // Set up PRIMITIVE_TYPE_MAP - static { - Class[] primitives = {Boolean.TYPE, Byte.TYPE, Character.TYPE, - Short.TYPE, Integer.TYPE, Long.TYPE, - Float.TYPE, Double.TYPE}; - Class[] wrappers = {Boolean.class, Byte.class, Character.class, - Short.class, Integer.class, Long.class, - Float.class, Double.class}; - for (int i = 0; i < primitives.length; i++) { - PRIMITIVE_TYPE_MAP.put (primitives[i], wrappers[i]); - } - } - // XXX: (Jon Skeet) The documentation below doesn't draw a clear // distinction between addConfigured and add. It's obvious what the // code *here* does (addConfigured sets both a creator method which @@ -327,13 +327,13 @@ * @return a helper for the specified class */ public static IntrospectionHelper getHelper(Project p, Class c) { - IntrospectionHelper ih = (IntrospectionHelper) helpers.get(c); + IntrospectionHelper ih = (IntrospectionHelper) HELPERS.get(c); if (ih == null) { ih = new IntrospectionHelper(c); if (p != null) { // #30162: do *not* cache this if there is no project, as we // cannot guarantee that the cache will be cleared. - helpers.put(c, ih); + HELPERS.put(c, ih); } } if (p != null) { @@ -1328,7 +1328,7 @@ nestedTypes.clear(); nestedCreators.clear(); addText = null; - helpers.clear(); + HELPERS.clear(); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]