craigmcc    00/12/21 15:47:20

  Modified:    catalina/src/share/org/apache/catalina/startup
                        Bootstrap.java
  Log:
  Modify the bootstrap program to call file.getCanonicalPath() rather than
  file.getAbsolutePath() when constructing "file:" URLs to declare as
  repositories to URLClassLoader instances.  This will cause occurrences of
  "/./" and "/../" to be normalized out of the URLs, which apparently causes
  problems on some platforms -- although I haven't been able to duplicate it
  with my simple tests so far.
  
  There are other cases where this change needs to be applied, which will be
  dealt with separately.
  
  Submitted by: Stuart Roebuck <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.8       +24 -13    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java
  
  Index: Bootstrap.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Bootstrap.java    2000/12/21 22:27:11     1.7
  +++ Bootstrap.java    2000/12/21 23:47:20     1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v
 1.7 2000/12/21 22:27:11 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/12/21 22:27:11 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v
 1.8 2000/12/21 23:47:20 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/12/21 23:47:20 $
    *
    * ====================================================================
    *
  @@ -66,6 +66,7 @@
   
   
   import java.io.File;
  +import java.io.IOException;
   import java.lang.reflect.Method;
   import java.net.MalformedURLException;
   import java.net.URL;
  @@ -84,7 +85,7 @@
    * class path and therefore not visible to application level classes.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/12/21 22:27:11 $
  + * @version $Revision: 1.8 $ $Date: 2000/12/21 23:47:20 $
    */
   
   public final class Bootstrap {
  @@ -109,6 +110,12 @@
        */
       public static void main(String args[]) {
   
  +        // Set the debug flag appropriately
  +        for (int i = 0; i < args.length; i++)  {
  +            if ("-debug".equals(args[i]))
  +                debug = 1;
  +        }
  +
           // Construct the class loaders we will need
           ClassLoader systemLoader = createSystemLoader();
           ClassLoader catalinaLoader = createCatalinaLoader(systemLoader);
  @@ -183,18 +190,19 @@
        String filenames[] = directory.list();
        for (int i = 0; i < filenames.length; i++) {
               String filename = filenames[i].toLowerCase();
  -         if ((!filename.endsWith(".jar")) || 
  +         if ((!filename.endsWith(".jar")) ||
                   (filename.indexOf("bootstrap.jar") != -1))
                continue;
               File file = new File(directory, filenames[i]);
               try {
  -                URL url = new URL("file", null, file.getAbsolutePath());
  +                URL url = new URL("file", null, file.getCanonicalPath());
                   if (debug >= 1)
                       log("  Adding " + url.toString());
                   list.add(url.toString());
  -            } catch (MalformedURLException e) {
  +            } catch (IOException e) {
                   System.out.println("Cannot create URL for " +
                                      filenames[i]);
  +                e.printStackTrace(System.out);
                   System.exit(1);
               }
        }
  @@ -226,13 +234,14 @@
               classes.isDirectory()) {
               try {
                   URL url = new URL("file", null,
  -                                  classes.getAbsolutePath() + "/");
  +                                  classes.getCanonicalPath() + "/");
                   if (debug >= 1)
                       log("  Adding " + url.toString());
                   list.add(url.toString());
  -            } catch (MalformedURLException e) {
  +            } catch (IOException e) {
                   System.out.println("Cannot create URL for " +
                                      classes.getAbsolutePath());
  +                e.printStackTrace(System.out);
                   System.exit(1);
               }
           }
  @@ -251,13 +260,14 @@
                continue;
               File file = new File(directory, filenames[i]);
               try {
  -                URL url = new URL("file", null, file.getAbsolutePath());
  +                URL url = new URL("file", null, file.getCanonicalPath());
                   if (debug >= 1)
                       log("  Adding " + url.toString());
                   list.add(url.toString());
  -            } catch (MalformedURLException e) {
  +            } catch (IOException e) {
                   System.out.println("Cannot create URL for " +
                                      filenames[i]);
  +                e.printStackTrace(System.out);
                   System.exit(1);
               }
        }
  @@ -297,13 +307,14 @@
                continue;
               File file = new File(directory, filenames[i]);
               try {
  -                URL url = new URL("file", null, file.getAbsolutePath());
  +                URL url = new URL("file", null, file.getCanonicalPath());
                   if (debug >= 1)
                       log("  Adding " + url.toString());
                   list.add(url.toString());
  -            } catch (MalformedURLException e) {
  +            } catch (IOException e) {
                   System.out.println("Cannot create URL for " +
                                      filenames[i]);
  +                e.printStackTrace(System.out);
                   System.exit(1);
               }
        }
  
  
  

Reply via email to