You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2016/03/29 11:22:44 UTC
[1/2] ant git commit: whitespace
Repository: ant
Updated Branches:
refs/heads/1.9.x a8d6367dd -> 17527b649
whitespace
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/b7ef1bcd
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/b7ef1bcd
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/b7ef1bcd
Branch: refs/heads/1.9.x
Commit: b7ef1bcd034c37e9088c32f8bedc748ef1d24a57
Parents: a8d6367
Author: Stefan Bodewig <bo...@apache.org>
Authored: Tue Mar 29 11:11:18 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Tue Mar 29 11:11:18 2016 +0200
----------------------------------------------------------------------
src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/b7ef1bcd/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java b/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
index 8419037..31740f7 100644
--- a/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
+++ b/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
@@ -40,8 +40,8 @@ import org.junit.Test;
*/
public class AntClassLoaderTest {
- @Rule
- public BuildFileRule buildRule = new BuildFileRule();
+ @Rule
+ public BuildFileRule buildRule = new BuildFileRule();
private AntClassLoader loader;
[2/2] ant git commit: AntClassLoader5 has become obsolete long ago
Posted by bo...@apache.org.
AntClassLoader5 has become obsolete long ago
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/17527b64
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/17527b64
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/17527b64
Branch: refs/heads/1.9.x
Commit: 17527b6490851a728623c1dcbf5078cc63a982dd
Parents: b7ef1bc
Author: Stefan Bodewig <bo...@apache.org>
Authored: Tue Mar 29 11:15:03 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Tue Mar 29 11:15:03 2016 +0200
----------------------------------------------------------------------
.../org/apache/tools/ant/AntClassLoader.java | 34 +++------
.../tools/ant/loader/AntClassLoader5.java | 20 +-----
.../apache/tools/ant/AntClassLoaderTest.java | 43 ++++++++++++
.../tools/ant/loader/AntClassLoader5Test.java | 73 --------------------
4 files changed, 56 insertions(+), 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/17527b64/src/main/org/apache/tools/ant/AntClassLoader.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java
index 607ada7..129b004 100644
--- a/src/main/org/apache/tools/ant/AntClassLoader.java
+++ b/src/main/org/apache/tools/ant/AntClassLoader.java
@@ -18,6 +18,7 @@
package org.apache.tools.ant;
import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -48,7 +49,6 @@ import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.util.LoaderUtils;
-import org.apache.tools.ant.util.ReflectUtil;
import org.apache.tools.ant.util.VectorSet;
import org.apache.tools.zip.ZipLong;
@@ -69,7 +69,7 @@ import org.apache.tools.zip.ZipLong;
* </p>
*
*/
-public class AntClassLoader extends ClassLoader implements SubBuildListener {
+public class AntClassLoader extends ClassLoader implements SubBuildListener, Closeable {
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
@@ -1550,20 +1550,15 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
return "AntClassLoader[" + getClasspath() + "]";
}
- private static Class<?> subClassToLoad = null;
- private static final Class<?>[] CONSTRUCTOR_ARGS = new Class[] {
- ClassLoader.class, Project.class, Path.class, Boolean.TYPE
- };
+ /** {@inheritDoc} */
+ @Override
+ public Enumeration<URL> getResources(String name) throws IOException {
+ return getNamedResources(name);
+ }
- static {
- if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_5)) {
- try {
- subClassToLoad =
- Class.forName("org.apache.tools.ant.loader.AntClassLoader5");
- } catch (final ClassNotFoundException e) {
- // this is Java5 but the installation is lacking our subclass
- }
- }
+ /** {@inheritDoc} */
+ public void close() {
+ cleanup();
}
/**
@@ -1573,15 +1568,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
final Project project,
final Path path,
final boolean parentFirst) {
- if (subClassToLoad != null) {
- return (AntClassLoader)
- ReflectUtil.newInstance(subClassToLoad,
- CONSTRUCTOR_ARGS,
- new Object[] {
- parent, project, path,
- Boolean.valueOf(parentFirst)
- });
- }
return new AntClassLoader(parent, project, path, parentFirst);
}
http://git-wip-us.apache.org/repos/asf/ant/blob/17527b64/src/main/org/apache/tools/ant/loader/AntClassLoader5.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/loader/AntClassLoader5.java b/src/main/org/apache/tools/ant/loader/AntClassLoader5.java
index a91ed41..15c29df 100644
--- a/src/main/org/apache/tools/ant/loader/AntClassLoader5.java
+++ b/src/main/org/apache/tools/ant/loader/AntClassLoader5.java
@@ -18,20 +18,15 @@
package org.apache.tools.ant.loader;
-import java.io.Closeable;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
/**
- * Overrides getResources which became non-final in Java5 and
- * implements Closeable
+ * @deprecated since 1.9.7
+ * Just use {@link AntClassLoader} itself.
*/
-public class AntClassLoader5 extends AntClassLoader implements Closeable {
+public class AntClassLoader5 extends AntClassLoader {
/**
* Creates a classloader for the given project using the classpath given.
*
@@ -53,13 +48,4 @@ public class AntClassLoader5 extends AntClassLoader implements Closeable {
super(parent, project, classpath, parentFirst);
}
- /** {@inheritDoc} */
- public Enumeration<URL> getResources(String name) throws IOException {
- return getNamedResources(name);
- }
-
- /** {@inheritDoc} */
- public void close() {
- cleanup();
- }
}
http://git-wip-us.apache.org/repos/asf/ant/blob/17527b64/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java b/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
index 31740f7..e22bd05 100644
--- a/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
+++ b/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
@@ -19,16 +19,21 @@
package org.apache.tools.ant;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
+import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
+import java.util.Enumeration;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.CollectionUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -199,6 +204,44 @@ public class AntClassLoaderTest {
}
}
+ /**
+ * Asserts that getResources won't return resources that cannot be
+ * seen by AntClassLoader but by ClassLoader.this.parent.
+ *
+ * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=46752">
+ * https://issues.apache.org/bugzilla/show_bug.cgi?id=46752</a>
+ */
+ @Test
+ public void testGetResources() throws IOException {
+ AntClassLoader acl = new AntClassLoader(new EmptyLoader(), null,
+ new Path(null), true);
+ assertNull(acl.getResource("META-INF/MANIFEST.MF"));
+ assertFalse(acl.getResources("META-INF/MANIFEST.MF").hasMoreElements());
+
+ // double check using system classloader as parent
+ acl = new AntClassLoader(null, null, new Path(null), true);
+ assertNotNull(acl.getResource("META-INF/MANIFEST.MF"));
+ assertTrue(acl.getResources("META-INF/MANIFEST.MF").hasMoreElements());
+ }
+
+ @Test
+ public void testGetResourcesUsingFactory() throws IOException {
+ AntClassLoader acl =
+ AntClassLoader.newAntClassLoader(new EmptyLoader(), null,
+ new Path(null), true);
+ assertNull(acl.getResource("META-INF/MANIFEST.MF"));
+ assertFalse(acl.getResources("META-INF/MANIFEST.MF").hasMoreElements());
+ }
+
+ private static class EmptyLoader extends ClassLoader {
+ public URL getResource(String n) {
+ return null;
+ }
+ public Enumeration getResources(String n) {
+ return new CollectionUtils.EmptyEnumeration();
+ }
+ }
+
private static class GetPackageWrapper extends ClassLoader {
GetPackageWrapper(ClassLoader parent) {
super(parent);
http://git-wip-us.apache.org/repos/asf/ant/blob/17527b64/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java b/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java
deleted file mode 100644
index a01a940..0000000
--- a/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.tools.ant.loader;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-import org.apache.tools.ant.AntClassLoader;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.CollectionUtils;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-public class AntClassLoader5Test {
-
- /**
- * Asserts that getResources won't return resources that cannot be
- * seen by AntClassLoader but by ClassLoader.this.parent.
- *
- * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=46752">
- * https://issues.apache.org/bugzilla/show_bug.cgi?id=46752</a>
- */
- @Test
- public void testGetResources() throws IOException {
- AntClassLoader acl = new AntClassLoader5(new EmptyLoader(), null,
- new Path(null), true);
- assertNull(acl.getResource("META-INF/MANIFEST.MF"));
- assertFalse(acl.getResources("META-INF/MANIFEST.MF").hasMoreElements());
-
- // double check using system classloader as parent
- acl = new AntClassLoader5(null, null, new Path(null), true);
- assertNotNull(acl.getResource("META-INF/MANIFEST.MF"));
- assertTrue(acl.getResources("META-INF/MANIFEST.MF").hasMoreElements());
- }
-
- @Test
- public void testGetResourcesUsingFactory() throws IOException {
- AntClassLoader acl =
- AntClassLoader.newAntClassLoader(new EmptyLoader(), null,
- new Path(null), true);
- assertNull(acl.getResource("META-INF/MANIFEST.MF"));
- assertFalse(acl.getResources("META-INF/MANIFEST.MF").hasMoreElements());
- }
-
- private static class EmptyLoader extends ClassLoader {
- public URL getResource(String n) {
- return null;
- }
- public Enumeration getResources(String n) {
- return new CollectionUtils.EmptyEnumeration();
- }
- }
-}
\ No newline at end of file