Browse Source

Cleanup of style

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271855 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
24bb66e654
1 changed files with 33 additions and 50 deletions
  1. +33
    -50
      src/main/org/apache/tools/ant/AntClassLoader.java

+ 33
- 50
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -163,8 +163,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
= (File)pathComponents.elementAt(pathElementsIndex); = (File)pathComponents.elementAt(pathElementsIndex);
url = getResourceURL(pathComponent, this.resourceName); url = getResourceURL(pathComponent, this.resourceName);
pathElementsIndex++; pathElementsIndex++;
}
catch (BuildException e) {
} catch (BuildException e) {
// ignore path elements which are not valid relative to the // ignore path elements which are not valid relative to the
// project // project
} }
@@ -176,7 +175,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
/** /**
* The size of buffers to be used in this classloader. * The size of buffers to be used in this classloader.
*/ */
private final static int BUFFER_SIZE = 8192;
private static final int BUFFER_SIZE = 8192;


/** /**
* The components of the classpath that the classloader searches * The components of the classpath that the classloader searches
@@ -261,8 +260,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
Integer.TYPE, Integer.TYPE, protectionDomain}; Integer.TYPE, Integer.TYPE, protectionDomain};
defineClassProtectionDomain defineClassProtectionDomain
= ClassLoader.class.getDeclaredMethod("defineClass", args); = ClassLoader.class.getDeclaredMethod("defineClass", args);
} catch (Exception e) {
// ignore failure to get access to 1.2+ methods
} }
catch (Exception e) {}
} }




@@ -287,8 +287,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
for (int i = 0; i < pathElements.length; ++i) { for (int i = 0; i < pathElements.length; ++i) {
try { try {
addPathElement(pathElements[i]); addPathElement(pathElements[i]);
}
catch (BuildException e) {
} catch (BuildException e) {
// ignore path elements which are invalid // ignore path elements which are invalid
// relative to the project // relative to the project
} }
@@ -357,8 +356,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
public AntClassLoader(ClassLoader parent, boolean parentFirst) { public AntClassLoader(ClassLoader parent, boolean parentFirst) {
if (parent != null) { if (parent != null) {
this.parent = parent; this.parent = parent;
}
else {
} else {
parent = AntClassLoader.class.getClassLoader(); parent = AntClassLoader.class.getClassLoader();
} }
project = null; project = null;
@@ -612,8 +610,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
+ " loaded from ant loader", Project.MSG_DEBUG); + " loaded from ant loader", Project.MSG_DEBUG);
} }
} }
}
else {
} else {
resourceStream = loadResource(name); resourceStream = loadResource(name);
if (resourceStream != null) { if (resourceStream != null) {
log("ResourceStream for " + name log("ResourceStream for " + name
@@ -650,7 +647,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
// find the class we want. // find the class we want.
InputStream stream = null; InputStream stream = null;


for (Enumeration e = pathComponents.elements(); e.hasMoreElements() && stream == null; ) {
Enumeration e = pathComponents.elements();
while (e.hasMoreElements() && stream == null) {
File pathComponent = (File)e.nextElement(); File pathComponent = (File)e.nextElement();
stream = getResourceStream(pathComponent, name); stream = getResourceStream(pathComponent, name);
} }
@@ -670,8 +668,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
private InputStream loadBaseResource(String name) { private InputStream loadBaseResource(String name) {
if (parent == null) { if (parent == null) {
return getSystemResourceAsStream(name); return getSystemResourceAsStream(name);
}
else {
} else {
return parent.getResourceAsStream(name); return parent.getResourceAsStream(name);
} }
} }
@@ -700,8 +697,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
if (resource.exists()) { if (resource.exists()) {
return new FileInputStream(resource); return new FileInputStream(resource);
} }
}
else {
} else {
// is the zip file in the cache // is the zip file in the cache
ZipFile zipFile = (ZipFile)zipFiles.get(file); ZipFile zipFile = (ZipFile)zipFiles.get(file);
if (zipFile == null) { if (zipFile == null) {
@@ -713,8 +709,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
return zipFile.getInputStream(entry); return zipFile.getInputStream(entry);
} }
} }
}
catch (Exception e) {
} catch (Exception e) {
log("Ignoring Exception " + e.getClass().getName() log("Ignoring Exception " + e.getClass().getName()
+ ": " + e.getMessage() + " reading resource " + resourceName + ": " + e.getMessage() + " reading resource " + resourceName
+ " from " + file, Project.MSG_VERBOSE); + " from " + file, Project.MSG_VERBOSE);
@@ -792,7 +787,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
} else { } else {
// try and load from this loader if the parent either didn't find // try and load from this loader if the parent either didn't find
// it or wasn't consulted. // it or wasn't consulted.
for (Enumeration e = pathComponents.elements(); e.hasMoreElements() && url == null; ) {
Enumeration e = pathComponents.elements();
while (e.hasMoreElements() && url == null) {
File pathComponent = (File)e.nextElement(); File pathComponent = (File)e.nextElement();
url = getResourceURL(pathComponent, name); url = getResourceURL(pathComponent, name);
if (url != null) { if (url != null) {
@@ -806,7 +802,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
if (url == null && !isParentFirst(name)) { if (url == null && !isParentFirst(name)) {
// this loader was first but it didn't find it - try the parent // this loader was first but it didn't find it - try the parent


url = (parent == null) ? super.getResource(name) : parent.getResource(name);
url = (parent == null) ? super.getResource(name)
: parent.getResource(name);
if (url != null) { if (url != null) {
log("Resource " + name + " loaded from parent loader", log("Resource " + name + " loaded from parent loader",
Project.MSG_DEBUG); Project.MSG_DEBUG);
@@ -861,8 +858,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
return null; return null;
} }
} }
}
else {
} else {
ZipFile zipFile = (ZipFile)zipFiles.get(file); ZipFile zipFile = (ZipFile)zipFiles.get(file);
if (zipFile == null) { if (zipFile == null) {
zipFile = new ZipFile(file); zipFile = new ZipFile(file);
@@ -879,8 +875,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
} }
} }
} }
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }


@@ -920,20 +915,17 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
theClass = findBaseClass(classname); theClass = findBaseClass(classname);
log("Class " + classname + " loaded from parent loader", log("Class " + classname + " loaded from parent loader",
Project.MSG_DEBUG); Project.MSG_DEBUG);
}
catch (ClassNotFoundException cnfe) {
} catch (ClassNotFoundException cnfe) {
theClass = findClass(classname); theClass = findClass(classname);
log("Class " + classname + " loaded from ant loader", log("Class " + classname + " loaded from ant loader",
Project.MSG_DEBUG); Project.MSG_DEBUG);
} }
}
else {
} else {
try { try {
theClass = findClass(classname); theClass = findClass(classname);
log("Class " + classname + " loaded from ant loader", log("Class " + classname + " loaded from ant loader",
Project.MSG_DEBUG); Project.MSG_DEBUG);
}
catch (ClassNotFoundException cnfe) {
} catch (ClassNotFoundException cnfe) {
if (ignoreBase) { if (ignoreBase) {
throw cnfe; throw cnfe;
} }
@@ -1000,24 +992,19 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
= new Object[] {classname, classData, new Integer(0), = new Object[] {classname, classData, new Integer(0),
new Integer(classData.length), domain}; new Integer(classData.length), domain};
return (Class)defineClassProtectionDomain.invoke(this, args); return (Class)defineClassProtectionDomain.invoke(this, args);
}
catch (InvocationTargetException ite) {
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
if (t instanceof ClassFormatError) { if (t instanceof ClassFormatError) {
throw (ClassFormatError)t; throw (ClassFormatError)t;
}
else if (t instanceof NoClassDefFoundError) {
} else if (t instanceof NoClassDefFoundError) {
throw (NoClassDefFoundError)t; throw (NoClassDefFoundError)t;
}
else {
} else {
throw new IOException(t.toString()); throw new IOException(t.toString());
} }
}
catch (Exception e) {
} catch (Exception e) {
throw new IOException(e.toString()); throw new IOException(e.toString());
} }
}
else {
} else {
return defineClass(classname, classData, 0, classData.length); return defineClass(classname, classData, 0, classData.length);
} }
} }
@@ -1058,15 +1045,15 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
InputStream stream = null; InputStream stream = null;
String classFilename = getClassFilename(name); String classFilename = getClassFilename(name);
try { try {
for (Enumeration e = pathComponents.elements(); e.hasMoreElements(); ) {
Enumeration e = pathComponents.elements();
while (e.hasMoreElements()) {
File pathComponent = (File)e.nextElement(); File pathComponent = (File)e.nextElement();
try { try {
stream = getResourceStream(pathComponent, classFilename); stream = getResourceStream(pathComponent, classFilename);
if (stream != null) { if (stream != null) {
return getClassFromStream(stream, name); return getClassFromStream(stream, name);
} }
}
catch (IOException ioe) {
} catch (IOException ioe) {
// ioe.printStackTrace(); // ioe.printStackTrace();
log("Exception reading component " + pathComponent , log("Exception reading component " + pathComponent ,
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
@@ -1074,14 +1061,12 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
} }


throw new ClassNotFoundException(name); throw new ClassNotFoundException(name);
}
finally {
} finally {
try { try {
if (stream != null) { if (stream != null) {
stream.close(); stream.close();
} }
}
catch (IOException e) {}
} catch (IOException e) {}
} }
} }


@@ -1103,8 +1088,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
private Class findBaseClass(String name) throws ClassNotFoundException { private Class findBaseClass(String name) throws ClassNotFoundException {
if (parent == null) { if (parent == null) {
return findSystemClass(name); return findSystemClass(name);
}
else {
} else {
return parent.loadClass(name); return parent.loadClass(name);
} }
} }
@@ -1120,8 +1104,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
ZipFile zipFile = (ZipFile)e.nextElement(); ZipFile zipFile = (ZipFile)e.nextElement();
try { try {
zipFile.close(); zipFile.close();
}
catch (IOException ioe) {
} catch (IOException ioe) {
// ignore // ignore
} }
} }


Loading…
Cancel
Save