+ try(Compilation c = new Compilation()) {
+ split(c);
+ if(!c.compile())
+ throw(new CompilationException(file, c.output()));
+ code = new BufferedClassLoader(c.classes());
+ }
+ }
+
+ private static final Pattern classpat = Pattern.compile("^((public|abstract)\\s+)*(class|interface)\\s+(\\S+)");
+ public void split(Compilation c) throws IOException {
+ StringBuilder head = new StringBuilder();
+ BufferedWriter cur = null;
+ try(BufferedReader fp = Files.newBufferedReader(file)) {
+ for(String ln = fp.readLine(); ln != null; ln = fp.readLine()) {
+ Matcher m = classpat.matcher(ln);
+ if(m.find()) {
+ String clnm = m.group(4);
+ Path sp = c.srcdir.resolve(clnm + ".java");
+ c.add(sp);
+ if(cur != null)
+ cur.close();
+ cur = Files.newBufferedWriter(sp);
+ cur.append(head);
+ }
+ if(cur != null) {
+ cur.append(ln); cur.append('\n');
+ } else {
+ head.append(ln); head.append('\n');
+ }
+ }
+ } finally {
+ if(cur != null)
+ cur.close();
+ }
+ }
+ }
+
+ public static class File {
+ public final Path name;
+ private FileTime mtime = null;
+ private Module mod = null;
+
+ private File(Path name) {
+ this.name = name;