1.1 --- a/rt/aot/src/main/java/org/apidesign/bck2brwsr/aot/Bck2BrwsrJars.java Fri Jan 09 21:48:45 2015 +0100
1.2 +++ b/rt/aot/src/main/java/org/apidesign/bck2brwsr/aot/Bck2BrwsrJars.java Sun Jan 11 09:54:37 2015 +0100
1.3 @@ -96,8 +96,35 @@
1.4 public static Bck2Brwsr configureFrom(
1.5 Bck2Brwsr c, File jar, final ClassLoader classpath
1.6 ) throws IOException {
1.7 + return configureFrom(c, jar, classpath, true);
1.8 + }
1.9 +
1.10 + /** Creates new compiler pre-configured from the content of
1.11 + * provided JAR file. The compiler will compile all classes.
1.12 + * The system understands OSGi manifest entries and NetBeans
1.13 + * module system manifest entries and will export
1.14 + * all packages that are exported in the JAR file. The system
1.15 + * also recognizes META-INF/services and makes sure the class names
1.16 + * are not mangled.
1.17 + *
1.18 + * @param c the compiler to {@link Bck2Brwsr#addClasses(java.lang.String...) add classes},
1.19 + * {@link Bck2Brwsr#addResources(java.lang.String...) add resources} and
1.20 + * {@link Bck2Brwsr#addExported(java.lang.String...) exported objects} to.
1.21 + * Can be <code>null</code> - in such case an
1.22 + * {@link Bck2Brwsr#newCompiler() empty compiler} is constructed.
1.23 + * @param jar the file to process
1.24 + * @param classpath additional resources to make available during
1.25 + * compilation, but not include them in the generated JavaScript
1.26 + * @param ignoreBootClassPath should we ignore classes on bootclasspath?
1.27 + * @return newly configured compiler
1.28 + * @throws IOException if something goes wrong
1.29 + * @since 0.14
1.30 + */
1.31 + public static Bck2Brwsr configureFrom(
1.32 + Bck2Brwsr c, File jar, final ClassLoader classpath, final boolean ignoreBootClassPath
1.33 + ) throws IOException {
1.34 if (jar.isDirectory()) {
1.35 - return configureDir(c, jar, classpath);
1.36 + return configureDir(ignoreBootClassPath, c, jar, classpath);
1.37 }
1.38 final JarFile jf = new JarFile(jar);
1.39 final List<String> classes = new ArrayList<>();
1.40 @@ -105,7 +132,7 @@
1.41 Set<String> exported = new HashSet<>();
1.42 class JarRes extends EmulationResources implements Bck2Brwsr.Resources {
1.43 JarRes() {
1.44 - super(classpath, classes);
1.45 + super(ignoreBootClassPath, classpath, classes);
1.46 }
1.47 @Override
1.48 public InputStream get(String resource) throws IOException {
1.49 @@ -236,8 +263,10 @@
1.50 private final Map<String,byte[]> converted = new HashMap<>();
1.51 private final BytecodeProcessor proc;
1.52 private final ClassLoader cp;
1.53 + private final boolean ignoreBootClassPath;
1.54
1.55 - protected EmulationResources(ClassLoader cp, List<String> classes) {
1.56 + protected EmulationResources(boolean ignoreBootClassPath, ClassLoader cp, List<String> classes) {
1.57 + this.ignoreBootClassPath = ignoreBootClassPath;
1.58 this.classes = classes;
1.59 this.cp = cp != null ? cp : Bck2BrwsrJars.class.getClassLoader();
1.60 BytecodeProcessor p;
1.61 @@ -273,7 +302,7 @@
1.62 LOG.log(Level.FINE, "Cannot find {0}", name);
1.63 return null;
1.64 }
1.65 - if (u.toExternalForm().contains("/rt.jar!")) {
1.66 + if (ignoreBootClassPath && u.toExternalForm().contains("/rt.jar!")) {
1.67 LOG.log(Level.WARNING, "No bootdelegation for {0}", name);
1.68 return null;
1.69 }
1.70 @@ -307,12 +336,12 @@
1.71 }
1.72 }
1.73
1.74 - private static Bck2Brwsr configureDir(Bck2Brwsr c, final File dir, ClassLoader cp) throws IOException {
1.75 + private static Bck2Brwsr configureDir(final boolean ignoreBootClassPath, Bck2Brwsr c, final File dir, ClassLoader cp) throws IOException {
1.76 List<String> arr = new ArrayList<>();
1.77 List<String> classes = new ArrayList<>();
1.78 class DirRes extends EmulationResources {
1.79 public DirRes(ClassLoader cp, List<String> classes) {
1.80 - super(cp, classes);
1.81 + super(ignoreBootClassPath, cp, classes);
1.82 }
1.83
1.84 @Override