diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index 44f7b2d..e6e648b 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -1204,8 +1204,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo * * @return the entry's certificates or null is the container is * not a jar or it has no certificates. + * + * @exception IOException if the manifest cannot be read. */ - private Certificate[] getCertificates(final File container, final String entry) { + private Certificate[] getCertificates(final File container, final String entry) + throws IOException { if (container.isDirectory()) { return null; } diff --git a/src/main/org/apache/tools/ant/launch/Locator.java b/src/main/org/apache/tools/ant/launch/Locator.java index 2e8c37d..4640e70 100644 --- a/src/main/org/apache/tools/ant/launch/Locator.java +++ b/src/main/org/apache/tools/ant/launch/Locator.java @@ -23,7 +23,6 @@ import java.io.FilenameFilter; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.text.CharacterIterator; import java.text.StringCharacterIterator; import java.util.Locale; @@ -60,6 +59,10 @@ public final class Locator { private static final int SPACE = 0x20; private static final int DEL = 0x7F; + /** + * encoding used to represent URIs + */ + public static final String URI_ENCODING = "UTF-8"; // stolen from org.apache.xerces.impl.XMLEntityManager#getUserDir() // of the Xerces-J team // which ASCII characters need to be escaped @@ -312,11 +315,11 @@ public final class Locator { } else if (c >= 0x0000 && c < 0x0080) { sb.write(c); } else { // #50543 - byte[] bytes = String.valueOf(c).getBytes(StandardCharsets.UTF_8); + byte[] bytes = String.valueOf(c).getBytes(URI_ENCODING); sb.write(bytes, 0, bytes.length); } } - return sb.toString(StandardCharsets.UTF_8.name()); + return sb.toString(URI_ENCODING); } /** @@ -324,9 +327,10 @@ public final class Locator { * The URI is escaped * @param path String to encode. * @return The encoded string, according to URI norms + * @throws UnsupportedEncodingException if UTF-8 is not available * @since Ant 1.7 */ - public static String encodeURI(String path) { + public static String encodeURI(String path) throws UnsupportedEncodingException { int i = 0; int len = path.length(); int ch = 0; @@ -358,7 +362,7 @@ public final class Locator { // get UTF-8 bytes for the remaining sub-string byte[] bytes = null; byte b; - bytes = path.substring(i).getBytes(StandardCharsets.UTF_8); + bytes = path.substring(i).getBytes(URI_ENCODING); len = bytes.length; // for each byte diff --git a/src/main/org/apache/tools/ant/taskdefs/Concat.java b/src/main/org/apache/tools/ant/taskdefs/Concat.java index 1af0143..1338f2a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Concat.java +++ b/src/main/org/apache/tools/ant/taskdefs/Concat.java @@ -383,7 +383,7 @@ public class Concat extends Task implements ResourceCollection { private ConcatResource(ResourceCollection c) { this.c = c; } - public InputStream getInputStream() { + public InputStream getInputStream() throws IOException { if (binary) { ConcatResourceInputStream result = new ConcatResourceInputStream(c); result.setManagingComponent(this); diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java index 5b20239..bb701a3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Jar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java @@ -1024,7 +1024,8 @@ public class Jar extends Zip { * @since Ant 1.6.2 */ protected final void writeIndexLikeList(List dirs, List files, - PrintWriter writer) { + PrintWriter writer) + throws IOException { // JarIndex is sorting the directories by ascending order. // it has no value but cosmetic since it will be read into a // hashtable by the classloader, but we'll do so anyway. diff --git a/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java b/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java index 4017b37..4a4f231 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java +++ b/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java @@ -115,8 +115,11 @@ public class ManifestClassPath extends Task { if (pathEntry.isDirectory() && !relPath.endsWith("/")) { relPath = relPath + '/'; } - relPath = Locator.encodeURI(relPath); - + try { + relPath = Locator.encodeURI(relPath); + } catch (UnsupportedEncodingException exc) { + throw new BuildException(exc); + } // Manifest's ClassPath: attribute always uses forward // slashes '/', and is space-separated. Ant will properly // format it on 72 columns with proper line continuation diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index 58304ce..c4b6dff 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -1022,7 +1022,8 @@ public class Zip extends MatchingTask { * Determine a Resource's Unix mode or return the given default * value if not available. */ - private int getUnixMode(final Resource r, final ZipFile zf, final int defaultMode) { + private int getUnixMode(final Resource r, final ZipFile zf, final int defaultMode) + throws IOException { int unixMode = defaultMode; if (zf != null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java index e83c0b6..ad9aee8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java @@ -378,6 +378,8 @@ public class Symlink extends DispatchTask { * * @param path A string containing the path of the symlink to delete. * + * @throws FileNotFoundException When the path results in a + * File that doesn't exist. * @throws IOException If calls to File.rename * or File.delete fail. * @deprecated use @@ -386,7 +388,7 @@ public class Symlink extends DispatchTask { */ @Deprecated public static void deleteSymlink(String path) - throws IOException { + throws IOException, FileNotFoundException { SYMLINK_UTILS.deleteSymbolicLink(new File(path), null); } diff --git a/src/main/org/apache/tools/ant/util/UUEncoder.java b/src/main/org/apache/tools/ant/util/UUEncoder.java index c42dcab..77e1bee 100644 --- a/src/main/org/apache/tools/ant/util/UUEncoder.java +++ b/src/main/org/apache/tools/ant/util/UUEncoder.java @@ -81,7 +81,7 @@ public class UUEncoder { /** * Encode a string to the output. */ - private void encodeString(String n) { + private void encodeString(String n) throws IOException { PrintStream writer = new PrintStream(out); writer.print(n); writer.flush();