| @@ -307,11 +307,11 @@ public class AntTypeDefinition { | |||
| // DataType can have a "no arg" constructor or take a single | |||
| // Project argument. | |||
| try { | |||
| ctor = newclass.getConstructor(new Class[0]); | |||
| ctor = newclass.getConstructor(); | |||
| noArg = true; | |||
| } catch (NoSuchMethodException nse) { | |||
| //can throw the same exception, if there is no this(Project) ctor. | |||
| ctor = newclass.getConstructor(new Class[] {Project.class}); | |||
| ctor = newclass.getConstructor(Project.class); | |||
| noArg = false; | |||
| } | |||
| //now we instantiate | |||
| @@ -750,7 +750,7 @@ public class ComponentHelper { | |||
| */ | |||
| public void exitAntLib() { | |||
| antLibStack.pop(); | |||
| antLibCurrentUri = (antLibStack.isEmpty()) ? null : (String) antLibStack.peek(); | |||
| antLibCurrentUri = (antLibStack.isEmpty()) ? null : antLibStack.peek(); | |||
| } | |||
| /** | |||
| @@ -18,7 +18,6 @@ | |||
| package org.apache.tools.ant; | |||
| import java.io.File; | |||
| import java.io.FilenameFilter; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.OutputStream; | |||
| @@ -122,8 +121,7 @@ public final class Diagnostics { | |||
| * @return array of files (or null for no such directory) | |||
| */ | |||
| private static File[] listJarFiles(File libDir) { | |||
| return libDir | |||
| .listFiles((FilenameFilter) (dir, name) -> name.endsWith(".jar")); | |||
| return libDir.listFiles((dir, name) -> name.endsWith(".jar")); | |||
| } | |||
| /** | |||
| @@ -451,7 +449,7 @@ public final class Diagnostics { | |||
| try { | |||
| Class<?> which = Class.forName("org.apache.env.Which"); | |||
| Method method = which.getMethod( | |||
| "main", new Class[] {String[].class}); | |||
| "main", String[].class); | |||
| method.invoke(null, new Object[]{new String[]{}}); | |||
| } catch (ClassNotFoundException e) { | |||
| out.println("Not available."); | |||
| @@ -616,9 +616,7 @@ public class DirectoryScanner | |||
| public static void resetDefaultExcludes() { | |||
| synchronized (defaultExcludes) { | |||
| defaultExcludes.clear(); | |||
| for (String element : DEFAULTEXCLUDES) { | |||
| defaultExcludes.add(element); | |||
| } | |||
| Collections.addAll(defaultExcludes, DEFAULTEXCLUDES); | |||
| } | |||
| } | |||
| @@ -1046,16 +1044,11 @@ public class DirectoryScanner | |||
| private boolean shouldSkipPattern(final String pattern) { | |||
| if (FileUtils.isAbsolutePath(pattern)) { | |||
| //skip abs. paths not under basedir, if set: | |||
| if (!(basedir == null || SelectorUtils.matchPatternStart(pattern, | |||
| basedir.getAbsolutePath(), | |||
| isCaseSensitive()))) { | |||
| return true; | |||
| } | |||
| } else if (basedir == null) { | |||
| //skip non-abs. paths if basedir == null: | |||
| return true; | |||
| return !(basedir == null || SelectorUtils.matchPatternStart(pattern, | |||
| basedir.getAbsolutePath(), isCaseSensitive())); | |||
| } | |||
| return false; | |||
| return basedir == null; | |||
| } | |||
| /** | |||
| @@ -1823,9 +1816,9 @@ public class DirectoryScanner | |||
| final String target = f.getCanonicalPath(); | |||
| files.add(target); | |||
| String relPath = ""; | |||
| StringBuilder relPath = new StringBuilder(); | |||
| for (final String dir : directoryNamesFollowed) { | |||
| relPath += "../"; | |||
| relPath.append("../"); | |||
| if (dirName.equals(dir)) { | |||
| f = FILE_UTILS.resolveFile(parent, relPath + dir); | |||
| files.add(f.getCanonicalPath()); | |||
| @@ -307,13 +307,8 @@ public final class IntrospectionHelper { | |||
| * @return true if the given set method is to be hidden. | |||
| */ | |||
| private boolean isHiddenSetMethod(final String name, final Class<?> type) { | |||
| if ("setLocation".equals(name) && Location.class.equals(type)) { | |||
| return true; | |||
| } | |||
| if ("setTaskType".equals(name) && String.class.equals(type)) { | |||
| return true; | |||
| } | |||
| return false; | |||
| return "setLocation".equals(name) && Location.class.equals(type) | |||
| || "setTaskType".equals(name) && String.class.equals(type); | |||
| } | |||
| /** | |||
| @@ -472,7 +467,7 @@ public final class IntrospectionHelper { | |||
| + " doesn't support nested text data (\"" + condenseText(text) + "\")."); | |||
| } | |||
| try { | |||
| addText.invoke(element, new Object[] {text}); | |||
| addText.invoke(element, text); | |||
| } catch (final IllegalAccessException ie) { | |||
| // impossible as getMethods should only return public methods | |||
| throw new BuildException(ie); | |||
| @@ -955,7 +950,7 @@ public final class IntrospectionHelper { | |||
| */ | |||
| public Map<String, Class<?>> getAttributeMap() { | |||
| return attributeTypes.isEmpty() | |||
| ? Collections.<String, Class<?>> emptyMap() : Collections.unmodifiableMap(attributeTypes); | |||
| ? Collections.emptyMap() : Collections.unmodifiableMap(attributeTypes); | |||
| } | |||
| /** | |||
| @@ -980,7 +975,7 @@ public final class IntrospectionHelper { | |||
| */ | |||
| public Map<String, Class<?>> getNestedElementMap() { | |||
| return nestedTypes.isEmpty() | |||
| ? Collections.<String, Class<?>> emptyMap() : Collections.unmodifiableMap(nestedTypes); | |||
| ? Collections.emptyMap() : Collections.unmodifiableMap(nestedTypes); | |||
| } | |||
| /** | |||
| @@ -1002,7 +997,7 @@ public final class IntrospectionHelper { | |||
| */ | |||
| public List<Method> getExtensionPoints() { | |||
| return addTypeMethods.isEmpty() | |||
| ? Collections.<Method> emptyList() : Collections.unmodifiableList(addTypeMethods); | |||
| ? Collections.emptyList() : Collections.unmodifiableList(addTypeMethods); | |||
| } | |||
| /** | |||
| @@ -1078,7 +1073,7 @@ public final class IntrospectionHelper { | |||
| throw new BuildException("The value \"\" is not a " | |||
| + "legal value for attribute \"" + attrName + "\""); | |||
| } | |||
| m.invoke(parent, (Object[]) new Character[] {new Character(value.charAt(0))}); | |||
| m.invoke(parent, (Object[]) new Character[] {value.charAt(0)}); | |||
| } | |||
| }; | |||
| } | |||
| @@ -1100,7 +1095,7 @@ public final class IntrospectionHelper { | |||
| public void set(final Project p, final Object parent, final String value) | |||
| throws InvocationTargetException, IllegalAccessException, BuildException { | |||
| try { | |||
| m.invoke(parent, new Object[] {Class.forName(value)}); | |||
| m.invoke(parent, Class.forName(value)); | |||
| } catch (final ClassNotFoundException ce) { | |||
| throw new BuildException(ce); | |||
| } | |||
| @@ -1113,7 +1108,7 @@ public final class IntrospectionHelper { | |||
| @Override | |||
| public void set(final Project p, final Object parent, final String value) | |||
| throws InvocationTargetException, IllegalAccessException { | |||
| m.invoke(parent, new Object[] {p.resolveFile(value)}); | |||
| m.invoke(parent, p.resolveFile(value)); | |||
| } | |||
| }; | |||
| } | |||
| @@ -1122,7 +1117,7 @@ public final class IntrospectionHelper { | |||
| return new AttributeSetter(m, arg) { | |||
| @Override | |||
| public void set(final Project p, final Object parent, final String value) throws InvocationTargetException, IllegalAccessException { | |||
| m.invoke(parent, new Object[] { p.resolveFile(value).toPath() }); | |||
| m.invoke(parent, p.resolveFile(value).toPath()); | |||
| } | |||
| }; | |||
| } | |||
| @@ -1133,7 +1128,7 @@ public final class IntrospectionHelper { | |||
| @Override | |||
| void set(final Project p, final Object parent, final String value) throws InvocationTargetException, | |||
| IllegalAccessException, BuildException { | |||
| m.invoke(parent, new Object[] {new FileResource(p, p.resolveFile(value))}); | |||
| m.invoke(parent, new FileResource(p, p.resolveFile(value))); | |||
| } | |||
| }; | |||
| } | |||
| @@ -1146,7 +1141,7 @@ public final class IntrospectionHelper { | |||
| try { | |||
| final EnumeratedAttribute ea = (EnumeratedAttribute) reflectedArg.newInstance(); | |||
| ea.setValue(value); | |||
| m.invoke(parent, new Object[] {ea}); | |||
| m.invoke(parent, ea); | |||
| } catch (final InstantiationException ie) { | |||
| throw new BuildException(ie); | |||
| } | |||
| @@ -1165,8 +1160,7 @@ public final class IntrospectionHelper { | |||
| public void set(final Project p, final Object parent, final String value) | |||
| throws InvocationTargetException, IllegalAccessException, BuildException { | |||
| try { | |||
| m.invoke(parent, new Object[] { | |||
| new Long(StringUtils.parseHumanSizes(value)) }); | |||
| m.invoke(parent, StringUtils.parseHumanSizes(value)); | |||
| } catch (final NumberFormatException e) { | |||
| throw new BuildException("Can't assign non-numeric" | |||
| + " value '" + value + "' to" | |||
| @@ -1216,7 +1210,7 @@ public final class IntrospectionHelper { | |||
| if (p != null) { | |||
| p.setProjectReference(attribute); | |||
| } | |||
| m.invoke(parent, new Object[] {attribute}); | |||
| m.invoke(parent, attribute); | |||
| } catch (final InvocationTargetException e) { | |||
| final Throwable cause = e.getCause(); | |||
| if (cause instanceof IllegalArgumentException) { | |||
| @@ -1434,7 +1428,7 @@ public final class IntrospectionHelper { | |||
| @Override | |||
| Object create(final Project project, final Object parent, final Object ignore) | |||
| throws InvocationTargetException, IllegalAccessException { | |||
| return getMethod().invoke(parent, new Object[] {}); | |||
| return getMethod().invoke(parent); | |||
| } | |||
| } | |||
| @@ -1485,7 +1479,7 @@ public final class IntrospectionHelper { | |||
| private void istore(final Object parent, final Object child) | |||
| throws InvocationTargetException, IllegalAccessException, InstantiationException { | |||
| getMethod().invoke(parent, new Object[] {child}); | |||
| getMethod().invoke(parent, child); | |||
| } | |||
| } | |||
| @@ -1514,7 +1508,7 @@ public final class IntrospectionHelper { | |||
| useType = PRIMITIVE_TYPE_MAP.get(type); | |||
| } | |||
| if (value == null || useType.isInstance(value)) { | |||
| method.invoke(parent, new Object[] {value}); | |||
| method.invoke(parent, value); | |||
| return; | |||
| } | |||
| } | |||
| @@ -1578,7 +1572,7 @@ public final class IntrospectionHelper { | |||
| Object create(final Project project, final Object parent, final Object ignore) | |||
| throws InvocationTargetException, IllegalAccessException { | |||
| if (!getMethod().getName().endsWith("Configured")) { | |||
| getMethod().invoke(parent, new Object[] {realObject}); | |||
| getMethod().invoke(parent, realObject); | |||
| } | |||
| return nestedObject; | |||
| } | |||
| @@ -1592,7 +1586,7 @@ public final class IntrospectionHelper { | |||
| void store(final Object parent, final Object child) throws InvocationTargetException, | |||
| IllegalAccessException, InstantiationException { | |||
| if (getMethod().getName().endsWith("Configured")) { | |||
| getMethod().invoke(parent, new Object[] {realObject}); | |||
| getMethod().invoke(parent, realObject); | |||
| } | |||
| } | |||
| }; | |||
| @@ -632,8 +632,8 @@ public class Main implements AntMain { | |||
| + args[pos]); | |||
| } | |||
| if (threadPriority.intValue() < Thread.MIN_PRIORITY | |||
| || threadPriority.intValue() > Thread.MAX_PRIORITY) { | |||
| if (threadPriority < Thread.MIN_PRIORITY | |||
| || threadPriority > Thread.MAX_PRIORITY) { | |||
| throw new BuildException( | |||
| "Niceness value is out of the range 1-10"); | |||
| } | |||
| @@ -798,7 +798,7 @@ public class Main implements AntMain { | |||
| try { | |||
| project.log("Setting Ant's thread priority to " | |||
| + threadPriority, Project.MSG_VERBOSE); | |||
| Thread.currentThread().setPriority(threadPriority.intValue()); | |||
| Thread.currentThread().setPriority(threadPriority); | |||
| } catch (final SecurityException swallowed) { | |||
| //we cannot set the priority here. | |||
| project.log("A security manager refused to set the -nice value"); | |||
| @@ -941,7 +941,7 @@ public class Main implements AntMain { | |||
| for (int i = 0; i < count; i++) { | |||
| final String className = listeners.elementAt(i); | |||
| final BuildListener listener = | |||
| (BuildListener) ClasspathUtils.newInstance(className, | |||
| ClasspathUtils.newInstance(className, | |||
| Main.class.getClassLoader(), BuildListener.class); | |||
| project.setProjectReference(listener); | |||
| @@ -962,7 +962,7 @@ public class Main implements AntMain { | |||
| if (inputHandlerClassname == null) { | |||
| handler = new DefaultInputHandler(); | |||
| } else { | |||
| handler = (InputHandler) ClasspathUtils.newInstance( | |||
| handler = ClasspathUtils.newInstance( | |||
| inputHandlerClassname, Main.class.getClassLoader(), | |||
| InputHandler.class); | |||
| project.setProjectReference(handler); | |||
| @@ -984,7 +984,7 @@ public class Main implements AntMain { | |||
| emacsMode = true; | |||
| } else if (loggerClassname != null) { | |||
| try { | |||
| logger = (BuildLogger) ClasspathUtils.newInstance( | |||
| logger = ClasspathUtils.newInstance( | |||
| loggerClassname, Main.class.getClassLoader(), | |||
| BuildLogger.class); | |||
| } catch (final BuildException e) { | |||
| @@ -1088,13 +1088,10 @@ public class Main implements AntMain { | |||
| props.load(in); | |||
| in.close(); | |||
| shortAntVersion = props.getProperty("VERSION"); | |||
| final StringBuffer msg = new StringBuffer(); | |||
| msg.append("Apache Ant(TM) version "); | |||
| msg.append(shortAntVersion); | |||
| msg.append(" compiled on "); | |||
| msg.append(props.getProperty("DATE")); | |||
| antVersion = msg.toString(); | |||
| antVersion = "Apache Ant(TM) version " + | |||
| shortAntVersion + | |||
| " compiled on " + | |||
| props.getProperty("DATE"); | |||
| } catch (final IOException ioe) { | |||
| throw new BuildException("Could not load the version information:" | |||
| + ioe.getMessage()); | |||
| @@ -439,9 +439,7 @@ public class Project implements ResourceFactory { | |||
| public Vector<BuildListener> getBuildListeners() { | |||
| synchronized (listenersLock) { | |||
| final Vector<BuildListener> r = new Vector<>(listeners.length); | |||
| for (BuildListener listener : listeners) { | |||
| r.add(listener); | |||
| } | |||
| Collections.addAll(r, listeners); | |||
| return r; | |||
| } | |||
| } | |||
| @@ -264,7 +264,7 @@ public class ProjectHelper { | |||
| * @since Ant 1.8.0 | |||
| */ | |||
| public static void setInIncludeMode(boolean includeMode) { | |||
| inIncludeMode.set(Boolean.valueOf(includeMode)); | |||
| inIncludeMode.set(includeMode); | |||
| } | |||
| // -------------------- Parse method -------------------- | |||
| @@ -381,8 +381,7 @@ public class PropertyHelper implements GetProperty { | |||
| public static synchronized PropertyHelper getPropertyHelper(Project project) { | |||
| PropertyHelper helper = null; | |||
| if (project != null) { | |||
| helper = (PropertyHelper) project.getReference(MagicNames | |||
| .REFID_PROPERTY_HELPER); | |||
| helper = project.getReference(MagicNames.REFID_PROPERTY_HELPER); | |||
| } | |||
| if (helper != null) { | |||
| return helper; | |||
| @@ -440,11 +439,8 @@ public class PropertyHelper implements GetProperty { | |||
| boolean inherited, boolean user, | |||
| boolean isNew) { | |||
| if (getNext() != null) { | |||
| boolean subst = getNext().setPropertyHook(ns, name, value, inherited, user, isNew); | |||
| // If next has handled the property | |||
| if (subst) { | |||
| return true; | |||
| } | |||
| return getNext().setPropertyHook(ns, name, value, inherited, user, isNew); | |||
| } | |||
| return false; | |||
| } | |||
| @@ -1118,7 +1114,7 @@ public class PropertyHelper implements GetProperty { | |||
| protected <D extends Delegate> List<D> getDelegates(Class<D> type) { | |||
| @SuppressWarnings("unchecked") | |||
| final List<D> result = (List<D>) delegates.get(type); | |||
| return result == null ? Collections.<D> emptyList() : result; | |||
| return result == null ? Collections.emptyList() : result; | |||
| } | |||
| /** | |||
| @@ -1193,7 +1189,7 @@ public class PropertyHelper implements GetProperty { | |||
| private boolean evalAsBooleanOrPropertyName(Object value) { | |||
| Boolean b = toBoolean(value); | |||
| if (b != null) { | |||
| return b.booleanValue(); | |||
| return b; | |||
| } | |||
| return getProperty(String.valueOf(value)) != null; | |||
| } | |||
| @@ -503,8 +503,7 @@ public class UnknownElement extends Task { | |||
| * @return the name to use in logging messages. | |||
| */ | |||
| public String getTaskName() { | |||
| return realThing == null | |||
| || !(realThing instanceof Task) ? super.getTaskName() | |||
| return !(realThing instanceof Task) ? super.getTaskName() | |||
| : ((Task) realThing).getTaskName(); | |||
| } | |||
| @@ -643,7 +642,7 @@ public class UnknownElement extends Task { | |||
| } | |||
| for (int i = 0; i < childrenSize; ++i) { | |||
| // children cannot be null childrenSize would have been 0 | |||
| UnknownElement child = (UnknownElement) children.get(i); //NOSONAR | |||
| UnknownElement child = children.get(i); //NOSONAR | |||
| if (!child.similar(other.children.get(i))) { | |||
| return false; | |||
| } | |||
| @@ -58,7 +58,7 @@ public abstract class BaseIfAttribute | |||
| * @return val if positive or !val if not. | |||
| */ | |||
| protected boolean convertResult(boolean val) { | |||
| return positive ? val : !val; | |||
| return positive == val; | |||
| } | |||
| /** | |||
| @@ -43,9 +43,8 @@ public class DispatchUtils { | |||
| } else if (task instanceof UnknownElement) { | |||
| UnknownElement ue = (UnknownElement) task; | |||
| Object realThing = ue.getRealThing(); | |||
| if (realThing != null | |||
| && realThing instanceof Dispatchable | |||
| && realThing instanceof Task) { | |||
| if (realThing instanceof Dispatchable | |||
| && realThing instanceof Task) { | |||
| dispatchable = (Dispatchable) realThing; | |||
| } | |||
| } | |||
| @@ -59,7 +58,7 @@ public class DispatchUtils { | |||
| mName += name.substring(1); | |||
| } | |||
| final Class<? extends Dispatchable> c = dispatchable.getClass(); | |||
| final Method actionM = c.getMethod(mName, new Class[0]); | |||
| final Method actionM = c.getMethod(mName); | |||
| if (actionM != null) { | |||
| final Object o = actionM.invoke(dispatchable, (Object[]) null); | |||
| if (o != null) { | |||
| @@ -68,7 +67,7 @@ public class DispatchUtils { | |||
| methodName = s.trim(); | |||
| Method executeM = null; | |||
| executeM = dispatchable.getClass().getMethod( | |||
| methodName, new Class[0]); | |||
| methodName); | |||
| if (executeM == null) { | |||
| throw new BuildException( | |||
| "No public " + methodName + "() in " | |||
| @@ -273,8 +273,8 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina | |||
| in = new MaskJavaTabLiteralsFilter(in); | |||
| } | |||
| // Add/Remove tabs | |||
| in = (tabs == AddAsisRemove.ADD) ? (Reader) new AddTabFilter(in, getTablength()) | |||
| : (Reader) new RemoveTabFilter(in, getTablength()); | |||
| in = (tabs == AddAsisRemove.ADD) ? new AddTabFilter(in, getTablength()) | |||
| : new RemoveTabFilter(in, getTablength()); | |||
| } | |||
| // Add missing EOF character | |||
| in = (ctrlz == AddAsisRemove.ADD) ? new AddEofFilter(in) : in; | |||
| @@ -117,7 +117,7 @@ public final class LineContains | |||
| for (line = readLine(); line != null; line = readLine()) { | |||
| boolean matches = true; | |||
| for (int i = 0; matches && i < containsSize; i++) { | |||
| String containsStr = (String) contains.elementAt(i); | |||
| String containsStr = contains.elementAt(i); | |||
| matches = line.contains(containsStr); | |||
| } | |||
| if (matches ^ isNegated()) { | |||
| @@ -116,15 +116,13 @@ public final class LineContainsRegExp | |||
| line = line.substring(1); | |||
| } | |||
| } else { | |||
| final int regexpsSize = regexps.size(); | |||
| for (line = readLine(); line != null; line = readLine()) { | |||
| boolean matches = true; | |||
| for (int i = 0; matches && i < regexpsSize; i++) { | |||
| RegularExpression regexp | |||
| = (RegularExpression) regexps.elementAt(i); | |||
| Regexp re = regexp.getRegexp(getProject()); | |||
| matches = re.matches(line, regexpOptions); | |||
| for (RegularExpression regexp : regexps) { | |||
| if (!regexp.getRegexp(getProject()).matches(line, regexpOptions)) { | |||
| matches = false; | |||
| break; | |||
| } | |||
| } | |||
| if (matches ^ isNegated()) { | |||
| break; | |||
| @@ -222,7 +222,7 @@ public final class SortFilter extends BaseParamFilterReader | |||
| } | |||
| if (iterator.hasNext()) { | |||
| line = (String) iterator.next(); | |||
| line = iterator.next(); | |||
| } else { | |||
| line = null; | |||
| lines = null; | |||
| @@ -317,12 +317,12 @@ public final class SortFilter extends BaseParamFilterReader | |||
| for (Parameter param : params) { | |||
| final String paramName = param.getName(); | |||
| if (REVERSE_KEY.equals(paramName)) { | |||
| setReverse(Boolean.valueOf(param.getValue()).booleanValue()); | |||
| setReverse(Boolean.valueOf(param.getValue())); | |||
| continue; | |||
| } | |||
| if (COMPARATOR_KEY.equals(paramName)) { | |||
| try { | |||
| String className = (String) param.getValue(); | |||
| String className = param.getValue(); | |||
| @SuppressWarnings("unchecked") | |||
| final Comparator<? super String> comparatorInstance | |||
| = (Comparator<? super String>) (Class.forName(className).newInstance()); | |||
| @@ -217,7 +217,7 @@ public class AntXMLContext { | |||
| if (wStack.size() < 1) { | |||
| return null; | |||
| } | |||
| return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1); | |||
| return wStack.elementAt(wStack.size() - 1); | |||
| } | |||
| /** | |||
| @@ -229,7 +229,7 @@ public class AntXMLContext { | |||
| if (wStack.size() < 2) { | |||
| return null; | |||
| } | |||
| return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2); | |||
| return wStack.elementAt(wStack.size() - 2); | |||
| } | |||
| /** | |||
| @@ -394,7 +394,7 @@ public class AntXMLContext { | |||
| if (list == null || list.isEmpty()) { | |||
| return null; | |||
| } | |||
| return (String) list.get(list.size() - 1); | |||
| return list.get(list.size() - 1); | |||
| } | |||
| /** | |||
| @@ -149,7 +149,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
| public void parse(Project project, Object source) throws BuildException { | |||
| getImportStack().addElement(source); | |||
| AntXMLContext context = null; | |||
| context = (AntXMLContext) project.getReference(REFID_CONTEXT); | |||
| context = project.getReference(REFID_CONTEXT); | |||
| if (context == null) { | |||
| context = new AntXMLContext(project); | |||
| project.addReference(REFID_CONTEXT, context); | |||
| @@ -1020,8 +1020,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||
| } | |||
| if (extensionPoint != null) { | |||
| ProjectHelper helper = | |||
| (ProjectHelper) context.getProject(). | |||
| getReference(ProjectHelper.PROJECTHELPER_REFERENCE); | |||
| context.getProject().getReference(ProjectHelper.PROJECTHELPER_REFERENCE); | |||
| for (String extPointName : Target.parseDepends(extensionPoint, name, "extensionOf")) { | |||
| if (extensionPointMissing == null) { | |||
| extensionPointMissing = OnMissingExtensionPoint.FAIL; | |||
| @@ -44,9 +44,9 @@ public class SecureInputHandler extends DefaultInputHandler { | |||
| try { | |||
| Object console = ReflectUtil.invokeStatic(System.class, "console"); | |||
| do { | |||
| char[] input = (char[]) ReflectUtil.invoke( | |||
| char[] input = ReflectUtil.invoke( | |||
| console, "readPassword", String.class, prompt, | |||
| Object[].class, (Object[]) null); | |||
| Object[].class, null); | |||
| request.setInput(new String(input)); | |||
| /* for security zero char array after retrieving value */ | |||
| java.util.Arrays.fill(input, ' '); | |||
| @@ -66,14 +66,13 @@ public class BindTargets extends Task { | |||
| if (getOwningTarget() == null | |||
| || !"".equals(getOwningTarget().getName())) { | |||
| throw new BuildException( | |||
| "bindtargets only allowed as a top-level task"); | |||
| throw new BuildException("bindtargets only allowed as a top-level task"); | |||
| } | |||
| if (onMissingExtensionPoint == null) { | |||
| onMissingExtensionPoint = OnMissingExtensionPoint.FAIL; | |||
| } | |||
| final ProjectHelper helper = (ProjectHelper) getProject().getReference( | |||
| final ProjectHelper helper = getProject().getReference( | |||
| ProjectHelper.PROJECTHELPER_REFERENCE); | |||
| for (String target : targets) { | |||
| @@ -355,9 +355,7 @@ public class Concat extends Task implements ResourceCollection { | |||
| * add a character to the lastchars buffer | |||
| */ | |||
| private void addLastChar(char ch) { | |||
| for (int i = lastChars.length - 2; i >= 0; --i) { | |||
| lastChars[i] = lastChars[i + 1]; | |||
| } | |||
| System.arraycopy(lastChars, 1, lastChars, 0, lastChars.length - 2 + 1); | |||
| lastChars[lastChars.length - 1] = ch; | |||
| } | |||
| @@ -40,7 +40,6 @@ import org.apache.tools.ant.types.FilterSetCollection; | |||
| import org.apache.tools.ant.types.Mapper; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.ResourceFactory; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.util.FileNameMapper; | |||
| @@ -827,10 +826,8 @@ public class Copy extends Task { | |||
| } | |||
| toCopy = v.toArray(new Resource[v.size()]); | |||
| } else { | |||
| toCopy = ResourceUtils.selectOutOfDateSources(this, fromResources, | |||
| mapper, | |||
| (ResourceFactory) name -> new FileResource(toDir, name), | |||
| granularity); | |||
| toCopy = ResourceUtils.selectOutOfDateSources(this, fromResources, mapper, | |||
| name -> new FileResource(toDir, name), granularity); | |||
| } | |||
| for (Resource rc : toCopy) { | |||
| final String[] mappedFiles = mapper.mapFileName(rc.getName()); | |||
| @@ -180,7 +180,7 @@ public class CopyPath extends Task { | |||
| for (String sourceFileName : sourceFiles) { | |||
| File sourceFile = new File(sourceFileName); | |||
| String[] toFiles = (String[]) mapper.mapFileName(sourceFileName); | |||
| String[] toFiles = mapper.mapFileName(sourceFileName); | |||
| if (toFiles == null) { | |||
| continue; | |||
| } | |||
| @@ -19,7 +19,6 @@ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Task; | |||
| @@ -125,7 +125,7 @@ public class ExecTask extends Task { | |||
| */ | |||
| public void setTimeout(Integer value) { | |||
| setTimeout( | |||
| (value == null) ? null : Long.valueOf(value.intValue())); | |||
| (value == null) ? null : (long) value); | |||
| } | |||
| /** | |||
| @@ -699,7 +699,7 @@ public class ExecTask extends Task { | |||
| */ | |||
| protected ExecuteWatchdog createWatchdog() throws BuildException { | |||
| return (timeout == null) | |||
| ? null : new ExecuteWatchdog(timeout.longValue()); | |||
| ? null : new ExecuteWatchdog(timeout); | |||
| } | |||
| /** | |||
| @@ -135,30 +135,30 @@ public class Execute { | |||
| procEnvironment = getVMSLogicals(in); | |||
| return procEnvironment; | |||
| } | |||
| String var = null; | |||
| StringBuilder var = null; | |||
| String line, lineSep = StringUtils.LINE_SEP; | |||
| while ((line = in.readLine()) != null) { | |||
| if (line.indexOf('=') == -1) { | |||
| // Chunk part of previous env var (UNIX env vars can | |||
| // contain embedded new lines). | |||
| if (var == null) { | |||
| var = lineSep + line; | |||
| var = new StringBuilder(lineSep + line); | |||
| } else { | |||
| var += lineSep + line; | |||
| var.append(lineSep).append(line); | |||
| } | |||
| } else { | |||
| // New env var...append the previous one if we have it. | |||
| if (var != null) { | |||
| int eq = var.indexOf('='); | |||
| int eq = var.toString().indexOf('='); | |||
| procEnvironment.put(var.substring(0, eq), | |||
| var.substring(eq + 1)); | |||
| } | |||
| var = line; | |||
| var = new StringBuilder(line); | |||
| } | |||
| } | |||
| // Since we "look ahead" before adding, there's one last env var. | |||
| if (var != null) { | |||
| int eq = var.indexOf('='); | |||
| int eq = var.toString().indexOf('='); | |||
| procEnvironment.put(var.substring(0, eq), var.substring(eq + 1)); | |||
| } | |||
| } catch (IOException exc) { | |||
| @@ -142,7 +142,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||
| "Could not find %s. Make sure you have it in your classpath", | |||
| classname); | |||
| } | |||
| main = target.getMethod("main", new Class[] {String[].class}); | |||
| main = target.getMethod("main", String[].class); | |||
| if (main == null) { | |||
| throw new BuildException("Could not find main() method in %s", | |||
| classname); | |||
| @@ -164,7 +164,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||
| // main thread will still be there to let the new thread | |||
| // finish | |||
| thread.setDaemon(true); | |||
| Watchdog w = new Watchdog(timeout.longValue()); | |||
| Watchdog w = new Watchdog(timeout); | |||
| w.addTimeoutObserver(this); | |||
| synchronized (this) { | |||
| thread.start(); | |||
| @@ -289,7 +289,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||
| = new Execute(redirector.createHandler(), | |||
| timeout == null | |||
| ? null | |||
| : new ExecuteWatchdog(timeout.longValue())); | |||
| : new ExecuteWatchdog(timeout)); | |||
| exe.setAntRun(pc.getProject()); | |||
| if (Os.isFamily("openvms")) { | |||
| setupCommandLineForVMS(exe, cmdl.getCommandline()); | |||
| @@ -117,7 +117,7 @@ public class Exit extends Task { | |||
| * @param i the <code>int</code> status | |||
| */ | |||
| public void setStatus(int i) { | |||
| status = Integer.valueOf(i); | |||
| status = i; | |||
| } | |||
| /** | |||
| @@ -162,7 +162,7 @@ public class Exit extends Task { | |||
| } | |||
| log("failing due to " + text, Project.MSG_DEBUG); | |||
| throw status == null ? new BuildException(text) | |||
| : new ExitStatusException(text, status.intValue()); | |||
| : new ExitStatusException(text, status); | |||
| } | |||
| } | |||
| @@ -297,9 +297,7 @@ public class ImportTask extends Task { | |||
| } | |||
| if (importedURL != null) { | |||
| URLProvider up = ((Resource) o).as(URLProvider.class); | |||
| if (up != null && up.getURL().equals(importedURL)) { | |||
| return true; | |||
| } | |||
| return up != null && up.getURL().equals(importedURL); | |||
| } | |||
| } | |||
| return false; | |||
| @@ -987,7 +987,7 @@ public class Java extends Task { | |||
| if (timeout == null) { | |||
| return null; | |||
| } | |||
| return new ExecuteWatchdog(timeout.longValue()); | |||
| return new ExecuteWatchdog(timeout); | |||
| } | |||
| /** | |||
| @@ -826,7 +826,7 @@ public class Javac extends MatchingTask { | |||
| * @param include if true, includes Ant's own classpath in the classpath | |||
| */ | |||
| public void setIncludeantruntime(final boolean include) { | |||
| includeAntRuntime = Boolean.valueOf(include); | |||
| includeAntRuntime = include; | |||
| } | |||
| /** | |||
| @@ -834,7 +834,7 @@ public class Javac extends MatchingTask { | |||
| * @return whether or not the ant classpath is to be included in the classpath | |||
| */ | |||
| public boolean getIncludeantruntime() { | |||
| return includeAntRuntime != null ? includeAntRuntime.booleanValue() : true; | |||
| return includeAntRuntime != null ? includeAntRuntime : true; | |||
| } | |||
| /** | |||
| @@ -1459,7 +1459,7 @@ public class Javac extends MatchingTask { | |||
| continue; | |||
| } | |||
| final String pkg = path.substring(0, path.length() - suffix.length()); | |||
| packageInfos.put(pkg, Long.valueOf(f.lastModified())); | |||
| packageInfos.put(pkg, f.lastModified()); | |||
| } | |||
| } | |||
| @@ -1475,7 +1475,7 @@ public class Javac extends MatchingTask { | |||
| final File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar)); | |||
| pkgBinDir.mkdirs(); | |||
| final File pkgInfoClass = new File(pkgBinDir, "package-info.class"); | |||
| if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod.longValue()) { | |||
| if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod) { | |||
| continue; | |||
| } | |||
| log("Creating empty " + pkgInfoClass); | |||
| @@ -108,7 +108,7 @@ public class Length extends Task implements Condition { | |||
| * @param ell the long length to compare with. | |||
| */ | |||
| public synchronized void setLength(long ell) { | |||
| length = Long.valueOf(ell); | |||
| length = ell; | |||
| } | |||
| /** | |||
| @@ -152,7 +152,7 @@ public class Length extends Task implements Condition { | |||
| * @param trim <code>boolean</code>. | |||
| */ | |||
| public synchronized void setTrim(boolean trim) { | |||
| this.trim = Boolean.valueOf(trim); | |||
| this.trim = trim; | |||
| } | |||
| /** | |||
| @@ -201,11 +201,11 @@ public class Length extends Task implements Condition { | |||
| } | |||
| Long ell; | |||
| if (STRING.equals(mode)) { | |||
| ell = Long.valueOf(getLength(string, getTrim())); | |||
| ell = getLength(string, getTrim()); | |||
| } else { | |||
| AccumHandler h = new AccumHandler(); | |||
| handleResources(h); | |||
| ell = Long.valueOf(h.getAccum()); | |||
| ell = h.getAccum(); | |||
| } | |||
| return when.evaluate(ell.compareTo(length)); | |||
| } | |||
| @@ -427,14 +427,8 @@ public class MacroDef extends AntlibDefinition { | |||
| } else if (!name.equals(other.name)) { | |||
| return false; | |||
| } | |||
| if (defaultValue == null) { | |||
| if (other.defaultValue != null) { | |||
| return false; | |||
| } | |||
| } else if (!defaultValue.equals(other.defaultValue)) { | |||
| return false; | |||
| } | |||
| return true; | |||
| return defaultValue == null ? other.defaultValue == null | |||
| : defaultValue.equals(other.defaultValue); | |||
| } | |||
| /** | |||
| @@ -62,9 +62,9 @@ public class Nice extends Task { | |||
| getProject().setNewProperty(currentPriority, current); | |||
| } | |||
| //if there is a new priority, and it is different, change it | |||
| if (newPriority != null && priority != newPriority.intValue()) { | |||
| if (newPriority != null && priority != newPriority) { | |||
| try { | |||
| self.setPriority(newPriority.intValue()); | |||
| self.setPriority(newPriority); | |||
| } catch (SecurityException e) { | |||
| //catch permissions denial and keep going | |||
| log("Unable to set new priority -a security manager is in the way", | |||
| @@ -92,7 +92,7 @@ public class Nice extends Task { | |||
| if (newPriority < Thread.MIN_PRIORITY || newPriority > Thread.MAX_PRIORITY) { | |||
| throw new BuildException("The thread priority is out of the range 1-10"); | |||
| } | |||
| this.newPriority = Integer.valueOf(newPriority); | |||
| this.newPriority = newPriority; | |||
| } | |||
| } | |||
| @@ -356,7 +356,7 @@ public class PathConvert extends Task { | |||
| StringBuilder rslt = new StringBuilder(); | |||
| ResourceCollection resources = isPreserveDuplicates() ? (ResourceCollection) path : new Union(path); | |||
| ResourceCollection resources = isPreserveDuplicates() ? path : new Union(path); | |||
| List<String> ret = new ArrayList<>(); | |||
| FileNameMapper mapperImpl = mapper == null ? new IdentityMapper() : mapper.getImplementation(); | |||
| for (Resource r : resources) { | |||
| @@ -157,7 +157,7 @@ public class Recorder extends Task implements SubBuildListener { | |||
| recorder.setMessageOutputLevel(loglevel); | |||
| recorder.setEmacsMode(emacsMode); | |||
| if (start != null) { | |||
| if (start.booleanValue()) { | |||
| if (start) { | |||
| recorder.reopenFile(); | |||
| recorder.setRecordState(start); | |||
| } else { | |||
| @@ -214,7 +214,7 @@ public class Recorder extends Task implements SubBuildListener { | |||
| if (append == null) { | |||
| entry.openFile(false); | |||
| } else { | |||
| entry.openFile(append.booleanValue()); | |||
| entry.openFile(append); | |||
| } | |||
| entry.setProject(proj); | |||
| recorderEntries.put(name, entry); | |||
| @@ -85,7 +85,7 @@ public class RecorderEntry implements BuildLogger, SubBuildListener { | |||
| public void setRecordState(Boolean state) { | |||
| if (state != null) { | |||
| flush(); | |||
| record = state.booleanValue(); | |||
| record = state; | |||
| } | |||
| } | |||
| @@ -708,9 +708,8 @@ public class Redirector { | |||
| /** outStreams */ | |||
| private void outStreams() { | |||
| if (out != null && out.length > 0) { | |||
| final String logHead = new StringBuffer("Output ").append( | |||
| ((appendOut) ? "appended" : "redirected")).append(" to ") | |||
| .toString(); | |||
| final String logHead = "Output " + | |||
| ((appendOut) ? "appended" : "redirected") + " to "; | |||
| outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE, | |||
| appendOut, createEmptyFilesOut); | |||
| } | |||
| @@ -731,9 +730,8 @@ public class Redirector { | |||
| private void errorStreams() { | |||
| if (error != null && error.length > 0) { | |||
| final String logHead = new StringBuffer("Error ").append( | |||
| ((appendErr) ? "appended" : "redirected")).append(" to ") | |||
| .toString(); | |||
| final String logHead = "Error " + | |||
| ((appendErr) ? "appended" : "redirected") + " to "; | |||
| errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE, | |||
| appendErr, createEmptyFilesErr); | |||
| } else if (!(logError || outputStream == null) && errorProperty == null) { | |||
| @@ -103,7 +103,7 @@ public class ResourceCount extends Task implements Condition { | |||
| * @param c number of Resources as int. | |||
| */ | |||
| public void setCount(int c) { | |||
| count = Integer.valueOf(c); | |||
| count = c; | |||
| } | |||
| /** | |||
| @@ -91,13 +91,9 @@ public class Retry extends Task implements TaskContainer { | |||
| } catch (Exception e) { | |||
| errorMessages.append(e.getMessage()); | |||
| if (i >= retryCount) { | |||
| StringBuilder exceptionMessage = new StringBuilder(); | |||
| exceptionMessage.append("Task [").append(nestedTask.getTaskName()); | |||
| exceptionMessage.append("] failed after [").append(retryCount); | |||
| exceptionMessage.append("] attempts; giving up.").append(StringUtils.LINE_SEP); | |||
| exceptionMessage.append("Error messages:").append(StringUtils.LINE_SEP); | |||
| exceptionMessage.append(errorMessages); | |||
| throw new BuildException(exceptionMessage.toString(), getLocation()); | |||
| throw new BuildException(String.format( | |||
| "Task [%s] failed after [%d] attempts; giving up.%nError messages:%n%s", | |||
| nestedTask.getTaskName(), retryCount, errorMessages), getLocation()); | |||
| } | |||
| String msg; | |||
| if (retryDelay > 0) { | |||
| @@ -329,14 +329,7 @@ public class SubAnt extends Task { | |||
| if (t instanceof BuildException) { | |||
| return isHardError(t.getCause()); | |||
| } | |||
| if (t instanceof OutOfMemoryError) { | |||
| return true; | |||
| } | |||
| if (t instanceof ThreadDeath) { | |||
| return true; | |||
| } | |||
| // incl. t == null | |||
| return false; | |||
| return t instanceof OutOfMemoryError || t instanceof ThreadDeath; | |||
| } | |||
| /** | |||
| @@ -252,7 +252,7 @@ public class Sync extends Task { | |||
| } | |||
| Boolean ped = getExplicitPreserveEmptyDirs(); | |||
| if (ped != null && ped.booleanValue() != myCopy.getIncludeEmptyDirs()) { | |||
| if (ped != null && ped != myCopy.getIncludeEmptyDirs()) { | |||
| FileSet fs = syncTarget.toFileSet(true); | |||
| fs.setDir(toDir); | |||
| String[] preservedDirs = | |||
| @@ -554,7 +554,7 @@ public class Sync extends Task { | |||
| * @since Ant 1.8.0 | |||
| */ | |||
| public void setPreserveEmptyDirs(boolean b) { | |||
| preserveEmptyDirs = Boolean.valueOf(b); | |||
| preserveEmptyDirs = b; | |||
| } | |||
| /** | |||
| @@ -750,7 +750,7 @@ public class Tar extends MatchingTask { | |||
| */ | |||
| protected TarFileSet asTarFileSet(final ArchiveFileSet archiveFileSet) { | |||
| TarFileSet tfs; | |||
| if (archiveFileSet != null && archiveFileSet instanceof TarFileSet) { | |||
| if (archiveFileSet instanceof TarFileSet) { | |||
| tfs = (TarFileSet) archiveFileSet; | |||
| } else { | |||
| tfs = new TarFileSet(); | |||
| @@ -40,7 +40,7 @@ public class Truncate extends Task { | |||
| private static final int BUFFER_SIZE = 1024; | |||
| private static final Long ZERO = new Long(0L); | |||
| private static final Long ZERO = 0L; | |||
| private static final String NO_CHILD = "No files specified."; | |||
| @@ -91,7 +91,7 @@ public class Truncate extends Task { | |||
| */ | |||
| public void setLength(Long length) { | |||
| this.length = length; | |||
| if (length != null && length.longValue() < 0) { | |||
| if (length != null && length < 0) { | |||
| throw new BuildException(INVALID_LENGTH + length); | |||
| } | |||
| } | |||
| @@ -159,7 +159,7 @@ public class Truncate extends Task { | |||
| private void process(File f) { | |||
| long len = f.length(); | |||
| long newLength = length == null | |||
| ? len + adjust.longValue() : length.longValue(); | |||
| ? len + adjust : length; | |||
| if (len == newLength) { | |||
| //nothing to do! | |||
| @@ -342,14 +342,14 @@ public class Tstamp extends Task { | |||
| /** Constructor for Unit enumerated type. */ | |||
| public Unit() { | |||
| calendarFields.put(MILLISECOND, | |||
| Integer.valueOf(Calendar.MILLISECOND)); | |||
| calendarFields.put(SECOND, Integer.valueOf(Calendar.SECOND)); | |||
| calendarFields.put(MINUTE, Integer.valueOf(Calendar.MINUTE)); | |||
| calendarFields.put(HOUR, Integer.valueOf(Calendar.HOUR_OF_DAY)); | |||
| calendarFields.put(DAY, Integer.valueOf(Calendar.DATE)); | |||
| calendarFields.put(WEEK, Integer.valueOf(Calendar.WEEK_OF_YEAR)); | |||
| calendarFields.put(MONTH, Integer.valueOf(Calendar.MONTH)); | |||
| calendarFields.put(YEAR, Integer.valueOf(Calendar.YEAR)); | |||
| Calendar.MILLISECOND); | |||
| calendarFields.put(SECOND, Calendar.SECOND); | |||
| calendarFields.put(MINUTE, Calendar.MINUTE); | |||
| calendarFields.put(HOUR, Calendar.HOUR_OF_DAY); | |||
| calendarFields.put(DAY, Calendar.DATE); | |||
| calendarFields.put(WEEK, Calendar.WEEK_OF_YEAR); | |||
| calendarFields.put(MONTH, Calendar.MONTH); | |||
| calendarFields.put(YEAR, Calendar.YEAR); | |||
| } | |||
| /** | |||
| @@ -358,7 +358,7 @@ public class Tstamp extends Task { | |||
| */ | |||
| public int getCalendarField() { | |||
| String key = getValue().toLowerCase(Locale.ENGLISH); | |||
| return calendarFields.get(key).intValue(); | |||
| return calendarFields.get(key); | |||
| } | |||
| /** | |||
| @@ -244,12 +244,12 @@ public class WaitFor extends ConditionBase { | |||
| /** Constructor the Unit enumerated type. */ | |||
| public Unit() { | |||
| timeTable.put(MILLISECOND, Long.valueOf(1L)); | |||
| timeTable.put(SECOND, Long.valueOf(ONE_SECOND)); | |||
| timeTable.put(MINUTE, Long.valueOf(ONE_MINUTE)); | |||
| timeTable.put(HOUR, Long.valueOf(ONE_HOUR)); | |||
| timeTable.put(DAY, Long.valueOf(ONE_DAY)); | |||
| timeTable.put(WEEK, Long.valueOf(ONE_WEEK)); | |||
| timeTable.put(MILLISECOND, 1L); | |||
| timeTable.put(SECOND, ONE_SECOND); | |||
| timeTable.put(MINUTE, ONE_MINUTE); | |||
| timeTable.put(HOUR, ONE_HOUR); | |||
| timeTable.put(DAY, ONE_DAY); | |||
| timeTable.put(WEEK, ONE_WEEK); | |||
| } | |||
| /** | |||
| @@ -258,7 +258,7 @@ public class WaitFor extends ConditionBase { | |||
| */ | |||
| public long getMultiplier() { | |||
| String key = getValue().toLowerCase(Locale.ENGLISH); | |||
| return timeTable.get(key).longValue(); | |||
| return timeTable.get(key); | |||
| } | |||
| /** | |||
| @@ -363,10 +363,8 @@ public class XmlProperty extends Task { | |||
| String nodeName = attributeNode.getNodeName(); | |||
| String attributeValue = getAttributeValue(attributeNode); | |||
| Path containingPath = | |||
| ((container != null) && (container instanceof Path)) | |||
| ? (Path) container | |||
| : null; | |||
| Path containingPath = container instanceof Path | |||
| ? (Path) container : null; | |||
| /* | |||
| * The main conditional logic -- if the attribute | |||
| * is somehow "special" (i.e., it has known | |||
| @@ -1248,11 +1248,11 @@ public class Zip extends MatchingTask { | |||
| final File zipFile, | |||
| final boolean needsUpdate) | |||
| throws BuildException { | |||
| final List<ResourceCollection> filesets = new ArrayList<>(); | |||
| final List<FileSet> filesets = new ArrayList<>(); | |||
| final List<ResourceCollection> rest = new ArrayList<>(); | |||
| for (ResourceCollection rc : rcs) { | |||
| if (rc instanceof FileSet) { | |||
| filesets.add(rc); | |||
| filesets.add((FileSet) rc); | |||
| } else { | |||
| rest.add(rc); | |||
| } | |||
| @@ -1262,8 +1262,7 @@ public class Zip extends MatchingTask { | |||
| ArchiveState as = getNonFileSetResourcesToAdd(rc, zipFile, | |||
| needsUpdate); | |||
| final FileSet[] fs = filesets.toArray(new FileSet[filesets | |||
| .size()]); | |||
| final FileSet[] fs = filesets.toArray(new FileSet[filesets.size()]); | |||
| final ArchiveState as2 = getResourcesToAdd(fs, zipFile, as.isOutOfDate()); | |||
| if (!as.isOutOfDate() && as2.isOutOfDate()) { | |||
| /* | |||
| @@ -1498,7 +1497,7 @@ public class Zip extends MatchingTask { | |||
| final Resource[][] initialResources = grabNonFileSetResources(rcs); | |||
| final boolean empty = isEmpty(initialResources); | |||
| HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(Boolean.valueOf(!empty)); | |||
| HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(!empty); | |||
| if (empty) { | |||
| // no emptyBehavior handling since the FileSet version | |||
| // will take care of it. | |||
| @@ -55,16 +55,12 @@ public class Javac12 extends DefaultCompilerAdapter { | |||
| // Create an instance of the compiler, redirecting output to | |||
| // the project log | |||
| Class<?> c = Class.forName(CLASSIC_COMPILER_CLASSNAME); | |||
| Constructor cons = | |||
| c.getConstructor(OutputStream.class, String.class); | |||
| Object compiler | |||
| = cons.newInstance(logstr, "javac"); | |||
| Constructor cons = c.getConstructor(OutputStream.class, String.class); | |||
| Object compiler = cons.newInstance(logstr, "javac"); | |||
| // Call the compile() method | |||
| Method compile = c.getMethod("compile", String[].class); | |||
| Boolean ok = (Boolean) compile.invoke(compiler, | |||
| new Object[] {cmd.getArguments()}); | |||
| return ok.booleanValue(); | |||
| return (Boolean) compile.invoke(compiler, new Object[] {cmd.getArguments()}); | |||
| } catch (ClassNotFoundException ex) { | |||
| throw new BuildException("Cannot use classic compiler, as it is " | |||
| + "not available. \n" | |||
| @@ -54,8 +54,8 @@ public class Javac13 extends DefaultCompilerAdapter { | |||
| Class<?> c = Class.forName("com.sun.tools.javac.Main"); | |||
| Object compiler = c.newInstance(); | |||
| Method compile = c.getMethod("compile", String[].class); | |||
| int result = ((Integer) compile.invoke(compiler, | |||
| (Object) cmd.getArguments())).intValue(); | |||
| int result = (Integer) compile.invoke(compiler, | |||
| (Object) cmd.getArguments()); | |||
| return result == MODERN_COMPILER_SUCCESS; | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| @@ -49,7 +49,7 @@ public class HasFreeSpace implements Condition { | |||
| //reflection to avoid bootstrap/build problems | |||
| File fs = new File(partition); | |||
| ReflectWrapper w = new ReflectWrapper(fs); | |||
| long free = w.<Long> invoke("getFreeSpace").longValue(); | |||
| long free = w.<Long>invoke("getFreeSpace"); | |||
| return free >= StringUtils.parseHumanSizes(needed); | |||
| } | |||
| throw new BuildException( | |||
| @@ -113,10 +113,7 @@ public class Http extends ProjectComponent implements Condition { | |||
| int code = http.getResponseCode(); | |||
| log("Result code for " + spec + " was " + code, | |||
| Project.MSG_VERBOSE); | |||
| if (code > 0 && code < errorsBeginAt) { | |||
| return true; | |||
| } | |||
| return false; | |||
| return code > 0 && code < errorsBeginAt; | |||
| } | |||
| } catch (ProtocolException pe) { | |||
| throw new BuildException("Invalid HTTP protocol: " | |||
| @@ -48,7 +48,7 @@ public class IsFalse extends ProjectComponent implements Condition { | |||
| if (value == null) { | |||
| throw new BuildException("Nothing to test for falsehood"); | |||
| } | |||
| return !value.booleanValue(); | |||
| return !value; | |||
| } | |||
| } | |||
| @@ -179,8 +179,8 @@ public class IsReachable extends ProjectComponent implements Condition { | |||
| Method reachableMethod = | |||
| InetAddress.class.getMethod(METHOD_NAME, Integer.class); | |||
| try { | |||
| reachable = ((Boolean) reachableMethod.invoke(address, | |||
| Integer.valueOf(timeout * SECOND))).booleanValue(); | |||
| reachable = (Boolean) reachableMethod.invoke(address, | |||
| timeout * SECOND); | |||
| } catch (final IllegalAccessException e) { | |||
| //utterly implausible, but catered for anyway | |||
| throw new BuildException("When calling " + reachableMethod); | |||
| @@ -49,7 +49,7 @@ public class IsTrue extends ProjectComponent implements Condition { | |||
| if (value == null) { | |||
| throw new BuildException("Nothing to test for truth"); | |||
| } | |||
| return value.booleanValue(); | |||
| return value; | |||
| } | |||
| } | |||
| @@ -165,7 +165,7 @@ public class EmailTask extends Task { | |||
| * @param port The port to use. | |||
| */ | |||
| public void setMailport(int port) { | |||
| this.port = Integer.valueOf(port); | |||
| this.port = port; | |||
| } | |||
| /** | |||
| @@ -554,7 +554,7 @@ public class EmailTask extends Task { | |||
| // pass the params to the mailer | |||
| mailer.setHost(host); | |||
| if (port != null) { | |||
| mailer.setPort(port.intValue()); | |||
| mailer.setPort(port); | |||
| mailer.setPortExplicitlySpecified(true); | |||
| } else { | |||
| mailer.setPort(SMTP_PORT); | |||
| @@ -111,8 +111,8 @@ public class MimeMailer extends Mailer { | |||
| return type; | |||
| } | |||
| // Must be like "text/plain; charset=windows-1251" | |||
| return new StringBuilder(type != null ? type : "text/plain").append( | |||
| "; charset=").append(charset).toString(); | |||
| return (type != null ? type : "text/plain") + | |||
| "; charset=" + charset; | |||
| } | |||
| @Override | |||
| @@ -692,14 +692,14 @@ public class PropertyFile extends Task { | |||
| /** no arg constructor */ | |||
| public Unit() { | |||
| calendarFields.put(MILLISECOND, | |||
| Integer.valueOf(Calendar.MILLISECOND)); | |||
| calendarFields.put(SECOND, Integer.valueOf(Calendar.SECOND)); | |||
| calendarFields.put(MINUTE, Integer.valueOf(Calendar.MINUTE)); | |||
| calendarFields.put(HOUR, Integer.valueOf(Calendar.HOUR_OF_DAY)); | |||
| calendarFields.put(DAY, Integer.valueOf(Calendar.DATE)); | |||
| calendarFields.put(WEEK, Integer.valueOf(Calendar.WEEK_OF_YEAR)); | |||
| calendarFields.put(MONTH, Integer.valueOf(Calendar.MONTH)); | |||
| calendarFields.put(YEAR, Integer.valueOf(Calendar.YEAR)); | |||
| Calendar.MILLISECOND); | |||
| calendarFields.put(SECOND, Calendar.SECOND); | |||
| calendarFields.put(MINUTE, Calendar.MINUTE); | |||
| calendarFields.put(HOUR, Calendar.HOUR_OF_DAY); | |||
| calendarFields.put(DAY, Calendar.DATE); | |||
| calendarFields.put(WEEK, Calendar.WEEK_OF_YEAR); | |||
| calendarFields.put(MONTH, Calendar.MONTH); | |||
| calendarFields.put(YEAR, Calendar.YEAR); | |||
| } | |||
| /** | |||
| @@ -707,7 +707,7 @@ public class PropertyFile extends Task { | |||
| * @return the calendar value. | |||
| */ | |||
| public int getCalendarField() { | |||
| return calendarFields.get(getValue().toLowerCase()).intValue(); | |||
| return calendarFields.get(getValue().toLowerCase()); | |||
| } | |||
| /** {@inheritDoc}. */ | |||
| @@ -428,8 +428,7 @@ public class SchemaValidate extends XMLValidateTask { | |||
| */ | |||
| public String getURIandLocation() throws BuildException { | |||
| validateNamespace(); | |||
| return new StringBuilder(namespace).append(' ') | |||
| .append(getSchemaLocationURL()).toString(); | |||
| return namespace + ' ' + getSchemaLocationURL(); | |||
| } | |||
| /** | |||
| @@ -475,11 +474,7 @@ public class SchemaValidate extends XMLValidateTask { | |||
| : schemaLocation.namespace != null) { | |||
| return false; | |||
| } | |||
| if (url != null ? !url.equals(schemaLocation.url) : schemaLocation.url != null) { | |||
| return false; | |||
| } | |||
| return true; | |||
| return url != null ? url.equals(schemaLocation.url) : schemaLocation.url == null; | |||
| } | |||
| /** | |||
| @@ -504,12 +499,10 @@ public class SchemaValidate extends XMLValidateTask { | |||
| */ | |||
| @Override | |||
| public String toString() { | |||
| StringBuilder buffer = new StringBuilder(); | |||
| buffer.append(namespace != null ? namespace : "(anonymous)"); | |||
| buffer.append(' '); | |||
| buffer.append(url != null ? (url + " ") : ""); | |||
| buffer.append(file != null ? file.getAbsolutePath() : ""); | |||
| return buffer.toString(); | |||
| String buffer = (namespace != null ? namespace : "(anonymous)") | |||
| + ' ' + (url != null ? (url + " ") : "") | |||
| + (file != null ? file.getAbsolutePath() : ""); | |||
| return buffer; | |||
| } | |||
| } //SchemaLocation | |||
| } | |||
| @@ -84,9 +84,7 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||
| } | |||
| ClassFile classFile = new ClassFile(); | |||
| classFile.read(inStream); | |||
| for (String dependency : classFile.getClassRefs()) { | |||
| analyzedDeps.add(dependency); | |||
| } | |||
| analyzedDeps.addAll(classFile.getClassRefs()); | |||
| } finally { | |||
| FileUtils.close(inStream); | |||
| FileUtils.close(zipFile); | |||
| @@ -103,7 +103,7 @@ public class ConstantPool { | |||
| if (entry instanceof Utf8CPInfo) { | |||
| Utf8CPInfo utf8Info = (Utf8CPInfo) entry; | |||
| utf8Indexes.put(utf8Info.getValue(), Integer.valueOf(index)); | |||
| utf8Indexes.put(utf8Info.getValue(), index); | |||
| } | |||
| return index; | |||
| @@ -145,7 +145,7 @@ public class ConstantPool { | |||
| Integer indexInteger = utf8Indexes.get(value); | |||
| if (indexInteger != null) { | |||
| index = indexInteger.intValue(); | |||
| index = indexInteger; | |||
| } | |||
| return index; | |||
| @@ -43,7 +43,7 @@ public class DoubleCPInfo extends ConstantCPInfo { | |||
| */ | |||
| @Override | |||
| public void read(DataInputStream cpStream) throws IOException { | |||
| setValue(Double.valueOf(cpStream.readDouble())); | |||
| setValue(cpStream.readDouble()); | |||
| } | |||
| /** | |||
| @@ -41,7 +41,7 @@ public class FloatCPInfo extends ConstantCPInfo { | |||
| */ | |||
| @Override | |||
| public void read(DataInputStream cpStream) throws IOException { | |||
| setValue(Float.valueOf(cpStream.readFloat())); | |||
| setValue(cpStream.readFloat()); | |||
| } | |||
| /** | |||
| @@ -41,7 +41,7 @@ public class IntegerCPInfo extends ConstantCPInfo { | |||
| */ | |||
| @Override | |||
| public void read(DataInputStream cpStream) throws IOException { | |||
| setValue(Integer.valueOf(cpStream.readInt())); | |||
| setValue(cpStream.readInt()); | |||
| } | |||
| /** | |||
| @@ -41,7 +41,7 @@ public class LongCPInfo extends ConstantCPInfo { | |||
| */ | |||
| @Override | |||
| public void read(DataInputStream cpStream) throws IOException { | |||
| setValue(Long.valueOf(cpStream.readLong())); | |||
| setValue(cpStream.readLong()); | |||
| } | |||
| /** | |||
| @@ -330,19 +330,19 @@ public class IPlanetEjbc { | |||
| private static void usage() { | |||
| System.out.println("java org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbc \\"); | |||
| System.out.println(" [OPTIONS] [EJB 1.1 descriptor] [iAS EJB descriptor]"); | |||
| System.out.println(""); | |||
| System.out.println(); | |||
| System.out.println("Where OPTIONS are:"); | |||
| System.out.println(" -debug -- for additional debugging output"); | |||
| System.out.println(" -keepsource -- to retain Java source files generated"); | |||
| System.out.println(" -classpath [classpath] -- classpath used for compilation"); | |||
| System.out.println(" -d [destination directory] -- directory for compiled classes"); | |||
| System.out.println(""); | |||
| System.out.println(); | |||
| System.out.println("If a classpath is not specified, the system classpath"); | |||
| System.out.println("will be used. If a destination directory is not specified,"); | |||
| System.out.println("the current working directory will be used (classes will"); | |||
| System.out.println("still be placed in subfolders which correspond to their"); | |||
| System.out.println("package name)."); | |||
| System.out.println(""); | |||
| System.out.println(); | |||
| System.out.println("The EJB home interface, remote interface, and implementation"); | |||
| System.out.println("class must be found in the destination directory. In"); | |||
| System.out.println("addition, the destination will look for the stubs and skeletons"); | |||
| @@ -1295,21 +1295,21 @@ public class IPlanetEjbc { | |||
| */ | |||
| @Override | |||
| public String toString() { | |||
| String s = "EJB name: " + name | |||
| + "\n\r home: " + home | |||
| + "\n\r remote: " + remote | |||
| + "\n\r impl: " + implementation | |||
| + "\n\r primaryKey: " + primaryKey | |||
| + "\n\r beantype: " + beantype | |||
| + "\n\r cmp: " + cmp | |||
| + "\n\r iiop: " + iiop | |||
| + "\n\r hasession: " + hasession; | |||
| StringBuilder s = new StringBuilder("EJB name: " + name | |||
| + "\n\r home: " + home | |||
| + "\n\r remote: " + remote | |||
| + "\n\r impl: " + implementation | |||
| + "\n\r primaryKey: " + primaryKey | |||
| + "\n\r beantype: " + beantype | |||
| + "\n\r cmp: " + cmp | |||
| + "\n\r iiop: " + iiop | |||
| + "\n\r hasession: " + hasession); | |||
| for (String cmpDescriptor : cmpDescriptors) { | |||
| s += "\n\r CMP Descriptor: " + cmpDescriptor; | |||
| s.append("\n\r CMP Descriptor: ").append(cmpDescriptor); | |||
| } | |||
| return s; | |||
| return s.toString(); | |||
| } | |||
| } // End of EjbInfo inner class | |||
| @@ -830,8 +830,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||
| rebuild = true; | |||
| } | |||
| } | |||
| if (genericLoader != null | |||
| && genericLoader instanceof AntClassLoader) { | |||
| if (genericLoader instanceof AntClassLoader) { | |||
| @SuppressWarnings("resource") | |||
| AntClassLoader loader = (AntClassLoader) genericLoader; | |||
| loader.cleanup(); | |||
| @@ -812,8 +812,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||
| rebuild = true; | |||
| } | |||
| } | |||
| if (genericLoader != null | |||
| && genericLoader instanceof AntClassLoader) { | |||
| if (genericLoader instanceof AntClassLoader) { | |||
| @SuppressWarnings("resource") | |||
| AntClassLoader loader = (AntClassLoader) genericLoader; | |||
| loader.cleanup(); | |||
| @@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.optional.extension; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import java.util.jar.JarFile; | |||
| import java.util.jar.Manifest; | |||
| @@ -66,9 +67,7 @@ public final class ExtensionUtil { | |||
| final List<FileSet> fileset) | |||
| throws BuildException { | |||
| if (!fileset.isEmpty()) { | |||
| for (Extension extension : getExtensions(project, fileset)) { | |||
| libraries.add(extension); | |||
| } | |||
| Collections.addAll(libraries, getExtensions(project, fileset)); | |||
| } | |||
| } | |||
| @@ -332,33 +332,22 @@ public final class Specification { | |||
| } | |||
| // Available specification version must be >= required | |||
| final DeweyDecimal otherSpecificationVersion | |||
| = other.getSpecificationVersion(); | |||
| if (null != specificationVersion) { | |||
| if (null == otherSpecificationVersion | |||
| || !isCompatible(specificationVersion, otherSpecificationVersion)) { | |||
| return REQUIRE_SPECIFICATION_UPGRADE; | |||
| } | |||
| final DeweyDecimal otherSpecificationVersion = other.getSpecificationVersion(); | |||
| if (null != specificationVersion && (null == otherSpecificationVersion | |||
| || !isCompatible(specificationVersion, otherSpecificationVersion))) { | |||
| return REQUIRE_SPECIFICATION_UPGRADE; | |||
| } | |||
| // Implementation Vendor ID must match | |||
| final String otherImplementationVendor | |||
| = other.getImplementationVendor(); | |||
| if (null != implementationVendor) { | |||
| if (null == otherImplementationVendor | |||
| || !implementationVendor.equals(otherImplementationVendor)) { | |||
| return REQUIRE_VENDOR_SWITCH; | |||
| } | |||
| if (null != implementationVendor | |||
| && !implementationVendor.equals(other.getImplementationVendor())) { | |||
| return REQUIRE_VENDOR_SWITCH; | |||
| } | |||
| // Implementation version must be >= required | |||
| final String otherImplementationVersion | |||
| = other.getImplementationVersion(); | |||
| if (null != implementationVersion) { | |||
| if (null == otherImplementationVersion | |||
| || !implementationVersion.equals(otherImplementationVersion)) { | |||
| return REQUIRE_IMPLEMENTATION_CHANGE; | |||
| } | |||
| if (null != implementationVersion | |||
| && !implementationVersion.equals(other.getImplementationVersion())) { | |||
| return REQUIRE_IMPLEMENTATION_CHANGE; | |||
| } | |||
| // This available optional package satisfies the requirements | |||
| @@ -65,7 +65,7 @@ public class JJDoc extends Task { | |||
| * @param plainText a <code>boolean</code> value. | |||
| */ | |||
| public void setText(boolean plainText) { | |||
| optionalAttrs.put(TEXT, Boolean.valueOf(plainText)); | |||
| optionalAttrs.put(TEXT, plainText); | |||
| this.plainText = plainText; | |||
| } | |||
| @@ -74,7 +74,7 @@ public class JJDoc extends Task { | |||
| * @param oneTable a <code>boolean</code> value. | |||
| */ | |||
| public void setOnetable(boolean oneTable) { | |||
| optionalAttrs.put(ONE_TABLE, Boolean.valueOf(oneTable)); | |||
| optionalAttrs.put(ONE_TABLE, oneTable); | |||
| } | |||
| /** | |||
| @@ -74,7 +74,7 @@ public class JJTree extends Task { | |||
| * @param buildNodeFiles a <code>boolean</code> value. | |||
| */ | |||
| public void setBuildnodefiles(boolean buildNodeFiles) { | |||
| optionalAttrs.put(BUILD_NODE_FILES, Boolean.valueOf(buildNodeFiles)); | |||
| optionalAttrs.put(BUILD_NODE_FILES, buildNodeFiles); | |||
| } | |||
| /** | |||
| @@ -82,7 +82,7 @@ public class JJTree extends Task { | |||
| * @param multi a <code>boolean</code> value. | |||
| */ | |||
| public void setMulti(boolean multi) { | |||
| optionalAttrs.put(MULTI, Boolean.valueOf(multi)); | |||
| optionalAttrs.put(MULTI, multi); | |||
| } | |||
| /** | |||
| @@ -90,7 +90,7 @@ public class JJTree extends Task { | |||
| * @param nodeDefaultVoid a <code>boolean</code> value. | |||
| */ | |||
| public void setNodedefaultvoid(boolean nodeDefaultVoid) { | |||
| optionalAttrs.put(NODE_DEFAULT_VOID, Boolean.valueOf(nodeDefaultVoid)); | |||
| optionalAttrs.put(NODE_DEFAULT_VOID, nodeDefaultVoid); | |||
| } | |||
| /** | |||
| @@ -98,7 +98,7 @@ public class JJTree extends Task { | |||
| * @param nodeFactory a <code>boolean</code> value. | |||
| */ | |||
| public void setNodefactory(boolean nodeFactory) { | |||
| optionalAttrs.put(NODE_FACTORY, Boolean.valueOf(nodeFactory)); | |||
| optionalAttrs.put(NODE_FACTORY, nodeFactory); | |||
| } | |||
| /** | |||
| @@ -106,7 +106,7 @@ public class JJTree extends Task { | |||
| * @param nodeScopeHook a <code>boolean</code> value. | |||
| */ | |||
| public void setNodescopehook(boolean nodeScopeHook) { | |||
| optionalAttrs.put(NODE_SCOPE_HOOK, Boolean.valueOf(nodeScopeHook)); | |||
| optionalAttrs.put(NODE_SCOPE_HOOK, nodeScopeHook); | |||
| } | |||
| /** | |||
| @@ -114,7 +114,7 @@ public class JJTree extends Task { | |||
| * @param nodeUsesParser a <code>boolean</code> value. | |||
| */ | |||
| public void setNodeusesparser(boolean nodeUsesParser) { | |||
| optionalAttrs.put(NODE_USES_PARSER, Boolean.valueOf(nodeUsesParser)); | |||
| optionalAttrs.put(NODE_USES_PARSER, nodeUsesParser); | |||
| } | |||
| /** | |||
| @@ -122,7 +122,7 @@ public class JJTree extends Task { | |||
| * @param staticParser a <code>boolean</code> value. | |||
| */ | |||
| public void setStatic(boolean staticParser) { | |||
| optionalAttrs.put(STATIC, Boolean.valueOf(staticParser)); | |||
| optionalAttrs.put(STATIC, staticParser); | |||
| } | |||
| /** | |||
| @@ -130,7 +130,7 @@ public class JJTree extends Task { | |||
| * @param visitor a <code>boolean</code> value. | |||
| */ | |||
| public void setVisitor(boolean visitor) { | |||
| optionalAttrs.put(VISITOR, Boolean.valueOf(visitor)); | |||
| optionalAttrs.put(VISITOR, visitor); | |||
| } | |||
| /** | |||
| @@ -111,7 +111,7 @@ public class JavaCC extends Task { | |||
| * @param lookahead an <code>int</code> value. | |||
| */ | |||
| public void setLookahead(int lookahead) { | |||
| optionalAttrs.put(LOOKAHEAD, Integer.valueOf(lookahead)); | |||
| optionalAttrs.put(LOOKAHEAD, lookahead); | |||
| } | |||
| /** | |||
| @@ -119,7 +119,7 @@ public class JavaCC extends Task { | |||
| * @param choiceAmbiguityCheck an <code>int</code> value. | |||
| */ | |||
| public void setChoiceambiguitycheck(int choiceAmbiguityCheck) { | |||
| optionalAttrs.put(CHOICE_AMBIGUITY_CHECK, Integer.valueOf(choiceAmbiguityCheck)); | |||
| optionalAttrs.put(CHOICE_AMBIGUITY_CHECK, choiceAmbiguityCheck); | |||
| } | |||
| /** | |||
| @@ -127,7 +127,7 @@ public class JavaCC extends Task { | |||
| * @param otherAmbiguityCheck an <code>int</code> value. | |||
| */ | |||
| public void setOtherambiguityCheck(int otherAmbiguityCheck) { | |||
| optionalAttrs.put(OTHER_AMBIGUITY_CHECK, Integer.valueOf(otherAmbiguityCheck)); | |||
| optionalAttrs.put(OTHER_AMBIGUITY_CHECK, otherAmbiguityCheck); | |||
| } | |||
| /** | |||
| @@ -624,7 +624,7 @@ public class JDependTask extends Task { | |||
| if (getTimeout() == null) { | |||
| return null; | |||
| } | |||
| return new ExecuteWatchdog(getTimeout().longValue()); | |||
| return new ExecuteWatchdog(getTimeout()); | |||
| } | |||
| private Optional<Path> getWorkingPath() { | |||
| @@ -64,33 +64,33 @@ class ConstantPool { | |||
| break; | |||
| case INTEGER : | |||
| values[i] = Integer.valueOf(data.readInt()); | |||
| values[i] = data.readInt(); | |||
| break; | |||
| case FLOAT : | |||
| values[i] = Float.valueOf(data.readFloat()); | |||
| values[i] = data.readFloat(); | |||
| break; | |||
| case LONG : | |||
| values[i] = Long.valueOf(data.readLong()); | |||
| values[i] = data.readLong(); | |||
| ++i; | |||
| break; | |||
| case DOUBLE : | |||
| values[i] = Double.valueOf(data.readDouble()); | |||
| values[i] = data.readDouble(); | |||
| ++i; | |||
| break; | |||
| case CLASS : | |||
| case STRING : | |||
| values[i] = Integer.valueOf(data.readUnsignedShort()); | |||
| values[i] = data.readUnsignedShort(); | |||
| break; | |||
| case FIELDREF : | |||
| case METHODREF : | |||
| case INTERFACEMETHODREF : | |||
| case NAMEANDTYPE : | |||
| values[i] = Integer.valueOf(data.readInt()); | |||
| values[i] = data.readInt(); | |||
| break; | |||
| default: | |||
| // Do nothing | |||
| @@ -129,7 +129,7 @@ public class ClassNameReader { | |||
| /* int accessFlags = */ data.readUnsignedShort(); | |||
| int classIndex = data.readUnsignedShort(); | |||
| Integer stringIndex = (Integer) values[classIndex]; | |||
| String className = (String) values[stringIndex.intValue()]; | |||
| String className = (String) values[stringIndex]; | |||
| return className; | |||
| } | |||
| @@ -307,14 +307,14 @@ public class WLJspc extends MatchingTask { | |||
| */ | |||
| protected String replaceString(String inpString, String escapeChars, | |||
| String replaceChars) { | |||
| String localString = ""; | |||
| StringBuilder localString = new StringBuilder(); | |||
| StringTokenizer st = new StringTokenizer(inpString, escapeChars, true); | |||
| int numTokens = st.countTokens(); | |||
| for (int i = 0; i < numTokens; i++) { | |||
| String test = st.nextToken(); | |||
| test = (test.equals(escapeChars) ? replaceChars : test); | |||
| localString += test; | |||
| localString.append(test); | |||
| } | |||
| return localString; | |||
| return localString.toString(); | |||
| } | |||
| } | |||
| @@ -50,15 +50,13 @@ public abstract class DefaultJspCompilerAdapter | |||
| jspc.log("Compilation " + cmd.describeJavaCommand(), | |||
| Project.MSG_VERBOSE); | |||
| StringBuilder niceSourceList = | |||
| new StringBuilder(compileList.size() == 1 ? "File" : "Files") | |||
| .append(" to be compiled:").append(lSep) | |||
| .append(compileList.stream() | |||
| .peek(arg -> cmd.createArgument().setValue(arg)) | |||
| .map(arg -> " " + arg) | |||
| .collect(Collectors.joining(lSep))); | |||
| jspc.log(niceSourceList.toString(), Project.MSG_VERBOSE); | |||
| String niceSourceList = (compileList.size() == 1 ? "File" : "Files") + | |||
| " to be compiled:" + lSep + | |||
| compileList.stream() | |||
| .peek(arg -> cmd.createArgument().setValue(arg)) | |||
| .map(arg -> " " + arg) | |||
| .collect(Collectors.joining(lSep)); | |||
| jspc.log(niceSourceList, Project.MSG_VERBOSE); | |||
| } | |||
| // CheckStyle:VisibilityModifier OFF - bc | |||
| @@ -322,7 +322,7 @@ public class AggregateTransformer { | |||
| final String suffix; | |||
| final String xsltFactoryName = xsltFactory == null ? null : xsltFactory.getName(); | |||
| if(xsltFactoryName != null && "net.sf.saxon.TransformerFactoryImpl".equals(xsltFactoryName)) { | |||
| if ("net.sf.saxon.TransformerFactoryImpl".equals(xsltFactoryName)) { | |||
| suffix = "-saxon.xsl"; | |||
| } else { | |||
| suffix = ".xsl"; | |||
| @@ -124,9 +124,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||
| return; // Quick return - no output do nothing. | |||
| } | |||
| try { | |||
| output | |||
| .write(new StringBuilder("Testsuite: ").append(suite.getName()) | |||
| .append(StringUtils.LINE_SEP).toString()); | |||
| output.write("Testsuite: " + suite.getName() + StringUtils.LINE_SEP); | |||
| output.flush(); | |||
| } catch (IOException ex) { | |||
| throw new BuildException(ex); | |||
| @@ -1643,7 +1643,7 @@ public class JUnitTask extends Task { | |||
| if (timeout == null) { | |||
| return null; | |||
| } | |||
| return new ExecuteWatchdog((long) timeout.intValue()); | |||
| return new ExecuteWatchdog((long) timeout); | |||
| } | |||
| /** | |||
| @@ -129,7 +129,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| this.haltOnFail = haltOnFailure; | |||
| this.filtertrace = filtertrace; | |||
| this.methodsSpecified = methods != null; | |||
| this.methods = methodsSpecified ? (String[]) methods.clone() : null; | |||
| this.methods = methodsSpecified ? methods.clone() : null; | |||
| this.antThreadID = thread; | |||
| } | |||
| @@ -306,7 +306,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
| this.haltOnFailure = haltOnFailure; | |||
| this.showOutput = showOutput; | |||
| this.logTestListenerEvents = logTestListenerEvents; | |||
| this.methods = methods != null ? (String[]) methods.clone() : null; | |||
| this.methods = methods != null ? methods.clone() : null; | |||
| this.loader = loader; | |||
| } | |||
| @@ -46,11 +46,11 @@ public class JUnitVersionHelper { | |||
| static { | |||
| try { | |||
| testCaseName = TestCase.class.getMethod("getName", new Class[0]); | |||
| testCaseName = TestCase.class.getMethod("getName"); | |||
| } catch (NoSuchMethodException e) { | |||
| // pre JUnit 3.7 | |||
| try { | |||
| testCaseName = TestCase.class.getMethod("name", new Class[0]); | |||
| testCaseName = TestCase.class.getMethod("name"); | |||
| } catch (NoSuchMethodException ignored) { | |||
| // ignore | |||
| } | |||
| @@ -105,8 +105,8 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||
| return; // Quick return - no output do nothing. | |||
| } | |||
| try { | |||
| out.write(new StringBuilder("Testsuite: ").append(suite.getName()) | |||
| .append(StringUtils.LINE_SEP).toString().getBytes()); | |||
| out.write(("Testsuite: " + suite.getName() + | |||
| StringUtils.LINE_SEP).getBytes()); | |||
| out.flush(); | |||
| } catch (IOException ex) { | |||
| throw new BuildException("Unable to write output", ex); | |||
| @@ -122,19 +122,9 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||
| public void endTestSuite(JUnitTest suite) throws BuildException { | |||
| boolean success = false; | |||
| try { | |||
| StringBuilder sb = new StringBuilder("Tests run: "); | |||
| sb.append(suite.runCount()); | |||
| sb.append(", Failures: "); | |||
| sb.append(suite.failureCount()); | |||
| sb.append(", Errors: "); | |||
| sb.append(suite.errorCount()); | |||
| sb.append(", Skipped: "); | |||
| sb.append(suite.skipCount()); | |||
| sb.append(", Time elapsed: "); | |||
| sb.append(nf.format(suite.getRunTime() / ONE_SECOND)); | |||
| sb.append(" sec"); | |||
| sb.append(StringUtils.LINE_SEP); | |||
| write(sb.toString()); | |||
| write(String.format("Tests run: %d, Failures: %d, Errors: %d, Skipped: %d, Time elapsed: %s sec%n", | |||
| suite.runCount(), suite.failureCount(), suite.errorCount(), suite.skipCount(), | |||
| nf.format(suite.getRunTime() / ONE_SECOND))); | |||
| // write the err and output streams to the log | |||
| if (systemOutput != null && systemOutput.length() > 0) { | |||
| @@ -190,7 +180,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||
| */ | |||
| @Override | |||
| public void startTest(Test t) { | |||
| testStarts.put(t, new Long(System.currentTimeMillis())); | |||
| testStarts.put(t, System.currentTimeMillis()); | |||
| failed.put(t, Boolean.FALSE); | |||
| } | |||
| @@ -214,7 +204,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||
| // can be null if an error occurred in setUp | |||
| if (l != null) { | |||
| seconds = | |||
| (System.currentTimeMillis() - l.longValue()) / ONE_SECOND; | |||
| (System.currentTimeMillis() - l) / ONE_SECOND; | |||
| } | |||
| wri.write(" took " + nf.format(seconds) + " sec"); | |||
| @@ -279,10 +279,7 @@ abstract class AbstractJUnitResultFormatter implements TestResultFormatter { | |||
| if (this.inMemoryStore != null && this.inMemoryStore.position() > 0) { | |||
| return true; | |||
| } | |||
| if (this.usingFileStore && this.filePath != null) { | |||
| return true; | |||
| } | |||
| return false; | |||
| return this.usingFileStore && this.filePath != null; | |||
| } | |||
| @Override | |||
| @@ -108,7 +108,7 @@ public class Native2AsciiAdapterFactory { | |||
| private static Native2AsciiAdapter resolveClassName(String className, | |||
| ClassLoader loader) | |||
| throws BuildException { | |||
| return (Native2AsciiAdapter) ClasspathUtils.newInstance(className, | |||
| return ClasspathUtils.newInstance(className, | |||
| loader != null ? loader : | |||
| Native2AsciiAdapterFactory.class.getClassLoader(), | |||
| Native2AsciiAdapter.class); | |||
| @@ -246,11 +246,11 @@ public class FTP extends Task implements FTPTaskConfig { | |||
| */ | |||
| @Override | |||
| public String getParent() { | |||
| String result = ""; | |||
| StringBuilder result = new StringBuilder(); | |||
| for (int i = 0; i < parts.length - 1; i++){ | |||
| result += File.separatorChar + parts[i]; | |||
| result.append(File.separatorChar).append(parts[i]); | |||
| } | |||
| return result; | |||
| return result.toString(); | |||
| } | |||
| @@ -145,11 +145,11 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
| */ | |||
| @Override | |||
| public String getParent() { | |||
| String result = ""; | |||
| for(int i = 0; i < parts.length - 1; i++){ | |||
| result += File.separatorChar + parts[i]; | |||
| StringBuilder result = new StringBuilder(); | |||
| for (int i = 0; i < parts.length - 1; i++){ | |||
| result.append(File.separatorChar).append(parts[i]); | |||
| } | |||
| return result; | |||
| return result.toString(); | |||
| } | |||
| /* (non-Javadoc) | |||
| @@ -206,7 +206,7 @@ public class RExecTask extends Task { | |||
| try { | |||
| StringBuilder sb = new StringBuilder(); | |||
| int windowStart = -s.length(); | |||
| if (timeout == null || timeout.intValue() == 0) { | |||
| if (timeout == null || timeout == 0) { | |||
| while (windowStart < 0 | |||
| || !sb.substring(windowStart).equals(s)) { | |||
| sb.append((char) is.read()); | |||
| @@ -214,7 +214,7 @@ public class RExecTask extends Task { | |||
| } | |||
| } else { | |||
| Calendar endTime = Calendar.getInstance(); | |||
| endTime.add(Calendar.SECOND, timeout.intValue()); | |||
| endTime.add(Calendar.SECOND, timeout); | |||
| while (windowStart < 0 | |||
| || !sb.substring(windowStart).equals(s)) { | |||
| while (Calendar.getInstance().before(endTime) | |||
| @@ -265,7 +265,7 @@ public class RExecTask extends Task { | |||
| InputStream is = this.getInputStream(); | |||
| try { | |||
| StringBuilder sb = new StringBuilder(); | |||
| if (timeout == null || timeout.intValue() == 0) { | |||
| if (timeout == null || timeout == 0) { | |||
| int read; | |||
| while ((read = is.read()) != -1) { | |||
| char c = (char) read; | |||
| @@ -277,7 +277,7 @@ public class RExecTask extends Task { | |||
| } | |||
| } else { | |||
| Calendar endTime = Calendar.getInstance(); | |||
| endTime.add(Calendar.SECOND, timeout.intValue()); | |||
| endTime.add(Calendar.SECOND, timeout); | |||
| int read = 0; | |||
| while (read != -1) { | |||
| while (Calendar.getInstance().before(endTime) && is.available() == 0) { | |||
| @@ -348,7 +348,7 @@ public class TelnetTask extends Task { | |||
| try { | |||
| StringBuilder sb = new StringBuilder(); | |||
| int windowStart = -s.length(); | |||
| if (timeout == null || timeout.intValue() == 0) { | |||
| if (timeout == null || timeout == 0) { | |||
| while (windowStart < 0 | |||
| || !sb.substring(windowStart).equals(s)) { | |||
| sb.append((char) is.read()); | |||
| @@ -356,7 +356,7 @@ public class TelnetTask extends Task { | |||
| } | |||
| } else { | |||
| Calendar endTime = Calendar.getInstance(); | |||
| endTime.add(Calendar.SECOND, timeout.intValue()); | |||
| endTime.add(Calendar.SECOND, timeout); | |||
| while (windowStart < 0 | |||
| || !sb.substring(windowStart).equals(s)) { | |||
| while (Calendar.getInstance().before(endTime) | |||
| @@ -124,7 +124,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| } | |||
| if (duration != null) { | |||
| playClip(audioClip, duration.longValue()); | |||
| playClip(audioClip, duration); | |||
| } else { | |||
| playClip(audioClip, loops); | |||
| } | |||
| @@ -162,7 +162,7 @@ public class SoundTask extends Task { | |||
| Random rn = new Random(); | |||
| int x = rn.nextInt(numfiles); | |||
| // set the source to the file at that location | |||
| this.source = (File) files.elementAt(x); | |||
| this.source = files.elementAt(x); | |||
| } | |||
| } else { | |||
| log(source + ": invalid path.", Project.MSG_WARN); | |||
| @@ -61,9 +61,7 @@ public class Directory { | |||
| * @param directory a Directory | |||
| */ | |||
| public void addDirectory(Directory directory) { | |||
| if (!childDirectories.contains(directory)) { | |||
| childDirectories.add(directory); | |||
| } | |||
| childDirectories.add(directory); | |||
| } | |||
| /** | |||
| @@ -210,7 +210,7 @@ public class SSHSession extends SSHBase { | |||
| int rport = 0; | |||
| public void setLPort(final int lport) { | |||
| final Integer portKey = Integer.valueOf(lport); | |||
| final Integer portKey = lport; | |||
| if (localPortsUsed.contains(portKey)) { | |||
| throw new BuildException( | |||
| "Multiple local tunnels defined to use same local port %d", | |||
| @@ -265,7 +265,7 @@ public class SSHSession extends SSHBase { | |||
| } | |||
| public void setRPort(final int rport) { | |||
| final Integer portKey = Integer.valueOf(rport); | |||
| final Integer portKey = rport; | |||
| if (remotePortsUsed.contains(portKey)) { | |||
| throw new BuildException( | |||
| "Multiple remote tunnels defined to use same remote port %d", | |||
| @@ -364,10 +364,10 @@ public class Scp extends SSHBase { | |||
| } | |||
| message.setLogListener(this); | |||
| if (fileMode != null) { | |||
| message.setFileMode(fileMode.intValue()); | |||
| message.setFileMode(fileMode); | |||
| } | |||
| if (dirMode != null) { | |||
| message.setDirMode(dirMode.intValue()); | |||
| message.setDirMode(dirMode); | |||
| } | |||
| message.execute(); | |||
| } | |||
| @@ -399,10 +399,10 @@ public class Scp extends SSHBase { | |||
| } | |||
| message.setLogListener(this); | |||
| if (fileMode != null) { | |||
| message.setFileMode(fileMode.intValue()); | |||
| message.setFileMode(fileMode); | |||
| } | |||
| if (dirMode != null) { | |||
| message.setDirMode(dirMode.intValue()); | |||
| message.setDirMode(dirMode); | |||
| } | |||
| message.execute(); | |||
| } finally { | |||
| @@ -420,7 +420,7 @@ public class ScpToMessage extends AbstractSshMessage { | |||
| * @since Ant 1.9.5 | |||
| */ | |||
| public int getFileMode() { | |||
| return fileMode != null ? fileMode.intValue() : DEFAULT_FILE_MODE; | |||
| return fileMode != null ? fileMode : DEFAULT_FILE_MODE; | |||
| } | |||
| /** | |||
| @@ -438,7 +438,7 @@ public class ScpToMessage extends AbstractSshMessage { | |||
| * @since Ant 1.9.5 | |||
| */ | |||
| public int getDirMode() { | |||
| return dirMode != null ? dirMode.intValue() : DEFAULT_DIR_MODE; | |||
| return dirMode != null ? dirMode : DEFAULT_DIR_MODE; | |||
| } | |||
| /** | |||
| @@ -640,7 +640,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
| * @return True if the FailOnError flag has been set or if 'writablefiles=skip'. | |||
| */ | |||
| private boolean getFailOnError() { | |||
| return getWritableFiles().equals(WRITABLE_SKIP) ? false : failOnError; | |||
| return !getWritableFiles().equals(WRITABLE_SKIP) && failOnError; | |||
| } | |||
| @@ -351,15 +351,11 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
| attributes.log("Compilation " + cmd.describeArguments(), | |||
| Project.MSG_VERBOSE); | |||
| StringBuilder niceSourceList = | |||
| new StringBuilder(compileList.size() == 1 ? "File" : "Files") | |||
| .append(" to be compiled:"); | |||
| niceSourceList.append( | |||
| compileList.stream().peek(arg -> cmd.createArgument().setValue(arg)) | |||
| .collect(Collectors.joining(" "))); | |||
| attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE); | |||
| String niceSourceList = (compileList.size() == 1 ? "File" : "Files") + | |||
| " to be compiled:" + | |||
| compileList.stream().peek(arg -> cmd.createArgument().setValue(arg)) | |||
| .collect(Collectors.joining(" ")); | |||
| attributes.log(niceSourceList, Project.MSG_VERBOSE); | |||
| } | |||
| private void verifyArguments(Commandline cmd) { | |||
| @@ -56,7 +56,7 @@ public class DirSet extends AbstractFileSet implements ResourceCollection { | |||
| @Override | |||
| public Object clone() { | |||
| if (isReference()) { | |||
| return ((DirSet) getRef(getProject())).clone(); | |||
| return getRef(getProject()).clone(); | |||
| } | |||
| return super.clone(); | |||
| } | |||
| @@ -115,8 +115,7 @@ public class Environment { | |||
| */ | |||
| public String getContent() throws BuildException { | |||
| validate(); | |||
| return new StringBuilder(key.trim()).append("=") | |||
| .append(value.trim()).toString(); | |||
| return key.trim() + "=" + value.trim(); | |||
| } | |||
| /** | |||