| @@ -135,11 +135,10 @@ public class WhichResource extends Task { | |||||
| getProject().log("using system classpath: " + classpath, | getProject().log("using system classpath: " + classpath, | ||||
| Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
| } | } | ||||
| AntClassLoader loader = null; | |||||
| try { | |||||
| loader = AntClassLoader.newAntClassLoader(getProject().getCoreLoader(), | |||||
| getProject(), | |||||
| classpath, false); | |||||
| try (AntClassLoader loader = | |||||
| AntClassLoader.newAntClassLoader(getProject().getCoreLoader(), | |||||
| getProject(), | |||||
| classpath, false)) { | |||||
| String loc = null; | String loc = null; | ||||
| if (classname != null) { | if (classname != null) { | ||||
| //convert a class name into a resource | //convert a class name into a resource | ||||
| @@ -162,10 +161,6 @@ public class WhichResource extends Task { | |||||
| loc = url.toExternalForm(); | loc = url.toExternalForm(); | ||||
| getProject().setNewProperty(property, loc); | getProject().setNewProperty(property, loc); | ||||
| } | } | ||||
| } finally { | |||||
| if (loader != null) { | |||||
| loader.cleanup(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -422,17 +422,12 @@ public class ANTLR extends Task { | |||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| */ | */ | ||||
| protected boolean is272() { | protected boolean is272() { | ||||
| AntClassLoader l = null; | |||||
| try { | |||||
| l = getProject().createClassLoader(commandline.getClasspath()); | |||||
| try (AntClassLoader l = | |||||
| getProject().createClassLoader(commandline.getClasspath())) { | |||||
| l.loadClass("antlr.Version"); | l.loadClass("antlr.Version"); | ||||
| return true; | return true; | ||||
| } catch (ClassNotFoundException e) { | } catch (ClassNotFoundException e) { | ||||
| return false; | return false; | ||||
| } finally { | |||||
| if (l != null) { | |||||
| l.cleanup(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -379,9 +379,7 @@ public class Depend extends MatchingTask { | |||||
| if (checkPath != null) { | if (checkPath != null) { | ||||
| // now determine which jars each class depends upon | // now determine which jars each class depends upon | ||||
| classpathDependencies = new Hashtable(); | classpathDependencies = new Hashtable(); | ||||
| AntClassLoader loader = null; | |||||
| try { | |||||
| loader = getProject().createClassLoader(checkPath); | |||||
| try (AntClassLoader loader = getProject().createClassLoader(checkPath)) { | |||||
| Hashtable classpathFileCache = new Hashtable(); | Hashtable classpathFileCache = new Hashtable(); | ||||
| Object nullFileMarker = new Object(); | Object nullFileMarker = new Object(); | ||||
| @@ -443,10 +441,6 @@ public class Depend extends MatchingTask { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } finally { | |||||
| if (loader != null) { | |||||
| loader.cleanup(); | |||||
| } | |||||
| } | } | ||||
| } else { | } else { | ||||
| log("No classpath to check", Project.MSG_DEBUG); | log("No classpath to check", Project.MSG_DEBUG); | ||||
| @@ -681,10 +681,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||||
| log("Looking for GenIC class in classpath: " | log("Looking for GenIC class in classpath: " | ||||
| + classpath.toString(), Project.MSG_VERBOSE); | + classpath.toString(), Project.MSG_VERBOSE); | ||||
| AntClassLoader cl = null; | |||||
| try { | |||||
| cl = classpath.getProject().createClassLoader(classpath); | |||||
| try (AntClassLoader cl = classpath.getProject().createClassLoader(classpath)) { | |||||
| try { | try { | ||||
| cl.loadClass(JonasDeploymentTool.GENIC_CLASS); | cl.loadClass(JonasDeploymentTool.GENIC_CLASS); | ||||
| @@ -723,10 +720,6 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||||
| + "' not found in classpath.", | + "' not found in classpath.", | ||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| } | } | ||||
| } finally { | |||||
| if (cl != null) { | |||||
| cl.cleanup(); | |||||
| } | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -425,12 +425,11 @@ public class JavaCC extends Task { | |||||
| String packagePrefix = null; | String packagePrefix = null; | ||||
| String mainClass = null; | String mainClass = null; | ||||
| AntClassLoader l = null; | |||||
| try { | |||||
| l = AntClassLoader.newAntClassLoader(null, null, | |||||
| path | |||||
| .concatSystemClasspath("ignore"), | |||||
| true); | |||||
| try (AntClassLoader l = | |||||
| AntClassLoader.newAntClassLoader(null, null, | |||||
| path | |||||
| .concatSystemClasspath("ignore"), | |||||
| true)) { | |||||
| String javaccClass = COM_PACKAGE + COM_JAVACC_CLASS; | String javaccClass = COM_PACKAGE + COM_JAVACC_CLASS; | ||||
| InputStream is = l.getResourceAsStream(javaccClass.replace('.', '/') | InputStream is = l.getResourceAsStream(javaccClass.replace('.', '/') | ||||
| + ".class"); | + ".class"); | ||||
| @@ -498,10 +497,6 @@ public class JavaCC extends Task { | |||||
| throw new BuildException("unknown task type " + type); | throw new BuildException("unknown task type " + type); | ||||
| } | } | ||||
| return packagePrefix + mainClass; | return packagePrefix + mainClass; | ||||
| } finally { | |||||
| if (l != null) { | |||||
| l.cleanup(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -439,13 +439,10 @@ public class JspC extends MatchingTask { | |||||
| File dest = getActualDestDir(); | File dest = getActualDestDir(); | ||||
| AntClassLoader al = null; | |||||
| try { | |||||
| try (AntClassLoader al = getProject().createClassLoader(compilerClasspath)) { | |||||
| //bind to a compiler | //bind to a compiler | ||||
| JspCompilerAdapter compiler = | JspCompilerAdapter compiler = | ||||
| JspCompilerAdapterFactory | |||||
| .getCompiler(compilerName, this, | |||||
| al = getProject().createClassLoader(compilerClasspath)); | |||||
| JspCompilerAdapterFactory.getCompiler(compilerName, this, al); | |||||
| //if we are a webapp, hand off to the compiler, which had | //if we are a webapp, hand off to the compiler, which had | ||||
| //better handle it | //better handle it | ||||
| @@ -514,10 +511,6 @@ public class JspC extends MatchingTask { | |||||
| log("all files are up to date", Project.MSG_VERBOSE); | log("all files are up to date", Project.MSG_VERBOSE); | ||||
| } | } | ||||
| } | } | ||||
| } finally { | |||||
| if (al != null) { | |||||
| al.cleanup(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -166,17 +166,11 @@ public class JasperC extends DefaultJspCompilerAdapter { | |||||
| * @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
| */ | */ | ||||
| private boolean isTomcat5x() { | private boolean isTomcat5x() { | ||||
| AntClassLoader l = null; | |||||
| try { | |||||
| l = getProject().createClassLoader(getClasspath()); | |||||
| try (AntClassLoader l = getProject().createClassLoader(getClasspath())) { | |||||
| l.loadClass("org.apache.jasper.tagplugins.jstl.If"); | l.loadClass("org.apache.jasper.tagplugins.jstl.If"); | ||||
| return true; | return true; | ||||
| } catch (ClassNotFoundException e) { | } catch (ClassNotFoundException e) { | ||||
| return false; | return false; | ||||
| } finally { | |||||
| if (l != null) { | |||||
| l.cleanup(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1360,12 +1360,10 @@ public class JUnitTask extends Task { | |||||
| if (!cmd.haveClasspath()) { | if (!cmd.haveClasspath()) { | ||||
| return; | return; | ||||
| } | } | ||||
| AntClassLoader loader = null; | |||||
| try { | |||||
| loader = | |||||
| AntClassLoader.newAntClassLoader(null, getProject(), | |||||
| cmd.createClasspath(getProject()), | |||||
| true); | |||||
| try (AntClassLoader loader = | |||||
| AntClassLoader.newAntClassLoader(null, getProject(), | |||||
| cmd.createClasspath(getProject()), | |||||
| true)) { | |||||
| final String projectResourceName = | final String projectResourceName = | ||||
| LoaderUtils.classNameToResource(Project.class.getName()); | LoaderUtils.classNameToResource(Project.class.getName()); | ||||
| URL previous = null; | URL previous = null; | ||||
| @@ -1386,10 +1384,6 @@ public class JUnitTask extends Task { | |||||
| } catch (final Exception ex) { | } catch (final Exception ex) { | ||||
| // Ignore exception | // Ignore exception | ||||
| } | } | ||||
| } finally { | |||||
| if (loader != null) { | |||||
| loader.cleanup(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||