@@ -181,10 +181,8 @@ public class ProjectHelperRepository { | |||||
try { | try { | ||||
// This code is needed by EBCDIC and other strange systems. | // This code is needed by EBCDIC and other strange systems. | ||||
// It's a fix for bugs reported in xerces | // It's a fix for bugs reported in xerces | ||||
InputStreamReader isr; | |||||
isr = new InputStreamReader(is, StandardCharsets.UTF_8); | |||||
BufferedReader rd = new BufferedReader(isr); | |||||
BufferedReader rd = new BufferedReader(new InputStreamReader(is, | |||||
StandardCharsets.UTF_8)); | |||||
String helperClassName = rd.readLine(); | String helperClassName = rd.readLine(); | ||||
rd.close(); | rd.close(); | ||||
@@ -442,11 +442,11 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina | |||||
return in instanceof SimpleFilterReader && ((SimpleFilterReader) in).editsBlocked(); | return in instanceof SimpleFilterReader && ((SimpleFilterReader) in).editsBlocked(); | ||||
} | } | ||||
public int read() throws java.io.IOException { | |||||
public int read() throws IOException { | |||||
return preemptIndex > 0 ? preempt[--preemptIndex] : in.read(); | return preemptIndex > 0 ? preempt[--preemptIndex] : in.read(); | ||||
} | } | ||||
public void close() throws java.io.IOException { | |||||
public void close() throws IOException { | |||||
in.close(); | in.close(); | ||||
} | } | ||||
@@ -458,23 +458,23 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina | |||||
return in.markSupported(); | return in.markSupported(); | ||||
} | } | ||||
public boolean ready() throws java.io.IOException { | |||||
public boolean ready() throws IOException { | |||||
return in.ready(); | return in.ready(); | ||||
} | } | ||||
public void mark(int i) throws java.io.IOException { | |||||
public void mark(int i) throws IOException { | |||||
in.mark(i); | in.mark(i); | ||||
} | } | ||||
public long skip(long i) throws java.io.IOException { | |||||
public long skip(long i) throws IOException { | |||||
return in.skip(i); | return in.skip(i); | ||||
} | } | ||||
public int read(char[] buf) throws java.io.IOException { | |||||
public int read(char[] buf) throws IOException { | |||||
return read(buf, 0, buf.length); | return read(buf, 0, buf.length); | ||||
} | } | ||||
public int read(char[] buf, int start, int length) throws java.io.IOException { | |||||
public int read(char[] buf, int start, int length) throws IOException { | |||||
int count = 0; | int count = 0; | ||||
int c = 0; | int c = 0; | ||||
@@ -87,22 +87,8 @@ public class AntStructure extends Task { | |||||
throw new BuildException("output attribute is required", getLocation()); | throw new BuildException("output attribute is required", getLocation()); | ||||
} | } | ||||
PrintWriter out = null; | |||||
try { | |||||
OutputStream fos = null; | |||||
try { | |||||
fos = Files.newOutputStream(output.toPath()); | |||||
out = new PrintWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); | |||||
} catch (final UnsupportedEncodingException ue) { | |||||
FileUtils.close(fos); | |||||
/* | |||||
* Plain impossible with UTF8, see | |||||
* http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html | |||||
* | |||||
* fallback to platform specific anyway. | |||||
*/ | |||||
out = new PrintWriter(new FileWriter(output)); | |||||
} | |||||
try (PrintWriter out = new PrintWriter(new OutputStreamWriter( | |||||
Files.newOutputStream(output.toPath()), StandardCharsets.UTF_8))) { | |||||
printer.printHead(out, getProject(), | printer.printHead(out, getProject(), | ||||
new Hashtable<>(getProject().getTaskDefinitions()), | new Hashtable<>(getProject().getTaskDefinitions()), | ||||
@@ -110,31 +96,24 @@ public class AntStructure extends Task { | |||||
printer.printTargetDecl(out); | printer.printTargetDecl(out); | ||||
for (final String typeName : getProject().getCopyOfDataTypeDefinitions() | |||||
.keySet()) { | |||||
printer.printElementDecl( | |||||
out, getProject(), typeName, | |||||
getProject().getDataTypeDefinitions().get(typeName)); | |||||
for (final String typeName : getProject().getCopyOfDataTypeDefinitions().keySet()) { | |||||
printer.printElementDecl(out, getProject(), typeName, | |||||
getProject().getDataTypeDefinitions().get(typeName)); | |||||
} | } | ||||
for (final String tName : getProject().getCopyOfTaskDefinitions().keySet()) { | for (final String tName : getProject().getCopyOfTaskDefinitions().keySet()) { | ||||
printer.printElementDecl(out, getProject(), tName, | printer.printElementDecl(out, getProject(), tName, | ||||
getProject().getTaskDefinitions().get(tName)); | |||||
getProject().getTaskDefinitions().get(tName)); | |||||
} | } | ||||
printer.printTail(out); | printer.printTail(out); | ||||
if (out.checkError()) { | if (out.checkError()) { | ||||
throw new IOException( | |||||
"Encountered an error writing Ant structure"); | |||||
throw new IOException("Encountered an error writing Ant structure"); | |||||
} | } | ||||
} catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
throw new BuildException("Error writing " | throw new BuildException("Error writing " | ||||
+ output.getAbsolutePath(), ioe, getLocation()); | |||||
} finally { | |||||
if (out != null) { | |||||
out.close(); | |||||
} | |||||
+ output.getAbsolutePath(), ioe, getLocation()); | |||||
} | } | ||||
} | } | ||||
@@ -428,7 +428,7 @@ public class Execute { | |||||
* Runs a process defined by the command line and returns its exit status. | * Runs a process defined by the command line and returns its exit status. | ||||
* | * | ||||
* @return the exit status of the subprocess or <code>INVALID</code>. | * @return the exit status of the subprocess or <code>INVALID</code>. | ||||
* @exception java.io.IOException The exception is thrown, if launching | |||||
* @exception IOException The exception is thrown, if launching | |||||
* of the subprocess failed. | * of the subprocess failed. | ||||
*/ | */ | ||||
public int execute() throws IOException { | public int execute() throws IOException { | ||||
@@ -484,7 +484,7 @@ public class Execute { | |||||
* Starts a process defined by the command line. | * Starts a process defined by the command line. | ||||
* Ant will not wait for this process, nor log its output. | * Ant will not wait for this process, nor log its output. | ||||
* | * | ||||
* @throws java.io.IOException The exception is thrown, if launching | |||||
* @throws IOException The exception is thrown, if launching | |||||
* of the subprocess failed. | * of the subprocess failed. | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
@@ -43,7 +43,7 @@ public class InvokeDynamicCPInfo extends ConstantCPInfo { | |||||
* | * | ||||
* @param cpStream the DataInputStream which contains the constant pool | * @param cpStream the DataInputStream which contains the constant pool | ||||
* entry to be read. | * entry to be read. | ||||
* @exception java.io.IOException if there is a problem reading the entry from | |||||
* @exception IOException if there is a problem reading the entry from | |||||
* the stream. | * the stream. | ||||
*/ | */ | ||||
@Override | @Override | ||||
@@ -58,7 +58,7 @@ public class MethodHandleCPInfo extends ConstantPoolEntry { | |||||
* | * | ||||
* @param cpStream the DataInputStream which contains the constant pool | * @param cpStream the DataInputStream which contains the constant pool | ||||
* entry to be read. | * entry to be read. | ||||
* @exception java.io.IOException if there is a problem reading the entry from | |||||
* @exception IOException if there is a problem reading the entry from | |||||
* the stream. | * the stream. | ||||
*/ | */ | ||||
@Override | @Override | ||||
@@ -41,7 +41,7 @@ public class MethodTypeCPInfo extends ConstantCPInfo { | |||||
* | * | ||||
* @param cpStream the DataInputStream which contains the constant pool | * @param cpStream the DataInputStream which contains the constant pool | ||||
* entry to be read. | * entry to be read. | ||||
* @exception java.io.IOException if there is a problem reading the entry from | |||||
* @exception IOException if there is a problem reading the entry from | |||||
* the stream. | * the stream. | ||||
*/ | */ | ||||
@Override | @Override | ||||
@@ -21,6 +21,7 @@ package org.apache.tools.ant.taskdefs.optional.junit; | |||||
import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.io.OutputStreamWriter; | |||||
import java.io.StringWriter; | import java.io.StringWriter; | ||||
import java.text.NumberFormat; | import java.text.NumberFormat; | ||||
@@ -91,7 +92,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||||
@Override | @Override | ||||
public void setOutput(OutputStream out) { | public void setOutput(OutputStream out) { | ||||
this.out = out; | this.out = out; | ||||
output = new BufferedWriter(new java.io.OutputStreamWriter(out)); | |||||
output = new BufferedWriter(new OutputStreamWriter(out)); | |||||
} | } | ||||
/** | /** | ||||
@@ -238,7 +238,7 @@ class LauncherSupport { | |||||
throw new BuildException("Listener class " + className + " is not of type " + TestExecutionListener.class.getName()); | throw new BuildException("Listener class " + className + " is not of type " + TestExecutionListener.class.getName()); | ||||
} | } | ||||
try { | try { | ||||
return TestExecutionListener.class.cast(klass.newInstance()); | |||||
return (TestExecutionListener) klass.newInstance(); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new BuildException("Failed to create an instance of listener " + className, e); | throw new BuildException("Failed to create an instance of listener " + className, e); | ||||
} | } | ||||
@@ -218,7 +218,7 @@ public class PatternSet extends DataType implements Cloneable { | |||||
public String toString() { | public String toString() { | ||||
String baseString = super.toString(); | String baseString = super.toString(); | ||||
return encoding == null ? baseString | return encoding == null ? baseString | ||||
: new StringBuilder(baseString).append(";encoding->").append(encoding).toString(); | |||||
: baseString + ";encoding->" + encoding; | |||||
} | } | ||||
} | } | ||||
@@ -17,8 +17,6 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.types.resources.selectors; | package org.apache.tools.ant.types.resources.selectors; | ||||
import java.util.Iterator; | |||||
import org.apache.tools.ant.types.Resource; | import org.apache.tools.ant.types.Resource; | ||||
/** | /** | ||||
@@ -18,6 +18,8 @@ | |||||
package org.apache.tools.ant.util; | package org.apache.tools.ant.util; | ||||
import java.io.File; | |||||
/** | /** | ||||
* Implementation of FileNameMapper that always returns the source | * Implementation of FileNameMapper that always returns the source | ||||
* file name without any leading directory information. | * file name without any leading directory information. | ||||
@@ -53,6 +55,6 @@ public class FlatFileNameMapper implements FileNameMapper { | |||||
@Override | @Override | ||||
public String[] mapFileName(String sourceFileName) { | public String[] mapFileName(String sourceFileName) { | ||||
return sourceFileName == null ? null | return sourceFileName == null ? null | ||||
: new String[] {new java.io.File(sourceFileName).getName()}; | |||||
: new String[] {new File(sourceFileName).getName()}; | |||||
} | } | ||||
} | } |
@@ -110,7 +110,7 @@ public class JavaxScriptRunner extends ScriptRunnerBase { | |||||
"Unable to create javax script engine for %s", | "Unable to create javax script engine for %s", | ||||
getLanguage()); | getLanguage()); | ||||
} | } | ||||
if (Compilable.class.isInstance(engine)) { | |||||
if (engine instanceof Compilable) { | |||||
getProject().log("compile script " + execName, | getProject().log("compile script " + execName, | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
@@ -18,6 +18,7 @@ | |||||
package org.apache.tools.zip; | package org.apache.tools.zip; | ||||
import java.io.Serializable; | |||||
import java.util.zip.ZipException; | import java.util.zip.ZipException; | ||||
/** | /** | ||||
@@ -66,7 +67,7 @@ public class UnsupportedZipFeatureException extends ZipException { | |||||
* ZIP Features that may or may not be supported. | * ZIP Features that may or may not be supported. | ||||
*/ | */ | ||||
@SuppressWarnings("serial") | @SuppressWarnings("serial") | ||||
public static class Feature implements java.io.Serializable { | |||||
public static class Feature implements Serializable { | |||||
/** | /** | ||||
* The entry is encrypted. | * The entry is encrypted. | ||||
*/ | */ | ||||
@@ -161,7 +161,7 @@ public class DefaultExcludesTest { | |||||
assertEquals("current default excludes: string array length match", expected.length, actual.length); | assertEquals("current default excludes: string array length match", expected.length, actual.length); | ||||
for (String element : expected) { | for (String element : expected) { | ||||
assertTrue("current default excludes: didn't find element " + element + " in array match", | assertTrue("current default excludes: didn't find element " + element + " in array match", | ||||
Arrays.stream(actual).anyMatch(member -> member.equals(element))); | |||||
Arrays.asList(actual).contains(element)); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -418,7 +418,7 @@ public class JavaTest { | |||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testSimpleSourceFile() throws Exception { | |||||
public void testSimpleSourceFile() { | |||||
requireJava11(); | requireJava11(); | ||||
buildRule.executeTarget("simpleSourceFile"); | buildRule.executeTarget("simpleSourceFile"); | ||||
} | } | ||||
@@ -429,7 +429,7 @@ public class JavaTest { | |||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testSourceFileRequiresFork() throws Exception { | |||||
public void testSourceFileRequiresFork() { | |||||
requireJava11(); | requireJava11(); | ||||
thrown.expect(BuildException.class); | thrown.expect(BuildException.class); | ||||
thrown.expectMessage("Cannot execute sourcefile in non-forked mode. Please set fork='true'"); | thrown.expectMessage("Cannot execute sourcefile in non-forked mode. Please set fork='true'"); | ||||
@@ -443,7 +443,7 @@ public class JavaTest { | |||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testSourceFileCantUseClassname() throws Exception { | |||||
public void testSourceFileCantUseClassname() { | |||||
requireJava11(); | requireJava11(); | ||||
thrown.expect(BuildException.class); | thrown.expect(BuildException.class); | ||||
thrown.expectMessage("Cannot use 'sourcefile' in combination with"); | thrown.expectMessage("Cannot use 'sourcefile' in combination with"); | ||||
@@ -457,7 +457,7 @@ public class JavaTest { | |||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testSourceFileCantUseJar() throws Exception { | |||||
public void testSourceFileCantUseJar() { | |||||
requireJava11(); | requireJava11(); | ||||
thrown.expect(BuildException.class); | thrown.expect(BuildException.class); | ||||
thrown.expectMessage("Cannot use 'sourcefile' in combination with"); | thrown.expectMessage("Cannot use 'sourcefile' in combination with"); | ||||
@@ -471,7 +471,7 @@ public class JavaTest { | |||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testSourceFileCantUseModule() throws Exception { | |||||
public void testSourceFileCantUseModule() { | |||||
requireJava11(); | requireJava11(); | ||||
thrown.expect(BuildException.class); | thrown.expect(BuildException.class); | ||||
thrown.expectMessage("Cannot use 'sourcefile' in combination with"); | thrown.expectMessage("Cannot use 'sourcefile' in combination with"); | ||||
@@ -81,7 +81,7 @@ public class ReaderInputStreamTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testPreample() throws Exception { | |||||
public void testPreample() { | |||||
byte[] bytes = "".getBytes(StandardCharsets.UTF_16); | byte[] bytes = "".getBytes(StandardCharsets.UTF_16); | ||||
System.out.println("Preample len is " + bytes.length); | System.out.println("Preample len is " + bytes.length); | ||||
} | } | ||||