src/share/classes/com/sun/tools/javac/file/JavacFileManager.java

changeset 510
72833a8a6086
parent 450
4011f49b4af8
child 554
9d9f26857129
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Feb 26 08:42:22 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Feb 26 15:26:58 2010 -0800
     1.3 @@ -260,7 +260,7 @@
     1.4                      archive = openArchive(directory);
     1.5                  } catch (IOException ex) {
     1.6                      log.error("error.reading.file",
     1.7 -                       directory, ex.getLocalizedMessage());
     1.8 +                       directory, getMessage(ex));
     1.9                      return;
    1.10                  }
    1.11              }
    1.12 @@ -489,7 +489,7 @@
    1.13                  archive = new MissingArchive(zipFileName);
    1.14              } catch (IOException ex) {
    1.15                  if (zipFileName.exists())
    1.16 -                    log.error("error.reading.file", zipFileName, ex.getLocalizedMessage());
    1.17 +                    log.error("error.reading.file", zipFileName, getMessage(ex));
    1.18                  archive = new MissingArchive(zipFileName);
    1.19              }
    1.20  
    1.21 @@ -838,4 +838,23 @@
    1.22          }
    1.23          throw new IllegalArgumentException("Invalid relative path: " + file);
    1.24      }
    1.25 +
    1.26 +    /**
    1.27 +     * Get a detail message from an IOException.
    1.28 +     * Most, but not all, instances of IOException provide a non-null result
    1.29 +     * for getLocalizedMessage().  But some instances return null: in these
    1.30 +     * cases, fallover to getMessage(), and if even that is null, return the
    1.31 +     * name of the exception itself.
    1.32 +     * @param e an IOException
    1.33 +     * @return a string to include in a compiler diagnostic
    1.34 +     */
    1.35 +    public static String getMessage(IOException e) {
    1.36 +        String s = e.getLocalizedMessage();
    1.37 +        if (s != null)
    1.38 +            return s;
    1.39 +        s = e.getMessage();
    1.40 +        if (s != null)
    1.41 +            return s;
    1.42 +        return e.toString();
    1.43 +    }
    1.44  }

mercurial