aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/ClassPoolTail.java
diff options
context:
space:
mode:
authornickl- <github@jigsoft.co.za>2017-10-30 20:37:23 +0200
committernickl- <github@jigsoft.co.za>2017-10-30 20:37:23 +0200
commit62851d0af30cdb0c54046627585451a468aacd2a (patch)
treefd7632ac39246a9598cb5bf6176c4bf0bcb21744 /src/main/javassist/ClassPoolTail.java
parent45b4c55361eef93542db8014e3ef8941169c97bd (diff)
downloadjavassist-62851d0af30cdb0c54046627585451a468aacd2a.tar.gz
javassist-62851d0af30cdb0c54046627585451a468aacd2a.zip
Source walk/Spring clean/Parameterize/Enhance et.al.
The following were applied during multiple itterations through the source. * Parameterize raw types. * Mark unused members. * Annotate override and deprecated methods. * Convert loops to enhance for loop. * Remove redundant else statements. * Widening collection type references. * Optimize code for improved readability. * Squash compiler warnings. * Identify smells.
Diffstat (limited to 'src/main/javassist/ClassPoolTail.java')
-rw-r--r--src/main/javassist/ClassPoolTail.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/main/javassist/ClassPoolTail.java b/src/main/javassist/ClassPoolTail.java
index 1b580855..c28003ea 100644
--- a/src/main/javassist/ClassPoolTail.java
+++ b/src/main/javassist/ClassPoolTail.java
@@ -45,6 +45,7 @@ final class DirClassPath implements ClassPath {
directory = dirName;
}
+ @Override
public InputStream openClassfile(String classname) {
try {
char sep = File.separatorChar;
@@ -57,6 +58,7 @@ final class DirClassPath implements ClassPath {
return null;
}
+ @Override
public URL find(String classname) {
char sep = File.separatorChar;
String filename = directory + sep
@@ -72,8 +74,10 @@ final class DirClassPath implements ClassPath {
return null;
}
+ @Override
public void close() {}
+ @Override
public String toString() {
return directory;
}
@@ -84,6 +88,7 @@ final class JarDirClassPath implements ClassPath {
JarDirClassPath(String dirName) throws NotFoundException {
File[] files = new File(dirName).listFiles(new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name) {
name = name.toLowerCase();
return name.endsWith(".jar") || name.endsWith(".zip");
@@ -97,6 +102,7 @@ final class JarDirClassPath implements ClassPath {
}
}
+ @Override
public InputStream openClassfile(String classname) throws NotFoundException {
if (jars != null)
for (int i = 0; i < jars.length; i++) {
@@ -108,6 +114,7 @@ final class JarDirClassPath implements ClassPath {
return null; // not found
}
+ @Override
public URL find(String classname) {
if (jars != null)
for (int i = 0; i < jars.length; i++) {
@@ -119,6 +126,7 @@ final class JarDirClassPath implements ClassPath {
return null; // not found
}
+ @Override
public void close() {
if (jars != null)
for (int i = 0; i < jars.length; i++)
@@ -141,6 +149,7 @@ final class JarClassPath implements ClassPath {
throw new NotFoundException(pathname);
}
+ @Override
public InputStream openClassfile(String classname)
throws NotFoundException
{
@@ -149,14 +158,14 @@ final class JarClassPath implements ClassPath {
JarEntry je = jarfile.getJarEntry(jarname);
if (je != null)
return jarfile.getInputStream(je);
- else
- return null; // not found
+ return null; // not found
}
catch (IOException e) {}
throw new NotFoundException("broken jar file?: "
+ jarfile.getName());
}
+ @Override
public URL find(String classname) {
String jarname = classname.replace('.', '/') + ".class";
JarEntry je = jarfile.getJarEntry(jarname);
@@ -169,6 +178,7 @@ final class JarClassPath implements ClassPath {
return null; // not found
}
+ @Override
public void close() {
try {
jarfile.close();
@@ -177,6 +187,7 @@ final class JarClassPath implements ClassPath {
catch (IOException e) {}
}
+ @Override
public String toString() {
return jarfile == null ? "<null>" : jarfile.toString();
}
@@ -189,6 +200,7 @@ final class ClassPoolTail {
pathList = null;
}
+ @Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("[class path: ");
@@ -242,10 +254,8 @@ final class ClassPoolTail {
public ClassPath appendSystemPath() {
if (javassist.bytecode.ClassFile.MAJOR_VERSION < javassist.bytecode.ClassFile.JAVA_9)
return appendClassPath(new ClassClassPath());
- else {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return appendClassPath(new LoaderClassPath(cl));
- }
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return appendClassPath(new LoaderClassPath(cl));
}
public ClassPath insertClassPath(String pathname)
@@ -346,8 +356,7 @@ final class ClassPoolTail {
if (error != null)
throw error;
- else
- return null; // not found
+ return null; // not found
}
/**