| @@ -539,15 +539,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||||
| */ | */ | ||||
| public String getClasspath() { | public String getClasspath() { | ||||
| final StringBuilder sb = new StringBuilder(); | final StringBuilder sb = new StringBuilder(); | ||||
| boolean firstPass = true; | |||||
| final Enumeration<File> componentEnum = pathComponents.elements(); | |||||
| while (componentEnum.hasMoreElements()) { | |||||
| if (!firstPass) { | |||||
| sb.append(System.getProperty("path.separator")); | |||||
| } else { | |||||
| firstPass = false; | |||||
| for (final File component : pathComponents) { | |||||
| if (sb.length() > 0) { | |||||
| sb.append(File.pathSeparator); | |||||
| } | } | ||||
| sb.append(componentEnum.nextElement().getAbsolutePath()); | |||||
| sb.append(component.getAbsolutePath()); | |||||
| } | } | ||||
| return sb.toString(); | return sb.toString(); | ||||
| } | } | ||||
| @@ -1407,8 +1403,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||||
| * files are closed. | * files are closed. | ||||
| */ | */ | ||||
| public synchronized void cleanup() { | public synchronized void cleanup() { | ||||
| for (final Enumeration<JarFile> e = jarFiles.elements(); e.hasMoreElements();) { | |||||
| FileUtils.close(e.nextElement()); | |||||
| for (final JarFile jarFile : jarFiles.values()) { | |||||
| FileUtils.close(jarFile); | |||||
| } | } | ||||
| jarFiles = new Hashtable<>(); | jarFiles = new Hashtable<>(); | ||||
| if (project != null) { | if (project != null) { | ||||
| @@ -83,11 +83,7 @@ public class PathTokenizer { | |||||
| * in the string after the current position; <code>false</code> otherwise. | * in the string after the current position; <code>false</code> otherwise. | ||||
| */ | */ | ||||
| public boolean hasMoreTokens() { | public boolean hasMoreTokens() { | ||||
| if (lookahead != null) { | |||||
| return true; | |||||
| } | |||||
| return tokenizer.hasMoreTokens(); | |||||
| return lookahead != null || tokenizer.hasMoreTokens(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1828,10 +1828,10 @@ public class Project implements ResourceFactory { | |||||
| + root); | + root); | ||||
| } | } | ||||
| } | } | ||||
| final StringBuilder buf = new StringBuilder("Build sequence for target(s)"); | |||||
| for (int j = 0; j < roots.length; j++) { | |||||
| buf.append((j == 0) ? " `" : ", `").append(roots[j]).append('\''); | |||||
| final StringBuilder buf = new StringBuilder(); | |||||
| for (String root : roots) { | |||||
| buf.append((buf.length() == 0) ? "Build sequence for target(s) `" | |||||
| : ", `").append(root).append('\''); | |||||
| } | } | ||||
| buf.append(" is ").append(ret); | buf.append(" is ").append(ret); | ||||
| log(buf.toString(), MSG_VERBOSE); | log(buf.toString(), MSG_VERBOSE); | ||||
| @@ -20,10 +20,10 @@ package org.apache.tools.ant; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Collection; | import java.util.Collection; | ||||
| import java.util.Collections; | import java.util.Collections; | ||||
| import java.util.Enumeration; | |||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.Set; | import java.util.Set; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -974,14 +974,11 @@ public class PropertyHelper implements GetProperty { | |||||
| public void copyInheritedProperties(Project other) { | public void copyInheritedProperties(Project other) { | ||||
| //avoid concurrent modification: | //avoid concurrent modification: | ||||
| synchronized (inheritedProperties) { | synchronized (inheritedProperties) { | ||||
| Enumeration<String> e = inheritedProperties.keys(); | |||||
| while (e.hasMoreElements()) { | |||||
| String arg = e.nextElement(); | |||||
| if (other.getUserProperty(arg) != null) { | |||||
| continue; | |||||
| for (Map.Entry<String, Object> entry : inheritedProperties.entrySet()) { | |||||
| String arg = entry.getKey(); | |||||
| if (other.getUserProperty(arg) == null) { | |||||
| other.setInheritedProperty(arg, entry.getValue().toString()); | |||||
| } | } | ||||
| Object value = inheritedProperties.get(arg); | |||||
| other.setInheritedProperty(arg, value.toString()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1004,14 +1001,11 @@ public class PropertyHelper implements GetProperty { | |||||
| public void copyUserProperties(Project other) { | public void copyUserProperties(Project other) { | ||||
| //avoid concurrent modification: | //avoid concurrent modification: | ||||
| synchronized (userProperties) { | synchronized (userProperties) { | ||||
| Enumeration<String> e = userProperties.keys(); | |||||
| while (e.hasMoreElements()) { | |||||
| Object arg = e.nextElement(); | |||||
| if (inheritedProperties.containsKey(arg)) { | |||||
| continue; | |||||
| for (Map.Entry<String, Object> entry : userProperties.entrySet()) { | |||||
| String arg = entry.getKey(); | |||||
| if (!inheritedProperties.containsKey(arg)) { | |||||
| other.setUserProperty(arg, entry.getValue().toString()); | |||||
| } | } | ||||
| Object value = userProperties.get(arg); | |||||
| other.setUserProperty(arg.toString(), value.toString()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1123,16 +1117,14 @@ public class PropertyHelper implements GetProperty { | |||||
| * @return Set<Class> | * @return Set<Class> | ||||
| * @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
| */ | */ | ||||
| @SuppressWarnings("unchecked") | |||||
| protected static Set<Class<? extends Delegate>> getDelegateInterfaces(Delegate d) { | protected static Set<Class<? extends Delegate>> getDelegateInterfaces(Delegate d) { | ||||
| final HashSet<Class<? extends Delegate>> result = new HashSet<>(); | final HashSet<Class<? extends Delegate>> result = new HashSet<>(); | ||||
| Class<?> c = d.getClass(); | Class<?> c = d.getClass(); | ||||
| while (c != null) { | while (c != null) { | ||||
| for (Class<?> ifc : c.getInterfaces()) { | for (Class<?> ifc : c.getInterfaces()) { | ||||
| if (Delegate.class.isAssignableFrom(ifc)) { | if (Delegate.class.isAssignableFrom(ifc)) { | ||||
| @SuppressWarnings("unchecked") | |||||
| final Class<? extends Delegate> delegateInterface = | |||||
| (Class<? extends Delegate>) ifc; | |||||
| result.add(delegateInterface); | |||||
| result.add((Class<? extends Delegate>) ifc); | |||||
| } | } | ||||
| } | } | ||||
| c = c.getSuperclass(); | c = c.getSuperclass(); | ||||
| @@ -531,23 +531,22 @@ public class RuntimeConfigurable implements Serializable { | |||||
| ih.setAttribute(p, target, name, attrValue); | ih.setAttribute(p, target, name, attrValue); | ||||
| } catch (UnsupportedAttributeException be) { | } catch (UnsupportedAttributeException be) { | ||||
| // id attribute must be set externally | // id attribute must be set externally | ||||
| if ("id".equals(name)) { | |||||
| // Do nothing | |||||
| } else if (getElementTag() == null) { | |||||
| throw be; | |||||
| } else { | |||||
| throw new BuildException( | |||||
| getElementTag() + " doesn't support the \"" | |||||
| + be.getAttribute() + "\" attribute", be); | |||||
| if (!"id".equals(name)) { | |||||
| if (getElementTag() == null) { | |||||
| throw be; | |||||
| } else { | |||||
| throw new BuildException( | |||||
| getElementTag() + " doesn't support the \"" | |||||
| + be.getAttribute() + "\" attribute", be); | |||||
| } | |||||
| } | } | ||||
| } catch (BuildException be) { | } catch (BuildException be) { | ||||
| if ("id".equals(name)) { | |||||
| // Assume that this is an not supported attribute type | |||||
| // thrown for example by a dynamic attribute task | |||||
| // Do nothing | |||||
| } else { | |||||
| if (!"id".equals(name)) { | |||||
| throw be; | throw be; | ||||
| } | } | ||||
| // Assume that this is an not supported attribute type | |||||
| // thrown for example by a dynamic attribute task -- | |||||
| // do nothing | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -207,12 +207,11 @@ public class XmlLogger implements BuildLogger { | |||||
| * @return the stack of timed elements for the current thread | * @return the stack of timed elements for the current thread | ||||
| */ | */ | ||||
| private Stack<TimedElement> getStack() { | private Stack<TimedElement> getStack() { | ||||
| Stack<TimedElement> threadStack = threadStacks.computeIfAbsent(Thread.currentThread(), k -> new Stack<>()); | |||||
| /* For debugging purposes uncomment: | /* For debugging purposes uncomment: | ||||
| org.w3c.dom.Comment s = doc.createComment("stack=" + threadStack); | org.w3c.dom.Comment s = doc.createComment("stack=" + threadStack); | ||||
| buildElement.element.appendChild(s); | buildElement.element.appendChild(s); | ||||
| */ | */ | ||||
| return threadStack; | |||||
| return threadStacks.computeIfAbsent(Thread.currentThread(), k -> new Stack<>()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -73,11 +73,10 @@ public abstract class BaseIfAttribute | |||||
| Hashtable<String, Object> attributes = rc.getAttributeMap(); // This does a copy! | Hashtable<String, Object> attributes = rc.getAttributeMap(); // This does a copy! | ||||
| for (Map.Entry<String, Object> entry : attributes.entrySet()) { | for (Map.Entry<String, Object> entry : attributes.entrySet()) { | ||||
| String key = entry.getKey(); | String key = entry.getKey(); | ||||
| String value = (String) entry.getValue(); | |||||
| if (key.startsWith("ant-attribute:param")) { | if (key.startsWith("ant-attribute:param")) { | ||||
| int pos = key.lastIndexOf(':'); | int pos = key.lastIndexOf(':'); | ||||
| ret.put(key.substring(pos + 1), | ret.put(key.substring(pos + 1), | ||||
| el.getProject().replaceProperties(value)); | |||||
| el.getProject().replaceProperties((String) entry.getValue())); | |||||
| } | } | ||||
| } | } | ||||
| return ret; | return ret; | ||||
| @@ -86,41 +86,27 @@ public final class ClassConstants | |||||
| * be read (for example due to the class not being found). | * be read (for example due to the class not being found). | ||||
| */ | */ | ||||
| public int read() throws IOException { | public int read() throws IOException { | ||||
| int ch = -1; | int ch = -1; | ||||
| if (queuedData != null && queuedData.length() == 0) { | if (queuedData != null && queuedData.length() == 0) { | ||||
| queuedData = null; | queuedData = null; | ||||
| } | } | ||||
| if (queuedData != null) { | |||||
| ch = queuedData.charAt(0); | |||||
| queuedData = queuedData.substring(1); | |||||
| if (queuedData.length() == 0) { | |||||
| queuedData = null; | |||||
| } | |||||
| } else { | |||||
| if (queuedData == null) { | |||||
| final String clazz = readFully(); | final String clazz = readFully(); | ||||
| if (clazz == null || clazz.length() == 0) { | if (clazz == null || clazz.length() == 0) { | ||||
| ch = -1; | ch = -1; | ||||
| } else { | } else { | ||||
| final byte[] bytes = clazz.getBytes(ResourceUtils.ISO_8859_1); | final byte[] bytes = clazz.getBytes(ResourceUtils.ISO_8859_1); | ||||
| try { | try { | ||||
| final Class<?> javaClassHelper = | |||||
| Class.forName(JAVA_CLASS_HELPER); | |||||
| final Class<?> javaClassHelper = Class.forName(JAVA_CLASS_HELPER); | |||||
| if (javaClassHelper != null) { | if (javaClassHelper != null) { | ||||
| final Class<?>[] params = { | |||||
| byte[].class | |||||
| }; | |||||
| final Method getConstants = | final Method getConstants = | ||||
| javaClassHelper.getMethod("getConstants", params); | |||||
| final Object[] args = { | |||||
| bytes | |||||
| }; | |||||
| javaClassHelper.getMethod("getConstants", byte[].class); | |||||
| // getConstants is a static method, no need to | // getConstants is a static method, no need to | ||||
| // pass in the object | // pass in the object | ||||
| final StringBuffer sb = (StringBuffer) | final StringBuffer sb = (StringBuffer) | ||||
| getConstants.invoke(null, args); | |||||
| getConstants.invoke(null, (Object) bytes); | |||||
| if (sb.length() > 0) { | if (sb.length() > 0) { | ||||
| queuedData = sb.toString(); | queuedData = sb.toString(); | ||||
| return read(); | return read(); | ||||
| @@ -141,6 +127,12 @@ public final class ClassConstants | |||||
| throw new BuildException(ex); | throw new BuildException(ex); | ||||
| } | } | ||||
| } | } | ||||
| } else { | |||||
| ch = queuedData.charAt(0); | |||||
| queuedData = queuedData.substring(1); | |||||
| if (queuedData.length() == 0) { | |||||
| queuedData = null; | |||||
| } | |||||
| } | } | ||||
| return ch; | return ch; | ||||
| } | } | ||||
| @@ -156,7 +148,6 @@ public final class ClassConstants | |||||
| * the specified reader | * the specified reader | ||||
| */ | */ | ||||
| public Reader chain(final Reader rdr) { | public Reader chain(final Reader rdr) { | ||||
| ClassConstants newFilter = new ClassConstants(rdr); | |||||
| return newFilter; | |||||
| return new ClassConstants(rdr); | |||||
| } | } | ||||
| } | } | ||||
| @@ -19,7 +19,6 @@ package org.apache.tools.ant.filters; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.util.Properties; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -98,8 +97,7 @@ public final class ExpandProperties | |||||
| if (propertySet == null) { | if (propertySet == null) { | ||||
| getProperty = PropertyHelper.getPropertyHelper(project); | getProperty = PropertyHelper.getPropertyHelper(project); | ||||
| } else { | } else { | ||||
| final Properties props = propertySet.getProperties(); | |||||
| getProperty = props::getProperty; | |||||
| getProperty = propertySet.getProperties()::getProperty; | |||||
| } | } | ||||
| Object expanded = new ParseProperties(project, PropertyHelper | Object expanded = new ParseProperties(project, PropertyHelper | ||||
| .getPropertyHelper(project) | .getPropertyHelper(project) | ||||
| @@ -186,10 +186,8 @@ public final class LineContainsRegExp | |||||
| LineContainsRegExp newFilter = new LineContainsRegExp(rdr); | LineContainsRegExp newFilter = new LineContainsRegExp(rdr); | ||||
| newFilter.setRegexps(getRegexps()); | newFilter.setRegexps(getRegexps()); | ||||
| newFilter.setNegate(isNegated()); | newFilter.setNegate(isNegated()); | ||||
| newFilter | |||||
| .setCaseSensitive(!RegexpUtil.hasFlag(regexpOptions, | |||||
| Regexp.MATCH_CASE_INSENSITIVE) | |||||
| ); | |||||
| newFilter.setCaseSensitive(!RegexpUtil.hasFlag(regexpOptions, | |||||
| Regexp.MATCH_CASE_INSENSITIVE)); | |||||
| return newFilter; | return newFilter; | ||||
| } | } | ||||
| @@ -139,7 +139,6 @@ public final class StripJavaComments | |||||
| */ | */ | ||||
| public Reader chain(final Reader rdr) { | public Reader chain(final Reader rdr) { | ||||
| StripJavaComments newFilter = new StripJavaComments(rdr); | |||||
| return newFilter; | |||||
| return new StripJavaComments(rdr); | |||||
| } | } | ||||
| } | } | ||||
| @@ -46,14 +46,12 @@ public final class JavaClassHelper { | |||||
| final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
| final ByteArrayInputStream bis = new ByteArrayInputStream(bytes); | final ByteArrayInputStream bis = new ByteArrayInputStream(bytes); | ||||
| final ClassParser parser = new ClassParser(bis, ""); | final ClassParser parser = new ClassParser(bis, ""); | ||||
| final JavaClass javaClass = parser.parse(); | |||||
| final Field[] fields = javaClass.getFields(); | |||||
| for (final Field field : fields) { | |||||
| for (final Field field : parser.parse().getFields()) { | |||||
| if (field != null) { | if (field != null) { | ||||
| final ConstantValue cv = field.getConstantValue(); | final ConstantValue cv = field.getConstantValue(); | ||||
| if (cv != null) { | if (cv != null) { | ||||
| String cvs = cv.toString(); | String cvs = cv.toString(); | ||||
| //Remove start and end quotes if field is a String | |||||
| // Remove start and end quotes if field is a String | |||||
| if (cvs.startsWith("\"") && cvs.endsWith("\"")) { | if (cvs.startsWith("\"") && cvs.endsWith("\"")) { | ||||
| cvs = cvs.substring(1, cvs.length() - 1); | cvs = cvs.substring(1, cvs.length() - 1); | ||||
| } | } | ||||
| @@ -274,12 +274,10 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| + uri + (zf != null ? " from a zip file" : ""), | + uri + (zf != null ? " from a zip file" : ""), | ||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| DefaultHandler hb = handler; | |||||
| parser.setContentHandler(hb); | |||||
| parser.setEntityResolver(hb); | |||||
| parser.setErrorHandler(hb); | |||||
| parser.setDTDHandler(hb); | |||||
| parser.setContentHandler(handler); | |||||
| parser.setEntityResolver(handler); | |||||
| parser.setErrorHandler(handler); | |||||
| parser.setDTDHandler(handler); | |||||
| parser.parse(inputSource); | parser.parse(inputSource); | ||||
| } catch (SAXParseException exc) { | } catch (SAXParseException exc) { | ||||
| Location location = new Location(exc.getSystemId(), exc.getLineNumber(), exc | Location location = new Location(exc.getSystemId(), exc.getLineNumber(), exc | ||||
| @@ -603,8 +601,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| @Override | @Override | ||||
| public void endElement(String uri, String name, String qName) throws SAXException { | public void endElement(String uri, String name, String qName) throws SAXException { | ||||
| currentHandler.onEndElement(uri, name, context); | currentHandler.onEndElement(uri, name, context); | ||||
| AntHandler prev = antHandlers.pop(); | |||||
| currentHandler = prev; | |||||
| currentHandler = antHandlers.pop(); | |||||
| if (currentHandler != null) { | if (currentHandler != null) { | ||||
| currentHandler.onEndChild(uri, name, qName, context); | currentHandler.onEndChild(uri, name, qName, context); | ||||
| } | } | ||||
| @@ -729,45 +726,49 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| if (attrUri != null && !attrUri.isEmpty() && !attrUri.equals(uri)) { | if (attrUri != null && !attrUri.isEmpty() && !attrUri.equals(uri)) { | ||||
| continue; // Ignore attributes from unknown uris | continue; // Ignore attributes from unknown uris | ||||
| } | } | ||||
| String key = attrs.getLocalName(i); | |||||
| String value = attrs.getValue(i); | String value = attrs.getValue(i); | ||||
| if ("default".equals(key)) { | |||||
| if (value != null && !value.isEmpty()) { | |||||
| if (!context.isIgnoringProjectTag()) { | |||||
| project.setDefault(value); | |||||
| switch (attrs.getLocalName(i)) { | |||||
| case "default": | |||||
| if (value != null && !value.isEmpty()) { | |||||
| if (!context.isIgnoringProjectTag()) { | |||||
| project.setDefault(value); | |||||
| } | |||||
| } | } | ||||
| } | |||||
| } else if ("name".equals(key)) { | |||||
| if (value != null) { | |||||
| context.setCurrentProjectName(value); | |||||
| nameAttributeSet = true; | |||||
| if (!context.isIgnoringProjectTag()) { | |||||
| project.setName(value); | |||||
| project.addReference(value, project); | |||||
| } else if (isInIncludeMode()) { | |||||
| if (!"".equals(value) && getCurrentTargetPrefix()!= null && getCurrentTargetPrefix().endsWith(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX)) { | |||||
| String newTargetPrefix = getCurrentTargetPrefix().replace(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX, value); | |||||
| // help nested include tasks | |||||
| setCurrentTargetPrefix(newTargetPrefix); | |||||
| break; | |||||
| case "name": | |||||
| if (value != null) { | |||||
| context.setCurrentProjectName(value); | |||||
| nameAttributeSet = true; | |||||
| if (!context.isIgnoringProjectTag()) { | |||||
| project.setName(value); | |||||
| project.addReference(value, project); | |||||
| } else if (isInIncludeMode()) { | |||||
| if (!value.isEmpty() && getCurrentTargetPrefix() != null | |||||
| && getCurrentTargetPrefix().endsWith(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX)) { | |||||
| String newTargetPrefix = getCurrentTargetPrefix().replace(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX, value); | |||||
| // help nested include tasks | |||||
| setCurrentTargetPrefix(newTargetPrefix); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | |||||
| } else if ("id".equals(key)) { | |||||
| if (value != null) { | |||||
| // What's the difference between id and name ? | |||||
| break; | |||||
| case "id": | |||||
| if (value != null) { | |||||
| // What's the difference between id and name ? | |||||
| if (!context.isIgnoringProjectTag()) { | |||||
| project.addReference(value, project); | |||||
| } | |||||
| } | |||||
| break; | |||||
| case "basedir": | |||||
| if (!context.isIgnoringProjectTag()) { | if (!context.isIgnoringProjectTag()) { | ||||
| project.addReference(value, project); | |||||
| baseDir = value; | |||||
| } | } | ||||
| } | |||||
| } else if ("basedir".equals(key)) { | |||||
| if (!context.isIgnoringProjectTag()) { | |||||
| baseDir = value; | |||||
| } | |||||
| } else { | |||||
| // TODO ignore attributes in a different NS ( maybe store them ? ) | |||||
| throw new SAXParseException("Unexpected attribute \"" + attrs.getQName(i) | |||||
| + "\"", context.getLocator()); | |||||
| break; | |||||
| default: | |||||
| // TODO ignore attributes in a different NS ( maybe store them ? ) | |||||
| throw new SAXParseException("Unexpected attribute \"" + attrs.getQName(i) | |||||
| + "\"", context.getLocator()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -914,37 +915,44 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| if (attrUri != null && !attrUri.isEmpty() && !attrUri.equals(uri)) { | if (attrUri != null && !attrUri.isEmpty() && !attrUri.equals(uri)) { | ||||
| continue; // Ignore attributes from unknown uris | continue; // Ignore attributes from unknown uris | ||||
| } | } | ||||
| String key = attrs.getLocalName(i); | |||||
| String value = attrs.getValue(i); | String value = attrs.getValue(i); | ||||
| if ("name".equals(key)) { | |||||
| name = value; | |||||
| if (name.isEmpty()) { | |||||
| throw new BuildException("name attribute must " + "not be empty"); | |||||
| } | |||||
| } else if ("depends".equals(key)) { | |||||
| depends = value; | |||||
| } else if ("if".equals(key)) { | |||||
| target.setIf(value); | |||||
| } else if ("unless".equals(key)) { | |||||
| target.setUnless(value); | |||||
| } else if ("id".equals(key)) { | |||||
| if (value != null && !value.isEmpty()) { | |||||
| context.getProject().addReference(value, target); | |||||
| } | |||||
| } else if ("description".equals(key)) { | |||||
| target.setDescription(value); | |||||
| } else if ("extensionOf".equals(key)) { | |||||
| extensionPoint = value; | |||||
| } else if ("onMissingExtensionPoint".equals(key)) { | |||||
| try { | |||||
| extensionPointMissing = OnMissingExtensionPoint.valueOf(value); | |||||
| } catch (IllegalArgumentException e) { | |||||
| throw new BuildException("Invalid onMissingExtensionPoint " + value); | |||||
| } | |||||
| } else { | |||||
| throw new SAXParseException("Unexpected attribute \"" + key + "\"", context | |||||
| .getLocator()); | |||||
| switch (attrs.getLocalName(i)) { | |||||
| case "name": | |||||
| name = value; | |||||
| if (name.isEmpty()) { | |||||
| throw new BuildException("name attribute must not be empty"); | |||||
| } | |||||
| break; | |||||
| case "depends": | |||||
| depends = value; | |||||
| break; | |||||
| case "if": | |||||
| target.setIf(value); | |||||
| break; | |||||
| case "unless": | |||||
| target.setUnless(value); | |||||
| break; | |||||
| case "id": | |||||
| if (value != null && !value.isEmpty()) { | |||||
| context.getProject().addReference(value, target); | |||||
| } | |||||
| break; | |||||
| case "description": | |||||
| target.setDescription(value); | |||||
| break; | |||||
| case "extensionOf": | |||||
| extensionPoint = value; | |||||
| break; | |||||
| case "onMissingExtensionPoint": | |||||
| try { | |||||
| extensionPointMissing = OnMissingExtensionPoint.valueOf(value); | |||||
| } catch (IllegalArgumentException e) { | |||||
| throw new BuildException("Invalid onMissingExtensionPoint " + value); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| throw new SAXParseException("Unexpected attribute \"" + attrs.getQName(i) | |||||
| + "\"", context.getLocator()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -389,19 +389,22 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| for (int i = 0; i < attrs.getLength(); i++) { | for (int i = 0; i < attrs.getLength(); i++) { | ||||
| String key = attrs.getName(i); | String key = attrs.getName(i); | ||||
| String value = attrs.getValue(i); | String value = attrs.getValue(i); | ||||
| if ("default".equals(key)) { | |||||
| def = value; | |||||
| } else if ("name".equals(key)) { | |||||
| name = value; | |||||
| } else if ("id".equals(key)) { | |||||
| id = value; | |||||
| } else if ("basedir".equals(key)) { | |||||
| baseDir = value; | |||||
| } else { | |||||
| throw new SAXParseException( | |||||
| "Unexpected attribute \"" + attrs.getName(i) | |||||
| + "\"", helperImpl.locator); | |||||
| switch (key) { | |||||
| case "default": | |||||
| def = value; | |||||
| break; | |||||
| case "name": | |||||
| name = value; | |||||
| break; | |||||
| case "id": | |||||
| id = value; | |||||
| break; | |||||
| case "basedir": | |||||
| baseDir = value; | |||||
| break; | |||||
| default: | |||||
| throw new SAXParseException("Unexpected attribute \"" + attrs.getName(i) | |||||
| + "\"", helperImpl.locator); | |||||
| } | } | ||||
| } | } | ||||
| @@ -525,26 +528,32 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| for (int i = 0; i < attrs.getLength(); i++) { | for (int i = 0; i < attrs.getLength(); i++) { | ||||
| String key = attrs.getName(i); | String key = attrs.getName(i); | ||||
| String value = attrs.getValue(i); | String value = attrs.getValue(i); | ||||
| if ("name".equals(key)) { | |||||
| name = value; | |||||
| if (name.isEmpty()) { | |||||
| throw new BuildException("name attribute must not" + " be empty", | |||||
| new Location(helperImpl.locator)); | |||||
| } | |||||
| } else if ("depends".equals(key)) { | |||||
| depends = value; | |||||
| } else if ("if".equals(key)) { | |||||
| ifCond = value; | |||||
| } else if ("unless".equals(key)) { | |||||
| unlessCond = value; | |||||
| } else if ("id".equals(key)) { | |||||
| id = value; | |||||
| } else if ("description".equals(key)) { | |||||
| description = value; | |||||
| } else { | |||||
| throw new SAXParseException("Unexpected attribute \"" + key + "\"", | |||||
| helperImpl.locator); | |||||
| switch (key) { | |||||
| case "name": | |||||
| name = value; | |||||
| if (name.isEmpty()) { | |||||
| throw new BuildException("name attribute must not be empty", | |||||
| new Location(helperImpl.locator)); | |||||
| } | |||||
| break; | |||||
| case "depends": | |||||
| depends = value; | |||||
| break; | |||||
| case "if": | |||||
| ifCond = value; | |||||
| break; | |||||
| case "unless": | |||||
| unlessCond = value; | |||||
| break; | |||||
| case "id": | |||||
| id = value; | |||||
| break; | |||||
| case "description": | |||||
| description = value; | |||||
| break; | |||||
| default: | |||||
| throw new SAXParseException("Unexpected attribute \"" + key + "\"", | |||||
| helperImpl.locator); | |||||
| } | } | ||||
| } | } | ||||
| @@ -348,19 +348,16 @@ public class AntStructure extends Task { | |||||
| sb.append(LINE_SEP).append(" ") | sb.append(LINE_SEP).append(" ") | ||||
| .append(attrName).append(" "); | .append(attrName).append(" "); | ||||
| final Class<?> type = ih.getAttributeType(attrName); | final Class<?> type = ih.getAttributeType(attrName); | ||||
| if (type.equals(Boolean.class) | |||||
| || type.equals(Boolean.TYPE)) { | |||||
| if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) { | |||||
| sb.append(BOOLEAN).append(" "); | sb.append(BOOLEAN).append(" "); | ||||
| } else if (Reference.class.isAssignableFrom(type)) { | } else if (Reference.class.isAssignableFrom(type)) { | ||||
| sb.append("IDREF "); | sb.append("IDREF "); | ||||
| } else if (EnumeratedAttribute.class.isAssignableFrom(type)) { | } else if (EnumeratedAttribute.class.isAssignableFrom(type)) { | ||||
| try { | try { | ||||
| final EnumeratedAttribute ea = | final EnumeratedAttribute ea = | ||||
| type.asSubclass(EnumeratedAttribute.class) | |||||
| .newInstance(); | |||||
| type.asSubclass(EnumeratedAttribute.class).newInstance(); | |||||
| final String[] values = ea.getValues(); | final String[] values = ea.getValues(); | ||||
| if (values == null | |||||
| || values.length == 0 | |||||
| if (values == null || values.length == 0 | |||||
| || !areNmtokens(values)) { | || !areNmtokens(values)) { | ||||
| sb.append("CDATA "); | sb.append("CDATA "); | ||||
| } else { | } else { | ||||
| @@ -595,7 +595,7 @@ public class Concat extends Task implements ResourceCollection { | |||||
| */ | */ | ||||
| @Deprecated | @Deprecated | ||||
| public void setForce(boolean forceOverwrite) { | public void setForce(boolean forceOverwrite) { | ||||
| this.forceOverwrite = forceOverwrite; | |||||
| setOverwrite(forceOverwrite); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -606,7 +606,7 @@ public class Concat extends Task implements ResourceCollection { | |||||
| * @since Ant 1.8.2 | * @since Ant 1.8.2 | ||||
| */ | */ | ||||
| public void setOverwrite(boolean forceOverwrite) { | public void setOverwrite(boolean forceOverwrite) { | ||||
| setForce(forceOverwrite); | |||||
| this.forceOverwrite = forceOverwrite; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -923,11 +923,8 @@ public class Concat extends Task implements ResourceCollection { | |||||
| } | } | ||||
| private boolean isUpToDate(ResourceCollection c) { | private boolean isUpToDate(ResourceCollection c) { | ||||
| if (dest == null || forceOverwrite) { | |||||
| return false; | |||||
| } | |||||
| return c.stream().noneMatch(r -> SelectorUtils.isOutOfDate(r, dest, | |||||
| FILE_UTILS.getFileTimestampGranularity())); | |||||
| return dest != null && !forceOverwrite | |||||
| && c.stream().noneMatch(r -> SelectorUtils.isOutOfDate(r, dest, FILE_UTILS.getFileTimestampGranularity())); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -270,7 +270,6 @@ public class Expand extends Task { | |||||
| String name = entryName.replace('/', File.separatorChar) | String name = entryName.replace('/', File.separatorChar) | ||||
| .replace('\\', File.separatorChar); | .replace('\\', File.separatorChar); | ||||
| boolean included = false; | |||||
| Set<String> includePatterns = new HashSet<>(); | Set<String> includePatterns = new HashSet<>(); | ||||
| Set<String> excludePatterns = new HashSet<>(); | Set<String> excludePatterns = new HashSet<>(); | ||||
| for (PatternSet p : patternsets) { | for (PatternSet p : patternsets) { | ||||
| @@ -302,20 +301,23 @@ public class Expand extends Task { | |||||
| } | } | ||||
| } | } | ||||
| for (Iterator<String> iter = includePatterns.iterator(); | |||||
| !included && iter.hasNext();) { | |||||
| String pattern = iter.next(); | |||||
| included = SelectorUtils.matchPath(pattern, name); | |||||
| boolean included = false; | |||||
| for (String pattern : includePatterns) { | |||||
| if (SelectorUtils.matchPath(pattern, name)) { | |||||
| included = true; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| for (Iterator<String> iter = excludePatterns.iterator(); | |||||
| included && iter.hasNext();) { | |||||
| String pattern = iter.next(); | |||||
| included = !SelectorUtils.matchPath(pattern, name); | |||||
| for (String pattern : excludePatterns) { | |||||
| if (SelectorUtils.matchPath(pattern, name)) { | |||||
| included = false; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| if (!included) { | if (!included) { | ||||
| //Do not process this file | |||||
| // Do not process this file | |||||
| log("skipping " + entryName | log("skipping " + entryName | ||||
| + " as it is excluded or not included.", | + " as it is excluded or not included.", | ||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| @@ -28,6 +28,8 @@ import java.net.URL; | |||||
| import java.net.URLConnection; | import java.net.URLConnection; | ||||
| import java.nio.file.Files; | import java.nio.file.Files; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| import java.util.zip.GZIPInputStream; | import java.util.zip.GZIPInputStream; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -46,9 +48,6 @@ import org.apache.tools.ant.util.FileNameMapper; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.StringUtils; | import org.apache.tools.ant.util.StringUtils; | ||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * Gets a particular file from a URL source. | * Gets a particular file from a URL source. | ||||
| * Options include verbose reporting, timestamp based fetches and controlling | * Options include verbose reporting, timestamp based fetches and controlling | ||||
| @@ -834,7 +834,7 @@ public class Javac extends MatchingTask { | |||||
| * @return whether or not the ant classpath is to be included in the classpath | * @return whether or not the ant classpath is to be included in the classpath | ||||
| */ | */ | ||||
| public boolean getIncludeantruntime() { | public boolean getIncludeantruntime() { | ||||
| return includeAntRuntime != null ? includeAntRuntime : true; | |||||
| return includeAntRuntime == null || includeAntRuntime; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1509,10 +1509,10 @@ public class Javac extends MatchingTask { | |||||
| * @return a mapping from module name to module source roots | * @return a mapping from module name to module source roots | ||||
| * @since 1.9.7 | * @since 1.9.7 | ||||
| */ | */ | ||||
| private static Map<String,Collection<File>> resolveModuleSourcePathElement( | |||||
| private static Map<String, Collection<File>> resolveModuleSourcePathElement( | |||||
| final File projectDir, | final File projectDir, | ||||
| final String element) { | final String element) { | ||||
| final Map<String,Collection<File>> result = new TreeMap<>(); | |||||
| final Map<String, Collection<File>> result = new TreeMap<>(); | |||||
| for (CharSequence resolvedElement : expandGroups(element)) { | for (CharSequence resolvedElement : expandGroups(element)) { | ||||
| findModules(projectDir, resolvedElement.toString(), result); | findModules(projectDir, resolvedElement.toString(), result); | ||||
| } | } | ||||
| @@ -193,12 +193,8 @@ public class Manifest { | |||||
| Attribute rhsAttribute = (Attribute) rhs; | Attribute rhsAttribute = (Attribute) rhs; | ||||
| String lhsKey = getKey(); | String lhsKey = getKey(); | ||||
| String rhsKey = rhsAttribute.getKey(); | String rhsKey = rhsAttribute.getKey(); | ||||
| if ((lhsKey == null && rhsKey != null) | |||||
| || (lhsKey != null && !lhsKey.equals(rhsKey))) { | |||||
| return false; | |||||
| } | |||||
| return values.equals(rhsAttribute.values); | |||||
| return (lhsKey != null || rhsKey == null) | |||||
| && (lhsKey == null || lhsKey.equals(rhsKey)) && values.equals(rhsAttribute.values); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -243,10 +239,7 @@ public class Manifest { | |||||
| * @return the attribute's key. | * @return the attribute's key. | ||||
| */ | */ | ||||
| public String getKey() { | public String getKey() { | ||||
| if (name == null) { | |||||
| return null; | |||||
| } | |||||
| return name.toLowerCase(Locale.ENGLISH); | |||||
| return name == null ? null : name.toLowerCase(Locale.ENGLISH); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -302,8 +295,7 @@ public class Manifest { | |||||
| * @param line the continuation line. | * @param line the continuation line. | ||||
| */ | */ | ||||
| public void addContinuation(String line) { | public void addContinuation(String line) { | ||||
| String currentValue = values.elementAt(currentIndex); | |||||
| setValue(currentValue + line.substring(1)); | |||||
| setValue(values.elementAt(currentIndex) + line.substring(1)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -607,10 +599,7 @@ public class Manifest { | |||||
| */ | */ | ||||
| public String getAttributeValue(String attributeName) { | public String getAttributeValue(String attributeName) { | ||||
| Attribute attribute = getAttribute(attributeName.toLowerCase(Locale.ENGLISH)); | Attribute attribute = getAttribute(attributeName.toLowerCase(Locale.ENGLISH)); | ||||
| if (attribute == null) { | |||||
| return null; | |||||
| } | |||||
| return attribute.getValue(); | |||||
| return attribute == null ? null : attribute.getValue(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -723,8 +712,7 @@ public class Manifest { | |||||
| if (attribute == null) { | if (attribute == null) { | ||||
| return; | return; | ||||
| } | } | ||||
| String attributeKey = attribute.getKey(); | |||||
| attributes.put(attributeKey, attribute); | |||||
| attributes.put(attribute.getKey(), attribute); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1113,11 +1101,8 @@ public class Manifest { | |||||
| return false; | return false; | ||||
| } | } | ||||
| if (!mainSection.equals(rhsManifest.mainSection)) { | |||||
| return false; | |||||
| } | |||||
| return mainSection.equals(rhsManifest.mainSection) && sections.equals(rhsManifest.sections); | |||||
| return sections.equals(rhsManifest.sections); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -310,8 +310,7 @@ public class Recorder extends Task implements SubBuildListener { | |||||
| Hashtable<String, RecorderEntry> entries | Hashtable<String, RecorderEntry> entries | ||||
| = (Hashtable<String, RecorderEntry>) recorderEntries.clone(); | = (Hashtable<String, RecorderEntry>) recorderEntries.clone(); | ||||
| for (Map.Entry<String, RecorderEntry> entry : entries.entrySet()) { | for (Map.Entry<String, RecorderEntry> entry : entries.entrySet()) { | ||||
| RecorderEntry re = entry.getValue(); | |||||
| if (re.getProject() == getProject()) { | |||||
| if (entry.getValue().getProject() == getProject()) { | |||||
| recorderEntries.remove(entry.getKey()); | recorderEntries.remove(entry.getKey()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -286,7 +286,7 @@ public class Replace extends MatchingTask { | |||||
| * The filter expects from the component providing the input that data | * The filter expects from the component providing the input that data | ||||
| * is only added by that component to the end of this StringBuffer. | * is only added by that component to the end of this StringBuffer. | ||||
| * This StringBuffer will be modified by this filter, and expects that | * This StringBuffer will be modified by this filter, and expects that | ||||
| * another component will only added to this StringBuffer. | |||||
| * another component will only append to this StringBuffer. | |||||
| * @param input The input for this filter. | * @param input The input for this filter. | ||||
| */ | */ | ||||
| void setInputBuffer(StringBuffer input) { | void setInputBuffer(StringBuffer input) { | ||||
| @@ -775,10 +775,7 @@ public class Rmic extends MatchingTask { | |||||
| try { | try { | ||||
| Class<?> testClass = loader.loadClass(classname); | Class<?> testClass = loader.loadClass(classname); | ||||
| // One cannot RMIC an interface for "classic" RMI (JRMP) | // One cannot RMIC an interface for "classic" RMI (JRMP) | ||||
| if (testClass.isInterface() && !iiop && !idl) { | |||||
| return false; | |||||
| } | |||||
| return isValidRmiRemote(testClass); | |||||
| return (!testClass.isInterface() || iiop || idl) && isValidRmiRemote(testClass); | |||||
| } catch (ClassNotFoundException e) { | } catch (ClassNotFoundException e) { | ||||
| log(ERROR_UNABLE_TO_VERIFY_CLASS + classname + ERROR_NOT_FOUND, | log(ERROR_UNABLE_TO_VERIFY_CLASS + classname + ERROR_NOT_FOUND, | ||||
| Project.MSG_WARN); | Project.MSG_WARN); | ||||
| @@ -24,7 +24,6 @@ import java.util.List; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.DirectoryScanner; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | import org.apache.tools.ant.taskdefs.condition.Condition; | ||||
| @@ -205,11 +204,12 @@ public class UpToDate extends Task implements Condition { | |||||
| // scan all filesets, even if we know the target is out of | // scan all filesets, even if we know the target is out of | ||||
| // date after the first test. | // date after the first test. | ||||
| Iterator<FileSet> iter = sourceFileSets.iterator(); | |||||
| while (upToDate && iter.hasNext()) { | |||||
| FileSet fs = iter.next(); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner(getProject()); | |||||
| upToDate = scanDir(fs.getDir(getProject()), ds.getIncludedFiles()); | |||||
| for (FileSet fs : sourceFileSets) { | |||||
| if (!scanDir(fs.getDir(getProject()), | |||||
| fs.getDirectoryScanner(getProject()).getIncludedFiles())) { | |||||
| upToDate = false; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| if (upToDate) { | if (upToDate) { | ||||
| @@ -696,8 +696,7 @@ public abstract class DefaultCompilerAdapter | |||||
| */ | */ | ||||
| @Deprecated | @Deprecated | ||||
| protected boolean assumeJava19() { | protected boolean assumeJava19() { | ||||
| return assumeJavaXY("javac1.9", JavaEnvUtils.JAVA_9) | |||||
| || assumeJavaXY("javac9", JavaEnvUtils.JAVA_9); | |||||
| return assumeJava9(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -706,7 +705,8 @@ public abstract class DefaultCompilerAdapter | |||||
| * @since Ant 1.9.8 | * @since Ant 1.9.8 | ||||
| */ | */ | ||||
| protected boolean assumeJava9() { | protected boolean assumeJava9() { | ||||
| return assumeJava19(); | |||||
| return assumeJavaXY("javac1.9", JavaEnvUtils.JAVA_9) | |||||
| || assumeJavaXY("javac9", JavaEnvUtils.JAVA_9); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -60,31 +60,26 @@ public class IsReference extends ProjectComponent implements Condition { | |||||
| public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
| if (ref == null) { | if (ref == null) { | ||||
| throw new BuildException( | throw new BuildException( | ||||
| "No reference specified for isreference condition"); | |||||
| "No reference specified for isreference condition"); | |||||
| } | } | ||||
| String key = ref.getRefId(); | String key = ref.getRefId(); | ||||
| if (!getProject().hasReference(key)) { | if (!getProject().hasReference(key)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (type == null) { | if (type == null) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| Object o = getProject().getReference(key); | |||||
| Class<?> typeClass = | |||||
| getProject().getDataTypeDefinitions().get(type); | |||||
| Class<?> typeClass = getProject().getDataTypeDefinitions().get(type); | |||||
| if (typeClass == null) { | if (typeClass == null) { | ||||
| typeClass = | |||||
| getProject().getTaskDefinitions().get(type); | |||||
| typeClass = getProject().getTaskDefinitions().get(type); | |||||
| } | } | ||||
| if (typeClass == null) { | |||||
| // don't know the type, should throw exception instead? | |||||
| return false; | |||||
| } | |||||
| // if the type is unknown, throw exception instead? | |||||
| return typeClass != null | |||||
| && typeClass.isAssignableFrom(getProject().getReference(key).getClass()); | |||||
| return typeClass.isAssignableFrom(o.getClass()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -18,6 +18,7 @@ | |||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import java.io.File; | |||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -34,8 +35,7 @@ public class Os implements Condition { | |||||
| System.getProperty("os.arch").toLowerCase(Locale.ENGLISH); | System.getProperty("os.arch").toLowerCase(Locale.ENGLISH); | ||||
| private static final String OS_VERSION = | private static final String OS_VERSION = | ||||
| System.getProperty("os.version").toLowerCase(Locale.ENGLISH); | System.getProperty("os.version").toLowerCase(Locale.ENGLISH); | ||||
| private static final String PATH_SEP = | |||||
| System.getProperty("path.separator"); | |||||
| private static final String PATH_SEP = File.pathSeparator; | |||||
| /** | /** | ||||
| * OS family that can be tested for. {@value} | * OS family that can be tested for. {@value} | ||||
| @@ -924,7 +924,7 @@ public class NetRexxC extends MatchingTask { | |||||
| */ | */ | ||||
| private void addExistingToClasspath(StringBuilder target, String source) { | private void addExistingToClasspath(StringBuilder target, String source) { | ||||
| StringTokenizer tok = new StringTokenizer(source, | StringTokenizer tok = new StringTokenizer(source, | ||||
| System.getProperty("path.separator"), false); | |||||
| File.pathSeparator, false); | |||||
| while (tok.hasMoreTokens()) { | while (tok.hasMoreTokens()) { | ||||
| File f = getProject().resolveFile(tok.nextToken()); | File f = getProject().resolveFile(tok.nextToken()); | ||||
| @@ -467,14 +467,9 @@ public class SchemaValidate extends XMLValidateTask { | |||||
| final SchemaLocation schemaLocation = (SchemaLocation) o; | final SchemaLocation schemaLocation = (SchemaLocation) o; | ||||
| if (file != null ? !file.equals(schemaLocation.file) : schemaLocation.file != null) { | |||||
| return false; | |||||
| } | |||||
| if (namespace != null ? !namespace.equals(schemaLocation.namespace) | |||||
| : schemaLocation.namespace != null) { | |||||
| return false; | |||||
| } | |||||
| return url != null ? url.equals(schemaLocation.url) : schemaLocation.url == null; | |||||
| return (file == null ? schemaLocation.file == null : file.equals(schemaLocation.file)) | |||||
| && (namespace == null ? schemaLocation.namespace == null : namespace.equals(schemaLocation.namespace)) | |||||
| && (url == null ? schemaLocation.url == null : url.equals(schemaLocation.url)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -485,9 +480,9 @@ public class SchemaValidate extends XMLValidateTask { | |||||
| public int hashCode() { | public int hashCode() { | ||||
| int result; | int result; | ||||
| // CheckStyle:MagicNumber OFF | // CheckStyle:MagicNumber OFF | ||||
| result = (namespace != null ? namespace.hashCode() : 0); | |||||
| result = 29 * result + (file != null ? file.hashCode() : 0); | |||||
| result = 29 * result + (url != null ? url.hashCode() : 0); | |||||
| result = (namespace == null ? 0 : namespace.hashCode()); | |||||
| result = 29 * result + (file == null ? 0 : file.hashCode()); | |||||
| result = 29 * result + (url == null ? 0 : url.hashCode()); | |||||
| // CheckStyle:MagicNumber OFF | // CheckStyle:MagicNumber OFF | ||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -499,10 +494,9 @@ public class SchemaValidate extends XMLValidateTask { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public String toString() { | public String toString() { | ||||
| String buffer = (namespace != null ? namespace : "(anonymous)") | |||||
| + ' ' + (url != null ? (url + " ") : "") | |||||
| + (file != null ? file.getAbsolutePath() : ""); | |||||
| return buffer; | |||||
| return (namespace == null ? "(anonymous)" : namespace) | |||||
| + (url == null ? "" : " " + url) | |||||
| + (file == null ? "" : " " + file.getAbsolutePath()); | |||||
| } | } | ||||
| } //SchemaLocation | |||||
| } | |||||
| } | } | ||||
| @@ -20,11 +20,11 @@ package org.apache.tools.ant.taskdefs.optional.depend; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Collections; | import java.util.Collections; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Set; | import java.util.Set; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.zip.ZipEntry; | import java.util.zip.ZipEntry; | ||||
| import java.util.zip.ZipFile; | import java.util.zip.ZipFile; | ||||
| @@ -812,11 +812,7 @@ public class IPlanetEjbc { | |||||
| String base = "\\ejb-jar\\enterprise-beans\\" + ejbType; | String base = "\\ejb-jar\\enterprise-beans\\" + ejbType; | ||||
| if ((base + "\\ejb-name").equals(currentLoc)) { | if ((base + "\\ejb-name").equals(currentLoc)) { | ||||
| currentEjb = ejbs.get(value); | |||||
| if (currentEjb == null) { | |||||
| currentEjb = new EjbInfo(value); | |||||
| ejbs.put(value, currentEjb); | |||||
| } | |||||
| currentEjb = ejbs.computeIfAbsent(value, EjbInfo::new); | |||||
| } else if ((base + "\\home").equals(currentLoc)) { | } else if ((base + "\\home").equals(currentLoc)) { | ||||
| currentEjb.setHome(value); | currentEjb.setHome(value); | ||||
| } else if ((base + "\\remote").equals(currentLoc)) { | } else if ((base + "\\remote").equals(currentLoc)) { | ||||
| @@ -846,18 +842,13 @@ public class IPlanetEjbc { | |||||
| String base = "\\ias-ejb-jar\\enterprise-beans\\" + ejbType; | String base = "\\ias-ejb-jar\\enterprise-beans\\" + ejbType; | ||||
| if ((base + "\\ejb-name").equals(currentLoc)) { | if ((base + "\\ejb-name").equals(currentLoc)) { | ||||
| currentEjb = ejbs.get(value); | |||||
| if (currentEjb == null) { | |||||
| currentEjb = new EjbInfo(value); | |||||
| ejbs.put(value, currentEjb); | |||||
| } | |||||
| currentEjb = ejbs.computeIfAbsent(value, EjbInfo::new); | |||||
| } else if ((base + "\\iiop").equals(currentLoc)) { | } else if ((base + "\\iiop").equals(currentLoc)) { | ||||
| currentEjb.setIiop(value); | currentEjb.setIiop(value); | ||||
| } else if ((base + "\\failover-required").equals(currentLoc)) { | } else if ((base + "\\failover-required").equals(currentLoc)) { | ||||
| currentEjb.setHasession(value); | currentEjb.setHasession(value); | ||||
| } else if ((base | } else if ((base | ||||
| + "\\persistence-manager\\properties-file-location") | |||||
| .equals(currentLoc)) { | |||||
| + "\\persistence-manager\\properties-file-location").equals(currentLoc)) { | |||||
| currentEjb.addCmpDescriptor(value); | currentEjb.addCmpDescriptor(value); | ||||
| } | } | ||||
| } | } | ||||
| @@ -869,15 +860,15 @@ public class IPlanetEjbc { | |||||
| * | * | ||||
| */ | */ | ||||
| private class EjbInfo { | private class EjbInfo { | ||||
| private String name; // EJB's display name | |||||
| private Classname home; // EJB's home interface name | |||||
| private Classname remote; // EJB's remote interface name | |||||
| private Classname implementation; // EJB's implementation class | |||||
| private Classname primaryKey; // EJB's primary key class | |||||
| private String beantype = "entity"; // or "stateful" or "stateless" | |||||
| private boolean cmp = false; // Does this EJB support CMP? | |||||
| private boolean iiop = false; // Does this EJB support IIOP? | |||||
| private boolean hasession = false; // Does this EJB require failover? | |||||
| private String name; // EJB's display name | |||||
| private Classname home; // EJB's home interface name | |||||
| private Classname remote; // EJB's remote interface name | |||||
| private Classname implementation; // EJB's implementation class | |||||
| private Classname primaryKey; // EJB's primary key class | |||||
| private String beantype = "entity"; // or "stateful" or "stateless" | |||||
| private boolean cmp = false; // Does this EJB support CMP? | |||||
| private boolean iiop = false; // Does this EJB support IIOP? | |||||
| private boolean hasession = false; // Does this EJB require failover? | |||||
| private List<String> cmpDescriptors = new ArrayList<>(); // CMP descriptor list | private List<String> cmpDescriptors = new ArrayList<>(); // CMP descriptor list | ||||
| /** | /** | ||||
| @@ -129,8 +129,7 @@ public class ClassNameReader { | |||||
| /* int accessFlags = */ data.readUnsignedShort(); | /* int accessFlags = */ data.readUnsignedShort(); | ||||
| int classIndex = data.readUnsignedShort(); | int classIndex = data.readUnsignedShort(); | ||||
| Integer stringIndex = (Integer) values[classIndex]; | Integer stringIndex = (Integer) values[classIndex]; | ||||
| String className = (String) values[stringIndex]; | |||||
| return className; | |||||
| return (String) values[stringIndex]; | |||||
| } | } | ||||
| } | } | ||||
| @@ -1429,10 +1429,8 @@ public class JUnitTask extends Task { | |||||
| * @return created file | * @return created file | ||||
| */ | */ | ||||
| private File createTempPropertiesFile(final String prefix) { | private File createTempPropertiesFile(final String prefix) { | ||||
| final File propsFile = | |||||
| FILE_UTILS.createTempFile(prefix, ".properties", | |||||
| tmpDir != null ? tmpDir : getProject().getBaseDir(), true, true); | |||||
| return propsFile; | |||||
| return FILE_UTILS.createTempFile(prefix, ".properties", | |||||
| tmpDir != null ? tmpDir : getProject().getBaseDir(), true, true); | |||||
| } | } | ||||
| @@ -1701,8 +1699,8 @@ public class JUnitTask extends Task { | |||||
| * @since 1.9.8 | * @since 1.9.8 | ||||
| */ | */ | ||||
| private void checkModules() { | private void checkModules() { | ||||
| if (hasPath(getCommandline().getModulepath()) || | |||||
| hasPath(getCommandline().getUpgrademodulepath())) { | |||||
| if (hasPath(getCommandline().getModulepath()) | |||||
| || hasPath(getCommandline().getUpgrademodulepath())) { | |||||
| if (!batchTests.stream().allMatch(BaseTest::getFork) | if (!batchTests.stream().allMatch(BaseTest::getFork) | ||||
| || !tests.stream().allMatch(BaseTest::getFork)) { | || !tests.stream().allMatch(BaseTest::getFork)) { | ||||
| throw new BuildException( | throw new BuildException( | ||||
| @@ -60,11 +60,11 @@ public class BuiltinNative2Ascii implements Native2AsciiAdapter { | |||||
| private BufferedReader getReader(File srcFile, String encoding, | private BufferedReader getReader(File srcFile, String encoding, | ||||
| boolean reverse) throws IOException { | boolean reverse) throws IOException { | ||||
| if (!reverse && encoding != null) { | |||||
| return new BufferedReader(new InputStreamReader( | |||||
| Files.newInputStream(srcFile.toPath()), encoding)); | |||||
| if (reverse || encoding == null) { | |||||
| return new BufferedReader(new FileReader(srcFile)); | |||||
| } | } | ||||
| return new BufferedReader(new FileReader(srcFile)); | |||||
| return new BufferedReader(new InputStreamReader( | |||||
| Files.newInputStream(srcFile.toPath()), encoding)); | |||||
| } | } | ||||
| private Writer getWriter(File destFile, String encoding, | private Writer getWriter(File destFile, String encoding, | ||||
| @@ -72,12 +72,12 @@ public class BuiltinNative2Ascii implements Native2AsciiAdapter { | |||||
| if (!reverse) { | if (!reverse) { | ||||
| encoding = "ASCII"; | encoding = "ASCII"; | ||||
| } | } | ||||
| if (encoding != null) { | |||||
| return new BufferedWriter( | |||||
| new OutputStreamWriter(Files.newOutputStream(destFile.toPath()), | |||||
| encoding)); | |||||
| if (encoding == null) { | |||||
| return new BufferedWriter(new FileWriter(destFile)); | |||||
| } | } | ||||
| return new BufferedWriter(new FileWriter(destFile)); | |||||
| return new BufferedWriter( | |||||
| new OutputStreamWriter(Files.newOutputStream(destFile.toPath()), | |||||
| encoding)); | |||||
| } | } | ||||
| private void translate(BufferedReader input, Writer output, | private void translate(BufferedReader input, Writer output, | ||||
| @@ -1202,13 +1202,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
| * @since ant 1.6 | * @since ant 1.6 | ||||
| */ | */ | ||||
| private boolean isFunctioningAsFile(FTPClient ftp, String dir, FTPFile file) { | private boolean isFunctioningAsFile(FTPClient ftp, String dir, FTPFile file) { | ||||
| if (file.isDirectory()) { | |||||
| return false; | |||||
| } | |||||
| if (file.isFile()) { | |||||
| return true; | |||||
| } | |||||
| return !isFunctioningAsDirectory(ftp, dir, file); | |||||
| return !file.isDirectory() && (file.isFile() || !isFunctioningAsDirectory(ftp, dir, file)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1901,8 +1895,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
| * @return the filename as it will appear on the server. | * @return the filename as it will appear on the server. | ||||
| */ | */ | ||||
| protected String resolveFile(String file) { | protected String resolveFile(String file) { | ||||
| return file.replace(System.getProperty("file.separator").charAt(0), | |||||
| remoteFileSep.charAt(0)); | |||||
| return file.replace(File.separator.charAt(0), remoteFileSep.charAt(0)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1280,8 +1280,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||||
| * @return the filename as it will appear on the server. | * @return the filename as it will appear on the server. | ||||
| */ | */ | ||||
| protected String resolveFile(String file) { | protected String resolveFile(String file) { | ||||
| return file.replace(System.getProperty("file.separator").charAt(0), | |||||
| task.getSeparator().charAt(0)); | |||||
| return file.replace(File.separator.charAt(0), task.getSeparator().charAt(0)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -218,7 +218,7 @@ public class SSHExec extends SSHBase { | |||||
| * will be stored. | * will be stored. | ||||
| * @since Apache Ant 1.9.4 | * @since Apache Ant 1.9.4 | ||||
| */ | */ | ||||
| public void setErrorproperty (final String property) { | |||||
| public void setErrorproperty(final String property) { | |||||
| errorProperty = property; | errorProperty = property; | ||||
| } | } | ||||
| @@ -319,9 +319,7 @@ public class ScpFromMessage extends AbstractSshMessage { | |||||
| throw new JSchException("failed to stat remote file", e); | throw new JSchException("failed to stat remote file", e); | ||||
| } | } | ||||
| FileUtils.getFileUtils().setFileLastModified(localFile, | FileUtils.getFileUtils().setFileLastModified(localFile, | ||||
| ((long) fileAttributes | |||||
| .getMTime()) | |||||
| * 1000); | |||||
| ((long) fileAttributes.getMTime()) * 1000); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -132,7 +132,7 @@ public class ScpFromMessageBySftp extends ScpFromMessage { | |||||
| private void getDir(final ChannelSftp channel, | private void getDir(final ChannelSftp channel, | ||||
| final String remoteFile, | final String remoteFile, | ||||
| final File localFile) throws IOException, SftpException { | |||||
| final File localFile) throws SftpException { | |||||
| String pwd = remoteFile; | String pwd = remoteFile; | ||||
| if (remoteFile.lastIndexOf('/') != -1) { | if (remoteFile.lastIndexOf('/') != -1) { | ||||
| if (remoteFile.length() > 1) { | if (remoteFile.length() > 1) { | ||||
| @@ -196,9 +196,7 @@ public class ScpFromMessageBySftp extends ScpFromMessage { | |||||
| } | } | ||||
| if (getPreserveLastModified()) { | if (getPreserveLastModified()) { | ||||
| FileUtils.getFileUtils().setFileLastModified(localFile, | FileUtils.getFileUtils().setFileLastModified(localFile, | ||||
| ((long) le.getAttrs() | |||||
| .getMTime()) | |||||
| * 1000); | |||||
| ((long) le.getAttrs().getMTime()) * 1000); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -592,7 +592,7 @@ public abstract class AbstractFileSet extends DataType | |||||
| return getRef(getProject()).hasSelectors(); | return getRef(getProject()).hasSelectors(); | ||||
| } | } | ||||
| dieOnCircularReference(); | dieOnCircularReference(); | ||||
| return !(selectors.isEmpty()); | |||||
| return !selectors.isEmpty(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -605,10 +605,8 @@ public abstract class AbstractFileSet extends DataType | |||||
| return getRef(getProject()).hasPatterns(); | return getRef(getProject()).hasPatterns(); | ||||
| } | } | ||||
| dieOnCircularReference(); | dieOnCircularReference(); | ||||
| if (defaultPatterns.hasPatterns(getProject())) { | |||||
| return true; | |||||
| } | |||||
| return additionalPatterns.stream().anyMatch(ps -> ps.hasPatterns(getProject())); | |||||
| return defaultPatterns.hasPatterns(getProject()) | |||||
| || additionalPatterns.stream().anyMatch(ps -> ps.hasPatterns(getProject())); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -113,11 +113,8 @@ public class CommandlineJava implements Cloneable { | |||||
| } | } | ||||
| } | } | ||||
| Properties propertySetProperties = mergePropertySets(); | Properties propertySetProperties = mergePropertySets(); | ||||
| for (Enumeration<?> e = propertySetProperties.keys(); | |||||
| e.hasMoreElements();) { | |||||
| String key = (String) e.nextElement(); | |||||
| String value = propertySetProperties.getProperty(key); | |||||
| listIt.add("-D" + key + "=" + value); | |||||
| for (String key : propertySetProperties.stringPropertyNames()) { | |||||
| listIt.add("-D" + key + "=" + propertySetProperties.getProperty(key)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -140,10 +137,9 @@ public class CommandlineJava implements Cloneable { | |||||
| try { | try { | ||||
| sys = System.getProperties(); | sys = System.getProperties(); | ||||
| Properties p = new Properties(); | Properties p = new Properties(); | ||||
| for (Enumeration<?> e = sys.propertyNames(); e.hasMoreElements();) { | |||||
| String name = (String) e.nextElement(); | |||||
| for (String name : sys.stringPropertyNames()) { | |||||
| String value = sys.getProperty(name); | String value = sys.getProperty(name); | ||||
| if (name != null && value != null) { | |||||
| if (value != null) { | |||||
| p.put(name, value); | p.put(name, value); | ||||
| } | } | ||||
| } | } | ||||
| @@ -568,8 +568,7 @@ public class PropertySet extends DataType implements ResourceCollection { | |||||
| pushAndInvokeCircularReferenceCheck(mapper, stk, p); | pushAndInvokeCircularReferenceCheck(mapper, stk, p); | ||||
| } | } | ||||
| for (PropertySet propertySet : setRefs) { | for (PropertySet propertySet : setRefs) { | ||||
| pushAndInvokeCircularReferenceCheck(propertySet, stk, | |||||
| p); | |||||
| pushAndInvokeCircularReferenceCheck(propertySet, stk, p); | |||||
| } | } | ||||
| setChecked(true); | setChecked(true); | ||||
| } | } | ||||
| @@ -120,10 +120,7 @@ public class PropertyResource extends Resource { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean equals(Object o) { | public boolean equals(Object o) { | ||||
| if (super.equals(o)) { | |||||
| return true; | |||||
| } | |||||
| return isReferenceOrProxy() && getReferencedOrProxied().equals(o); | |||||
| return super.equals(o) || isReferenceOrProxy() && getReferencedOrProxied().equals(o); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -310,10 +310,10 @@ public class URLResource extends Resource implements URLProvider { | |||||
| if (another == null || another.getClass() != getClass()) { | if (another == null || another.getClass() != getClass()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| URLResource otheru = (URLResource) another; | |||||
| URLResource other = (URLResource) another; | |||||
| return getURL() == null | return getURL() == null | ||||
| ? otheru.getURL() == null | |||||
| : getURL().equals(otheru.getURL()); | |||||
| ? other.getURL() == null | |||||
| : getURL().equals(other.getURL()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -53,10 +53,7 @@ public abstract class ResourceComparator extends DataType implements Comparator< | |||||
| if (isReference()) { | if (isReference()) { | ||||
| return getCheckedRef().equals(o); | return getCheckedRef().equals(o); | ||||
| } | } | ||||
| if (o == null) { | |||||
| return false; | |||||
| } | |||||
| return o == this || o.getClass().equals(getClass()); | |||||
| return o != null && (o == this || o.getClass().equals(getClass())); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -434,10 +434,8 @@ public class DOMElementWriter { | |||||
| } | } | ||||
| private String encode(final String value, final boolean encodeWhitespace) { | private String encode(final String value, final boolean encodeWhitespace) { | ||||
| final int len = value.length(); | |||||
| final StringBuilder sb = new StringBuilder(len); | |||||
| for (int i = 0; i < len; i++) { | |||||
| final char c = value.charAt(i); | |||||
| final StringBuilder sb = new StringBuilder(value.length()); | |||||
| for (final char c : value.toCharArray()) { | |||||
| switch (c) { | switch (c) { | ||||
| case '<': | case '<': | ||||
| sb.append("<"); | sb.append("<"); | ||||
| @@ -522,13 +520,12 @@ public class DOMElementWriter { | |||||
| while (prevEnd < len) { | while (prevEnd < len) { | ||||
| final int end = (cdataEndPos < 0 ? len : cdataEndPos); | final int end = (cdataEndPos < 0 ? len : cdataEndPos); | ||||
| // Write out stretches of legal characters in the range [prevEnd, end). | // Write out stretches of legal characters in the range [prevEnd, end). | ||||
| for (int prevLegalCharPos = prevEnd; prevLegalCharPos < end;/*empty*/) { | |||||
| int illegalCharPos; | |||||
| for (illegalCharPos = prevLegalCharPos; true; ++illegalCharPos) { | |||||
| if (illegalCharPos >= end | |||||
| || !isLegalCharacter(value.charAt(illegalCharPos))) { | |||||
| break; | |||||
| } | |||||
| int prevLegalCharPos = prevEnd; | |||||
| while (prevLegalCharPos < end) { | |||||
| int illegalCharPos = prevLegalCharPos; | |||||
| while (illegalCharPos < end | |||||
| && isLegalCharacter(value.charAt(illegalCharPos))) { | |||||
| ++illegalCharPos; | |||||
| } | } | ||||
| out.write(value, prevLegalCharPos, illegalCharPos - prevLegalCharPos); | out.write(value, prevLegalCharPos, illegalCharPos - prevLegalCharPos); | ||||
| prevLegalCharPos = illegalCharPos + 1; | prevLegalCharPos = illegalCharPos + 1; | ||||
| @@ -318,12 +318,12 @@ public final class DateUtils { | |||||
| } | } | ||||
| } | } | ||||
| final private static ThreadLocal<DateFormat> iso8601WithTimeZone = | |||||
| private static final ThreadLocal<DateFormat> iso8601WithTimeZone = | |||||
| ThreadLocal.withInitial(() -> { | ThreadLocal.withInitial(() -> { | ||||
| // An arbitrary easy-to-read format to normalize to. | // An arbitrary easy-to-read format to normalize to. | ||||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z"); | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z"); | ||||
| }); | }); | ||||
| final private static Pattern iso8601normalizer = Pattern.compile( | |||||
| private static final Pattern iso8601normalizer = Pattern.compile( | |||||
| "^(\\d{4,}-\\d{2}-\\d{2})[Tt ]" + // yyyy-MM-dd | "^(\\d{4,}-\\d{2}-\\d{2})[Tt ]" + // yyyy-MM-dd | ||||
| "(\\d{2}:\\d{2}(:\\d{2}(\\.\\d{3})?)?) ?" + // HH:mm:ss.SSS | "(\\d{2}:\\d{2}(:\\d{2}(\\.\\d{3})?)?) ?" + // HH:mm:ss.SSS | ||||
| "(?:Z|([+-]\\d{2})(?::?(\\d{2}))?)?$"); // Z | "(?:Z|([+-]\\d{2})(?::?(\\d{2}))?)?$"); // Z | ||||
| @@ -1615,7 +1615,6 @@ public class FileUtils { | |||||
| if (0 < toPathStack.length && 0 < fromPathStack.length) { | if (0 < toPathStack.length && 0 < fromPathStack.length) { | ||||
| if (!fromPathStack[0].equals(toPathStack[0])) { | if (!fromPathStack[0].equals(toPathStack[0])) { | ||||
| // not the same device (would be "" on Linux/Unix) | // not the same device (would be "" on Linux/Unix) | ||||
| return getPath(Arrays.asList(toPathStack)); | return getPath(Arrays.asList(toPathStack)); | ||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -1623,14 +1622,11 @@ public class FileUtils { | |||||
| return getPath(Arrays.asList(toPathStack)); | return getPath(Arrays.asList(toPathStack)); | ||||
| } | } | ||||
| int minLength = Math.min(fromPathStack.length, toPathStack.length); | |||||
| int same = 1; // Used outside the for loop | |||||
| // get index of parts which are equal | // get index of parts which are equal | ||||
| for (; | |||||
| same < minLength && fromPathStack[same].equals(toPathStack[same]); | |||||
| same++) { | |||||
| // Do nothing | |||||
| int minLength = Math.min(fromPathStack.length, toPathStack.length); | |||||
| int same = 1; | |||||
| while (same < minLength && fromPathStack[same].equals(toPathStack[same])) { | |||||
| same++; | |||||
| } | } | ||||
| List<String> relativePathStack = new ArrayList<>(); | List<String> relativePathStack = new ArrayList<>(); | ||||
| @@ -338,7 +338,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
| s = "\n" + s; | s = "\n" + s; | ||||
| } else { | } else { | ||||
| // could be a comment, if first non-whitespace is a # or ! | // could be a comment, if first non-whitespace is a # or ! | ||||
| comment = s.matches("^( |\t|\f)*(#|!).*"); | |||||
| comment = s.matches("^([ \t\f])*([#!]).*"); | |||||
| } | } | ||||
| // continuation if not a comment and the line ends is an | // continuation if not a comment and the line ends is an | ||||
| @@ -29,7 +29,7 @@ import java.util.Hashtable; | |||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| */ | */ | ||||
| @Deprecated | @Deprecated | ||||
| public class LazyHashtable extends Hashtable { | |||||
| public class LazyHashtable<K, V> extends Hashtable<K, V> { | |||||
| // CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
| protected boolean initAllDone = false; | protected boolean initAllDone = false; | ||||
| // CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
| @@ -55,7 +55,7 @@ public class LazyHashtable extends Hashtable { | |||||
| * Get a enumeration over the elements. | * Get a enumeration over the elements. | ||||
| * @return an enumeration. | * @return an enumeration. | ||||
| */ | */ | ||||
| public Enumeration elements() { | |||||
| public Enumeration<V> elements() { | |||||
| initAll(); | initAll(); | ||||
| return super.elements(); | return super.elements(); | ||||
| } | } | ||||
| @@ -111,7 +111,7 @@ public class LazyHashtable extends Hashtable { | |||||
| * Get an enumeration over the keys. | * Get an enumeration over the keys. | ||||
| * @return an enumeration. | * @return an enumeration. | ||||
| */ | */ | ||||
| public Enumeration keys() { | |||||
| public Enumeration<K> keys() { | |||||
| initAll(); | initAll(); | ||||
| return super.keys(); | return super.keys(); | ||||
| } | } | ||||
| @@ -796,14 +796,9 @@ public class ResourceUtils { | |||||
| return false; | return false; | ||||
| } | } | ||||
| final FileProvider fileResource1 = resource1.as(FileProvider.class); | final FileProvider fileResource1 = resource1.as(FileProvider.class); | ||||
| if (fileResource1 == null) { | |||||
| return false; | |||||
| } | |||||
| final FileProvider fileResource2 = resource2.as(FileProvider.class); | final FileProvider fileResource2 = resource2.as(FileProvider.class); | ||||
| if (fileResource2 == null) { | |||||
| return false; | |||||
| } | |||||
| return FileUtils.getFileUtils().areSame(fileResource1.getFile(), fileResource2.getFile()); | |||||
| return fileResource1 != null && fileResource2 != null | |||||
| && FileUtils.getFileUtils().areSame(fileResource1.getFile(), fileResource2.getFile()); | |||||
| } | } | ||||
| private static void log(final Project project, final String message) { | private static void log(final Project project, final String message) { | ||||
| @@ -61,9 +61,8 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
| */ | */ | ||||
| protected Pattern getCompiledPattern(int options) | protected Pattern getCompiledPattern(int options) | ||||
| throws BuildException { | throws BuildException { | ||||
| int cOptions = getCompilerOptions(options); | |||||
| try { | try { | ||||
| return Pattern.compile(this.pattern, cOptions); | |||||
| return Pattern.compile(this.pattern, getCompilerOptions(options)); | |||||
| } catch (PatternSyntaxException e) { | } catch (PatternSyntaxException e) { | ||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| } | } | ||||
| @@ -729,10 +729,8 @@ class BlockSort { | |||||
| } | } | ||||
| break; | break; | ||||
| } // while x > 0 | } // while x > 0 | ||||
| else { | |||||
| if ((block[i1] & 0xff) <= (block[i2] & 0xff)) { | |||||
| break; | |||||
| } | |||||
| else if ((block[i1] & 0xff) <= (block[i2] & 0xff)) { | |||||
| break; | |||||
| } | } | ||||
| } else if ((block[i1 + 5] & 0xff) <= (block[i2 + 5] & 0xff)) { | } else if ((block[i1 + 5] & 0xff) <= (block[i2 + 5] & 0xff)) { | ||||
| break; | break; | ||||
| @@ -74,7 +74,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| private int currentChar = -1; | private int currentChar = -1; | ||||
| private static final int EOF = 0; | |||||
| private static final int EOF = 0; | |||||
| private static final int START_BLOCK_STATE = 1; | private static final int START_BLOCK_STATE = 1; | ||||
| private static final int RAND_PART_A_STATE = 2; | private static final int RAND_PART_A_STATE = 2; | ||||
| private static final int RAND_PART_B_STATE = 3; | private static final int RAND_PART_B_STATE = 3; | ||||
| @@ -85,8 +85,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| private int currentState = START_BLOCK_STATE; | private int currentState = START_BLOCK_STATE; | ||||
| private int storedBlockCRC, storedCombinedCRC; | |||||
| private int computedBlockCRC, computedCombinedCRC; | |||||
| private int storedBlockCRC; | |||||
| private int storedCombinedCRC; | |||||
| private int computedBlockCRC; | |||||
| private int computedCombinedCRC; | |||||
| // Variables used by setup* methods exclusively | // Variables used by setup* methods exclusively | ||||
| @@ -343,10 +343,7 @@ public class TarEntry implements TarConstants { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean equals(Object it) { | public boolean equals(Object it) { | ||||
| if (it == null || getClass() != it.getClass()) { | |||||
| return false; | |||||
| } | |||||
| return equals((TarEntry) it); | |||||
| return it != null && getClass() == it.getClass() && equals((TarEntry) it); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -425,7 +422,7 @@ public class TarEntry implements TarConstants { | |||||
| */ | */ | ||||
| @Deprecated | @Deprecated | ||||
| public int getUserId() { | public int getUserId() { | ||||
| return (int) (userId & 0xffffffff); | |||||
| return (int) userId; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -466,7 +463,7 @@ public class TarEntry implements TarConstants { | |||||
| */ | */ | ||||
| @Deprecated | @Deprecated | ||||
| public int getGroupId() { | public int getGroupId() { | ||||
| return (int) (groupId & 0xffffffff); | |||||
| return (int) groupId; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -753,13 +750,8 @@ public class TarEntry implements TarConstants { | |||||
| * @return <i>true</i> if it is a 'normal' file | * @return <i>true</i> if it is a 'normal' file | ||||
| */ | */ | ||||
| public boolean isFile() { | public boolean isFile() { | ||||
| if (file != null) { | |||||
| return file.isFile(); | |||||
| } | |||||
| if (linkFlag == LF_OLDNORM || linkFlag == LF_NORMAL) { | |||||
| return true; | |||||
| } | |||||
| return !getName().endsWith("/"); | |||||
| return file != null ? file.isFile() | |||||
| : linkFlag == LF_OLDNORM || linkFlag == LF_NORMAL || !getName().endsWith("/"); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -207,10 +207,8 @@ public final class ZipEightByteInteger { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean equals(Object o) { | public boolean equals(Object o) { | ||||
| if (o instanceof ZipEightByteInteger) { | |||||
| return value.equals(((ZipEightByteInteger) o).getValue()); | |||||
| } | |||||
| return false; | |||||
| return o instanceof ZipEightByteInteger | |||||
| && value.equals(((ZipEightByteInteger) o).getValue()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -168,10 +168,7 @@ public final class ZipLong implements Cloneable { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean equals(Object o) { | public boolean equals(Object o) { | ||||
| if (o instanceof ZipLong) { | |||||
| return value == ((ZipLong) o).getValue(); | |||||
| } | |||||
| return false; | |||||
| return o instanceof ZipLong && value == ((ZipLong) o).getValue(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -133,10 +133,7 @@ public final class ZipShort implements Cloneable { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean equals(Object o) { | public boolean equals(Object o) { | ||||
| if (o instanceof ZipShort) { | |||||
| return value == ((ZipShort) o).getValue(); | |||||
| } | |||||
| return false; | |||||
| return o instanceof ZipShort && value == ((ZipShort) o).getValue(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -29,6 +29,8 @@ import org.junit.Before; | |||||
| import org.junit.Rule; | import org.junit.Rule; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import java.io.File; | |||||
| /** | /** | ||||
| */ | */ | ||||
| public class DirnameTest { | public class DirnameTest { | ||||
| @@ -75,8 +77,7 @@ public class DirnameTest { | |||||
| public void test4() { | public void test4() { | ||||
| assumeFalse("Test not possible on DOS or Netware family OS", Os.isFamily("netware") || Os.isFamily("dos")); | assumeFalse("Test not possible on DOS or Netware family OS", Os.isFamily("netware") || Os.isFamily("dos")); | ||||
| buildRule.executeTarget("test4"); | buildRule.executeTarget("test4"); | ||||
| String filesep = System.getProperty("file.separator"); | |||||
| String expected = filesep + "usr" + filesep + "local"; | |||||
| String expected = File.separator + "usr" + File.separator + "local"; | |||||
| String checkprop = buildRule.getProject().getProperty("local.dir"); | String checkprop = buildRule.getProject().getProperty("local.dir"); | ||||
| assertEquals("dirname failed", expected, checkprop); | assertEquals("dirname failed", expected, checkprop); | ||||
| } | } | ||||