More robust against missing classes closure
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 05 May 2014 08:36:50 +0200
branchclosure
changeset 1523d1eeb43a75a3
parent 1522 0d32bf6b4436
child 1524 ed9f8f93960f
More robust against missing classes
launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java
     1.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Sun May 04 12:02:57 2014 +0200
     1.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Mon May 05 08:36:50 2014 +0200
     1.3 @@ -40,6 +40,7 @@
     1.4   * @author Jaroslav Tulach
     1.5   */
     1.6  class CompileCP {
     1.7 +    private static final Logger LOG = Logger.getLogger(CompileCP.class.getName());
     1.8      static String compileJAR(final JarFile jar) throws IOException {
     1.9          List<String> arr = new ArrayList<>();
    1.10          List<String> classes = new ArrayList<>();
    1.11 @@ -62,6 +63,8 @@
    1.12                  .generate(w);
    1.13              w.flush();
    1.14              return w.toString();
    1.15 +        } catch (IOException ex) {
    1.16 +            throw ex;
    1.17          } catch (Throwable ex) {
    1.18              throw new IOException("Cannot compile: ", ex);
    1.19          } finally {
    1.20 @@ -171,7 +174,8 @@
    1.21              .resources(new Bck2Brwsr.Resources() {
    1.22                  @Override
    1.23                  public InputStream get(String resource) throws IOException {
    1.24 -                    return r.get(resource, 0).openStream();
    1.25 +                    final URL url = r.get(resource, 0);
    1.26 +                    return url == null ? null : url.openStream();
    1.27                  }
    1.28              }).generate(sb);
    1.29      }
    1.30 @@ -186,10 +190,12 @@
    1.31                  u = en.nextElement();
    1.32              }
    1.33              if (u == null) {
    1.34 -                throw new IOException("Can't find " + name);
    1.35 +                LOG.log(Level.WARNING, "Cannot find {0}", name);
    1.36 +                return null;
    1.37              }
    1.38 -            if (u.toExternalForm().contains("rt.jar!")) {
    1.39 -                throw new IOException("No emulation for " + u);
    1.40 +            if (u.toExternalForm().contains("/rt.jar!")) {
    1.41 +                LOG.warning(name + "No bootdelegation for ");
    1.42 +                return null;
    1.43              }
    1.44              return u.openStream();
    1.45          }