|
From: <tr...@us...> - 2003-09-25 22:11:34
|
Update of /cvsroot/babeldoc/babeldoc/modules/init/src/com/babeldoc/init
In directory sc8-pr-cvs1:/tmp/cvs-serv7651
Modified Files:
Main.java
Log Message:
Fixed bug where the init modules Main class would fail with an NPE if a classpath entry is not found!
Index: Main.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/init/src/com/babeldoc/init/Main.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Main.java 8 Sep 2003 22:40:59 -0000 1.5
--- Main.java 25 Sep 2003 22:11:30 -0000 1.6
***************
*** 73,76 ****
--- 73,78 ----
import java.util.Vector;
import java.util.StringTokenizer;
+ import java.util.Collection;
+ import java.util.ArrayList;
import java.net.URL;
import java.net.URLClassLoader;
***************
*** 95,98 ****
--- 97,101 ----
public static final String DOT_JAR = ".jar";
public static final String DOT_ZIP = ".zip";
+ public static final String MAIN = "main";
/**
***************
*** 165,169 ****
for (int i = 0; i < methods.length; ++i) {
! if ("main".equals(methods[i].getName())) {
Method method = methods[i];
Object[] methodArgs = new Object[] { args };
--- 168,172 ----
for (int i = 0; i < methods.length; ++i) {
! if (MAIN.equals(methods[i].getName())) {
Method method = methods[i];
Object[] methodArgs = new Object[] { args };
***************
*** 211,215 ****
urls[i] = files[i].toURL();
} catch (MalformedURLException e) {
! System.out.println(e);
}
}
--- 214,218 ----
urls[i] = files[i].toURL();
} catch (MalformedURLException e) {
! System.err.println(e);
}
}
***************
*** 252,270 ****
private static File[] getClasspathFiles() {
String cp = System.getProperty(BABELDOC_CP);
- File [] files = null;
if(cp!=null) {
StringTokenizer st = new StringTokenizer(cp, File.pathSeparator);
! int num = st.countTokens();
! int i = 0;
! files = new File[num];
while(st.hasMoreTokens()) {
String token = st.nextToken();
File file = new File(token);
! if(file.exists()) {
! files[i++] = file;
}
}
}
- return files;
}
}
--- 255,277 ----
private static File[] getClasspathFiles() {
String cp = System.getProperty(BABELDOC_CP);
if(cp!=null) {
StringTokenizer st = new StringTokenizer(cp, File.pathSeparator);
! Collection files = new ArrayList();
while(st.hasMoreTokens()) {
String token = st.nextToken();
File file = new File(token);
! if(file.exists()&&
! (token.endsWith(DOT_JAR)||
! token.endsWith(DOT_ZIP))) {
! // System.out.println("Adding: "+token);
! files.add(file);
! } else {
! // System.out.println("Ignoring : "+token);
}
}
+ return (File[])files.toArray(new File[0]);
+ } else {
+ return null;
}
}
}
|