Public API to disallow classes from rt.jar
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 10 Oct 2013 13:59:29 +0200
changeset 13654393b7db103b
parent 1364 2cb12e6693d3
child 1366 add89df8447e
Public API to disallow classes from rt.jar
rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/Java2JavaScript.java
rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java
     1.1 --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/Java2JavaScript.java	Thu Oct 10 09:33:40 2013 +0200
     1.2 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/Java2JavaScript.java	Thu Oct 10 13:59:29 2013 +0200
     1.3 @@ -70,6 +70,10 @@
     1.4       */
     1.5      @Parameter(defaultValue="NONE")
     1.6      private ObfuscationLevel obfuscation;
     1.7 +    
     1.8 +    /** Should classes from rt.jar be included? */
     1.9 +    @Parameter(defaultValue = "false")
    1.10 +    private boolean ignoreBootClassPath;
    1.11  
    1.12      @Override
    1.13      public void execute() throws MojoExecutionException {
    1.14 @@ -94,7 +98,7 @@
    1.15              FileWriter w = new FileWriter(javascript);
    1.16              Bck2Brwsr.newCompiler().
    1.17                  obfuscation(obfuscation).
    1.18 -                resources(url).
    1.19 +                resources(url, ignoreBootClassPath).
    1.20                  addRootClasses(arr.toArray(new String[0])).
    1.21                  generate(w);
    1.22              w.close();
     2.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java	Thu Oct 10 09:33:40 2013 +0200
     2.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java	Thu Oct 10 13:59:29 2013 +0200
     2.3 @@ -151,7 +151,21 @@
     2.4       * @since 0.5
     2.5       */
     2.6      public Bck2Brwsr resources(final ClassLoader loader) {
     2.7 -        return resources(new LdrRsrcs(loader, false));
     2.8 +        return resources(loader, false);
     2.9 +    }
    2.10 +
    2.11 +    /** A way to change the provider of additional resources (classes) for the 
    2.12 +     * compiler by specifying classloader to use for loading them.
    2.13 +     * 
    2.14 +     * @param loader class loader to load the resources from
    2.15 +     * @param ignoreBootClassPath <code>true</code> if classes loaded
    2.16 +     *    from <code>rt.jar</code> 
    2.17 +     * @return new instance of the compiler with all values being the same, just 
    2.18 +     *   different resources provider
    2.19 +     * @since 0.9
    2.20 +     */
    2.21 +    public Bck2Brwsr resources(final ClassLoader loader, boolean ignoreBootClassPath) {
    2.22 +        return resources(new LdrRsrcs(loader, ignoreBootClassPath));
    2.23      }
    2.24      
    2.25      /** Generates virtual machine based on previous configuration of the