6420151: need to improve byfile compile policy to eliminate footprint issues
authorjjg
Tue, 23 Sep 2008 10:44:51 -0700
changeset 1355 74cc97efef51
parent 1262 ecec15963b1b
child 1356 9f40f16e543b
6420151: need to improve byfile compile policy to eliminate footprint issues Reviewed-by: mcimadamore
langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
langtools/src/share/classes/com/sun/tools/javac/comp/Todo.java
langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
langtools/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java
langtools/src/share/classes/javax/tools/FileObject.java
langtools/test/tools/javac/6734819/T6734819b.out
langtools/test/tools/javac/policy/A.java
langtools/test/tools/javac/policy/B.java
langtools/test/tools/javac/policy/C.java
langtools/test/tools/javac/policy/D.java
langtools/test/tools/javac/policy/Test.java
langtools/test/tools/javac/policy/byfile.ABD.out
langtools/test/tools/javac/policy/byfile.ACD.out
langtools/test/tools/javac/policy/bytodo.ABD.out
langtools/test/tools/javac/policy/bytodo.ACD.out
langtools/test/tools/javac/policy/simple.ABD.out
langtools/test/tools/javac/policy/simple.ACD.out
langtools/test/tools/javac/policy/test1/A.java
langtools/test/tools/javac/policy/test1/B.java
langtools/test/tools/javac/policy/test1/C.java
langtools/test/tools/javac/policy/test1/D.java
langtools/test/tools/javac/policy/test1/Test1a.java
langtools/test/tools/javac/policy/test1/Test1b.java
langtools/test/tools/javac/policy/test1/byfile.ABD.out
langtools/test/tools/javac/policy/test1/byfile.ACD.out
langtools/test/tools/javac/policy/test1/bytodo.ABD.out
langtools/test/tools/javac/policy/test1/bytodo.ACD.out
langtools/test/tools/javac/policy/test1/simple.ABD.out
langtools/test/tools/javac/policy/test1/simple.ACD.out
langtools/test/tools/javac/policy/test2/A.java
langtools/test/tools/javac/policy/test2/B.java
langtools/test/tools/javac/policy/test2/Test.java
langtools/test/tools/javac/policy/test2/byfile.AB.out
langtools/test/tools/javac/policy/test2/byfile.BA.out
langtools/test/tools/javac/policy/test2/bytodo.AB.out
langtools/test/tools/javac/policy/test2/bytodo.BA.out
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Thu Sep 18 18:39:44 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Sep 23 10:44:51 2008 -0700
@@ -474,23 +474,22 @@
     }
 
     abstract class Filter {
-        void run(ListBuffer<Env<AttrContext>> list, Iterable<? extends TypeElement> classes) {
+        void run(Queue<Env<AttrContext>> list, Iterable<? extends TypeElement> classes) {
             Set<TypeElement> set = new HashSet<TypeElement>();
             for (TypeElement item: classes)
                 set.add(item);
 
-            List<Env<AttrContext>> defer = List.<Env<AttrContext>>nil();
-            while (list.nonEmpty()) {
-                Env<AttrContext> env = list.next();
+            ListBuffer<Env<AttrContext>> defer = ListBuffer.<Env<AttrContext>>lb();
+            while (list.peek() != null) {
+                Env<AttrContext> env = list.remove();
                 ClassSymbol csym = env.enclClass.sym;
                 if (csym != null && set.contains(csym.outermostClass()))
                     process(env);
                 else
-                    defer = defer.prepend(env);
+                    defer = defer.append(env);
             }
 
-            for (List<Env<AttrContext>> l = defer; l.nonEmpty(); l = l.tail)
-                list.prepend(l.head);
+            list.addAll(defer);
         }
 
         abstract void process(Env<AttrContext> env);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Todo.java	Thu Sep 18 18:39:44 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Todo.java	Tue Sep 23 10:44:51 2008 -0700
@@ -25,7 +25,14 @@
 
 package com.sun.tools.javac.comp;
 
-import com.sun.tools.javac.util.*;
+import java.util.AbstractQueue;
+import com.sun.tools.javac.util.Context;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Queue;
+import javax.tools.JavaFileObject;
 
 /** A queue of all as yet unattributed classes.
  *
@@ -34,7 +41,7 @@
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  */
-public class Todo extends ListBuffer<Env<AttrContext>> {
+public class Todo extends AbstractQueue<Env<AttrContext>> {
     /** The context key for the todo list. */
     protected static final Context.Key<Todo> todoKey =
         new Context.Key<Todo>();
@@ -51,4 +58,115 @@
     protected Todo(Context context) {
         context.put(todoKey, this);
     }
+
+    public void append(Env<AttrContext> env) {
+        add(env);
+    }
+
+    @Override
+    public Iterator<Env<AttrContext>> iterator() {
+        return contents.iterator();
+    }
+
+    @Override
+    public int size() {
+        return contents.size();
+    }
+
+    public boolean offer(Env<AttrContext> e) {
+        if (contents.add(e)) {
+            if (contentsByFile != null)
+                addByFile(e);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Env<AttrContext> poll() {
+        if (size() == 0)
+            return null;
+        Env<AttrContext> env = contents.remove(0);
+        if (contentsByFile != null)
+            removeByFile(env);
+        return env;
+    }
+
+    public Env<AttrContext> peek() {
+        return (size() == 0 ? null : contents.get(0));
+    }
+
+    public Queue<Queue<Env<AttrContext>>> groupByFile() {
+        if (contentsByFile == null) {
+            contentsByFile = new LinkedList<Queue<Env<AttrContext>>>();
+            for (Env<AttrContext> env: contents) {
+                addByFile(env);
+            }
+        }
+        return contentsByFile;
+    }
+
+    private void addByFile(Env<AttrContext> env) {
+        JavaFileObject file = env.toplevel.sourcefile;
+        if (fileMap == null)
+            fileMap = new HashMap<JavaFileObject, FileQueue>();
+        FileQueue fq = fileMap.get(file);
+        if (fq == null) {
+            fq = new FileQueue();
+            fileMap.put(file, fq);
+            contentsByFile.add(fq);
+        }
+        fq.fileContents.add(env);
+    }
+
+    private void removeByFile(Env<AttrContext> env) {
+        JavaFileObject file = env.toplevel.sourcefile;
+        FileQueue fq = fileMap.get(file);
+        if (fq == null)
+            return;
+        if (fq.fileContents.remove(env)) {
+            if (fq.isEmpty()) {
+                fileMap.remove(file);
+                contentsByFile.remove(fq);
+            }
+        }
+    }
+
+    LinkedList<Env<AttrContext>> contents = new LinkedList<Env<AttrContext>>();
+    LinkedList<Queue<Env<AttrContext>>> contentsByFile;
+    Map<JavaFileObject, FileQueue> fileMap;
+
+    class FileQueue extends AbstractQueue<Env<AttrContext>> {
+        @Override
+        public Iterator<Env<AttrContext>> iterator() {
+            return fileContents.iterator();
+        }
+
+        @Override
+        public int size() {
+            return fileContents.size();
+        }
+
+        public boolean offer(Env<AttrContext> e) {
+            if (fileContents.offer(e)) {
+                contents.add(e);
+                return true;
+            }
+            return false;
+        }
+
+        public Env<AttrContext> poll() {
+            if (fileContents.size() == 0)
+                return null;
+            Env<AttrContext> env = fileContents.remove(0);
+            contents.remove(env);
+            return env;
+        }
+
+        public Env<AttrContext> peek() {
+            return (fileContents.size() == 0 ? null : fileContents.get(0));
+        }
+
+        LinkedList<Env<AttrContext>> fileContents = new LinkedList<Env<AttrContext>>();
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Sep 18 18:39:44 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Sep 23 10:44:51 2008 -0700
@@ -122,35 +122,47 @@
         }
     }
 
-    private static enum CompilePolicy {
-        /*
-         * Just attribute the parse trees
+    /**
+     * Control how the compiler's latter phases (attr, flow, desugar, generate)
+     * are connected. Each individual file is processed by each phase in turn,
+     * but with different compile policies, you can control the order in which
+     * each class is processed through its next phase.
+     *
+     * <p>Generally speaking, the compiler will "fail fast" in the face of
+     * errors, although not aggressively so. flow, desugar, etc become no-ops
+     * once any errors have occurred. No attempt is currently made to determine
+     * if it might be safe to process a class through its next phase because
+     * it does not depend on any unrelated errors that might have occurred.
+     */
+    protected static enum CompilePolicy {
+        /**
+         * Just attribute the parse trees.
          */
         ATTR_ONLY,
 
-        /*
+        /**
          * Just attribute and do flow analysis on the parse trees.
          * This should catch most user errors.
          */
         CHECK_ONLY,
 
-        /*
+        /**
          * Attribute everything, then do flow analysis for everything,
          * then desugar everything, and only then generate output.
-         * Means nothing is generated if there are any errors in any classes.
+         * This means no output will be generated if there are any
+         * errors in any classes.
          */
         SIMPLE,
 
-        /*
-         * After attributing everything and doing flow analysis,
-         * group the work by compilation unit.
-         * Then, process the work for each compilation unit together.
-         * Means nothing is generated for a compilation unit if the are any errors
-         * in the compilation unit  (or in any preceding compilation unit.)
+        /**
+         * Groups the classes for each source file together, then process
+         * each group in a manner equivalent to the {@code SIMPLE} policy.
+         * This means no output will be generated if there are any
+         * errors in any of the classes in a source file.
          */
         BY_FILE,
 
-        /*
+        /**
          * Completely process each entry on the todo list in turn.
          * -- this is the same for 1.5.
          * Means output might be generated for some classes in a compilation unit
@@ -178,7 +190,7 @@
 
     private static CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
 
-    private static enum ImplicitSourcePolicy {
+    protected static enum ImplicitSourcePolicy {
         /** Don't generate or process implicitly read source files. */
         NONE,
         /** Generate classes for implicitly read source files. */
@@ -252,11 +264,11 @@
 
     /** The type eraser.
      */
-    TransTypes transTypes;
+    protected TransTypes transTypes;
 
     /** The syntactic sugar desweetener.
      */
-    Lower lower;
+    protected Lower lower;
 
     /** The annotation annotator.
      */
@@ -788,14 +800,17 @@
                 generate(desugar(flow(attribute(todo))));
                 break;
 
-            case BY_FILE:
-                for (Queue<Env<AttrContext>> queue : groupByFile(flow(attribute(todo))).values())
-                    generate(desugar(queue));
+            case BY_FILE: {
+                    Queue<Queue<Env<AttrContext>>> q = todo.groupByFile();
+                    while (!q.isEmpty() && errorCount() == 0) {
+                        generate(desugar(flow(attribute(q.remove()))));
+                    }
+                }
                 break;
 
             case BY_TODO:
-                while (todo.nonEmpty())
-                    generate(desugar(flow(attribute(todo.next()))));
+                while (!todo.isEmpty())
+                    generate(desugar(flow(attribute(todo.remove()))));
                 break;
 
             default:
@@ -1105,13 +1120,13 @@
     /**
      * Perform dataflow checks on an attributed parse tree.
      */
-    protected void flow(Env<AttrContext> env, ListBuffer<Env<AttrContext>> results) {
+    protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
         try {
             if (errorCount() > 0)
                 return;
 
             if (relax || compileStates.isDone(env, CompileState.FLOW)) {
-                results.append(env);
+                results.add(env);
                 return;
             }
 
@@ -1130,7 +1145,7 @@
                 if (errorCount() > 0)
                     return;
 
-                results.append(env);
+                results.add(env);
             }
             finally {
                 log.useSource(prev);
@@ -1284,7 +1299,7 @@
         generate(queue, null);
     }
 
-    public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, ListBuffer<JavaFileObject> results) {
+    public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, Queue<JavaFileObject> results) {
         boolean usePrintSource = (stubOutput || sourceOutput || printFlat);
 
         for (Pair<Env<AttrContext>, JCClassDecl> x: queue) {
@@ -1294,7 +1309,7 @@
             if (verboseCompilePolicy) {
                 log.printLines(log.noticeWriter, "[generate "
                                + (usePrintSource ? " source" : "code")
-                               + " " + env.enclClass.sym + "]");
+                               + " " + cdef.sym + "]");
             }
 
             if (taskListener != null) {
@@ -1312,7 +1327,7 @@
                 else
                     file = genCode(env, cdef);
                 if (results != null && file != null)
-                    results.append(file);
+                    results.add(file);
             } catch (IOException ex) {
                 log.error(cdef.pos(), "class.cant.write",
                           cdef.sym, ex.getMessage());
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Thu Sep 18 18:39:44 2008 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Tue Sep 23 10:44:51 2008 -0700
@@ -46,8 +46,13 @@
         super(context);
     }
 
-    public ListBuffer<Env<AttrContext>> append(Env<AttrContext> e) {
+    @Override
+    public void append(Env<AttrContext> e) {
         // do nothing; Javadoc doesn't perform attribution.
-        return this;
+    }
+
+    @Override
+    public boolean offer(Env<AttrContext> e) {
+        return false;
     }
 }
--- a/langtools/src/share/classes/javax/tools/FileObject.java	Thu Sep 18 18:39:44 2008 -0700
+++ b/langtools/src/share/classes/javax/tools/FileObject.java	Tue Sep 23 10:44:51 2008 -0700
@@ -26,12 +26,10 @@
 package javax.tools;
 
 import java.io.IOException;
-import java.io.CharConversionException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.Writer;
-import java.nio.CharBuffer;
 import java.net.URI;
 
 /**
--- a/langtools/test/tools/javac/6734819/T6734819b.out	Thu Sep 18 18:39:44 2008 -0700
+++ b/langtools/test/tools/javac/6734819/T6734819b.out	Tue Sep 23 10:44:51 2008 -0700
@@ -5,5 +5,5 @@
 [desugar A]
 [generate code A]
 [desugar B]
+[generate code B.C]
 [generate code B]
-[generate code B]
--- a/langtools/test/tools/javac/policy/A.java	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-class A
-{
-    A() {
-        D d = new D();
-    }
-}
-
-class A1
-{
-    A1() {
-    }
-}
-
-class A2
-{
-    A2() {
-    }
-}
--- a/langtools/test/tools/javac/policy/B.java	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/* /nodynamiccopyright/ */
-class B
-{
-    B() {
-    }
-}
-
-
-class B1
-{
-    B1() {
-        x = 1;
-    }
-}
-
-class B2
-{
-    B2() {
-    }
-}
--- a/langtools/test/tools/javac/policy/C.java	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/* /nodynamiccopyright/ */
-class C
-{
-    C() {
-    }
-}
-
-
-class C1
-{
-    C1() {
-        return; return;
-    }
-}
-
-class C2
-{
-    C2() {
-    }
-}
--- a/langtools/test/tools/javac/policy/D.java	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-class D
-{
-    D() {
-    }
-}
-
-class D1
-{
-    D1() {
-    }
-}
-
-class D2
-{
-    D2() {
-    }
-}
--- a/langtools/test/tools/javac/policy/Test.java	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-/*
- * @test
- * @bug 6260188 6290772
- * @summary provide variable policies for javac operation
- *              Default compile policy is now "by file" (reverted to "todo" for 6382700)
- *              Because of attr errors in B, no code should be generated
- * @compile/fail/ref=bytodo.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy A.java B.java D.java
- */
-
-/*
- * @test
- * @bug 6260188
- * @summary provide variable policies for javac operation
- *              Generate code for A, A1, A2, B
- * @compile/fail/ref=bytodo.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=bytodo A.java B.java D.java
- */
-
-/*
- * @test
- * @bug 6260188
- * @summary provide variable policies for javac operation
- *              Because of attr errors in B, no code should be generated
- * @compile/fail/ref=simple.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=simple A.java B.java D.java
- */
-
-/*
- * @test
- * @bug 6260188
- * @summary provide variable policies for javac operation
- *              Because of attr errors in B, no code should be generated
- * @compile/fail/ref=byfile.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=byfile A.java B.java D.java
- */
-
-
-
-
-/*
- * @test
- * @bug 6260188 6290772
- * @summary provide variable policies for javac operation
- *              Default compile policy is now "by file" (reverted to "todo" for 6382700)
- *              Generate code for A, A1, A2, but because of flow errors in C, no more code should be generated
- * @compile/fail/ref=bytodo.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy A.java C.java D.java
- */
-
-/*
- * @test
- * @bug 6260188
- * @summary provide variable policies for javac operation
- *              Generate code for A, A1, A2, C
- * @compile/fail/ref=bytodo.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=bytodo A.java C.java D.java
- */
-
-/*
- * @test
- * @bug 6260188
- * @summary provide variable policies for javac operation
- *              Because of flow errors in C, no code should be generated
- * @compile/fail/ref=simple.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=simple A.java C.java D.java
- */
-
-/*
- * @test
- * @bug 6260188
- * @summary provide variable policies for javac operation
- *              Generate code for A, A1, A2, but because of flow errors in C, no more code should be generated
- * @compile/fail/ref=byfile.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=byfile A.java C.java D.java
- */
--- a/langtools/test/tools/javac/policy/byfile.ABD.out	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-[attribute A]
-[attribute A1]
-[attribute A2]
-[attribute B]
-[attribute B1]
-B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
-[attribute B2]
-[attribute D]
-[attribute D1]
-[attribute D2]
-1 error
--- a/langtools/test/tools/javac/policy/byfile.ACD.out	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-[attribute A]
-[attribute A1]
-[attribute A2]
-[attribute C]
-[attribute C1]
-[attribute C2]
-[attribute D]
-[attribute D1]
-[attribute D2]
-[flow A]
-[flow A1]
-[flow A2]
-[flow C]
-[flow C1]
-C.java:12:17: compiler.err.unreachable.stmt
-1 error
--- a/langtools/test/tools/javac/policy/bytodo.ABD.out	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-[attribute A]
-[flow A]
-[desugar A]
-[generate code A]
-[attribute A1]
-[flow A1]
-[desugar A1]
-[generate code A1]
-[attribute A2]
-[flow A2]
-[desugar A2]
-[generate code A2]
-[attribute B]
-[flow B]
-[desugar B]
-[generate code B]
-[attribute B1]
-B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
-[attribute B2]
-[attribute D]
-[attribute D1]
-[attribute D2]
-1 error
--- a/langtools/test/tools/javac/policy/bytodo.ACD.out	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-[attribute A]
-[flow A]
-[desugar A]
-[generate code A]
-[attribute A1]
-[flow A1]
-[desugar A1]
-[generate code A1]
-[attribute A2]
-[flow A2]
-[desugar A2]
-[generate code A2]
-[attribute C]
-[flow C]
-[desugar C]
-[generate code C]
-[attribute C1]
-[flow C1]
-C.java:12:17: compiler.err.unreachable.stmt
-[attribute C2]
-[attribute D]
-[attribute D1]
-[attribute D2]
-1 error
--- a/langtools/test/tools/javac/policy/simple.ABD.out	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-[attribute A]
-[attribute A1]
-[attribute A2]
-[attribute B]
-[attribute B1]
-B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
-[attribute B2]
-[attribute D]
-[attribute D1]
-[attribute D2]
-1 error
--- a/langtools/test/tools/javac/policy/simple.ACD.out	Thu Sep 18 18:39:44 2008 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-[attribute A]
-[attribute A1]
-[attribute A2]
-[attribute C]
-[attribute C1]
-[attribute C2]
-[attribute D]
-[attribute D1]
-[attribute D2]
-[flow A]
-[flow A1]
-[flow A2]
-[flow C]
-[flow C1]
-C.java:12:17: compiler.err.unreachable.stmt
-1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/A.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+class A
+{
+    A() {
+        D d = new D();
+    }
+}
+
+class A1
+{
+    A1() {
+    }
+}
+
+class A2
+{
+    A2() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/B.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,20 @@
+/* /nodynamiccopyright/ */
+class B
+{
+    B() {
+    }
+}
+
+
+class B1
+{
+    B1() {
+        x = 1;
+    }
+}
+
+class B2
+{
+    B2() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/C.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,20 @@
+/* /nodynamiccopyright/ */
+class C
+{
+    C() {
+    }
+}
+
+
+class C1
+{
+    C1() {
+        return; return;
+    }
+}
+
+class C2
+{
+    C2() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/D.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+class D
+{
+    D() {
+    }
+}
+
+class D1
+{
+    D1() {
+    }
+}
+
+class D2
+{
+    D2() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/Test1a.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+// These tests exercise the various compile policies available via
+// JavaCompiler.CompilePolicy. Like any golden file tests, they are
+// somewhat fragile and susceptible to breakage, but like the canary
+// in the mine, it is useful to know when something is not as it used
+// to be. The golden files should not be taken as a guarantee of
+// future behavior, and should be updated, with due care, if the
+// behavior of the compile policy is deliberately changed.
+
+/*
+ * @test
+ * @bug 6260188 6290772
+ * @summary provide variable policies for javac operation
+ *              Default compile policy is now "by file" (reverted to "todo" for 6382700)
+ *              Because of attr errors in B, no code should be generated
+ * @compile/fail/ref=bytodo.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy A.java B.java D.java
+ */
+
+/*
+ * @test
+ * @bug 6260188
+ * @summary provide variable policies for javac operation
+ *              Generate code for A, A1, A2, B
+ * @compile/fail/ref=bytodo.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=bytodo A.java B.java D.java
+ */
+
+/*
+ * @test
+ * @bug 6260188
+ * @summary provide variable policies for javac operation
+ *              Because of attr errors in B, no code should be generated
+ * @compile/fail/ref=simple.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=simple A.java B.java D.java
+ */
+
+/*
+ * @test
+ * @bug 6260188
+ * @summary provide variable policies for javac operation
+ *              Because of attr errors in B, no code should be generated
+ * @compile/fail/ref=byfile.ABD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=byfile A.java B.java D.java
+ */
+
+
+
+
+/*
+ * @test
+ * @bug 6260188 6290772
+ * @summary provide variable policies for javac operation
+ *              Default compile policy is now "by file" (reverted to "todo" for 6382700)
+ *              Generate code for A, A1, A2, but because of flow errors in C, no more code should be generated
+ * @compile/fail/ref=bytodo.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy A.java C.java D.java
+ */
+
+/*
+ * @test
+ * @bug 6260188
+ * @summary provide variable policies for javac operation
+ *              Generate code for A, A1, A2, C
+ * @compile/fail/ref=bytodo.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=bytodo A.java C.java D.java
+ */
+
+/*
+ * @test
+ * @bug 6260188
+ * @summary provide variable policies for javac operation
+ *              Because of flow errors in C, no code should be generated
+ * @compile/fail/ref=simple.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=simple A.java C.java D.java
+ */
+
+/*
+ * @test
+ * @bug 6260188
+ * @summary provide variable policies for javac operation
+ *              Generate code for A, A1, A2, but because of flow errors in C, no more code should be generated
+ * @compile/fail/ref=byfile.ACD.out -XDstdout -XDrawDiagnostics -XDverboseCompilePolicy -XDcompilePolicy=byfile A.java C.java D.java
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/Test1b.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test 6420151
+ * @summary Compile a group of files and validate the set of class files produced
+ * @run main Test1b -XDcompilePolicy=byfile A.java B.java D.java
+ */
+
+/*
+ * @test 6420151
+ * @summary Compile a group of files and validate the set of class files produced
+ * @run main Test1b -XDcompilePolicy=byfile A.java C.java D.java
+ */
+
+/*
+ * @test 6420151
+ * @summary Compile a group of files and validate the set of class files produced
+ * @run main Test1b -XDcompilePolicy=simple A.java B.java D.java
+ */
+
+/*
+ * @test 6420151
+ * @summary Compile a group of files and validate the set of class files produced
+ * @run main Test1b -XDcompilePolicy=simple A.java C.java D.java
+ */
+
+// These test cases should be uncommented when the default compile policy is
+// changed to "byfile".  While the default policy is "bytodo", the test cases fail
+///*
+// * @test 6420151
+// * @summary Compile a group of files and validate the set of class files produced
+// * @run main Test1b A.java B.java D.java
+// */
+//
+///*
+// * @test 6420151
+// * @summary Compile a group of files and validate the set of class files produced
+// * @run main Test1b A.java C.java D.java
+// */
+
+// These test cases are retained for debugging; if uncommented, they show that
+// to bytodo mode fails the "all or none" class file test
+///*
+// * @test 6420151
+// * @summary Compile a group of files and validate the set of class files produced
+// * @run main Test1b -XDcompilePolicy=bytodo A.java B.java D.java
+// */
+//
+///*
+// * @test 6420151
+// * @summary Compile a group of files and validate the set of class files produced
+// * @run main Test1b -XDcompilePolicy=bytodo A.java C.java D.java
+// */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Test1b
+{
+    public static void main(String... args) throws Exception {
+        new Test1b().run(args);
+    }
+
+    void run(String... args) throws Exception {
+        File testSrcDir = new File(System.getProperty("test.src"));
+        File tmpClassDir = new File(".");
+        List<String> l = new ArrayList<String>();
+        l.add("-d");
+        l.add(tmpClassDir.getPath());
+        for (String a: args) {
+            if (a.endsWith(".java"))
+                l.add(new File(testSrcDir, a).getPath());
+            else
+                l.add(a);
+        }
+
+        StringWriter sw = new StringWriter();
+        int rc = com.sun.tools.javac.Main.compile(l.toArray(new String[l.size()]), new PrintWriter(sw));
+        System.err.println(sw);
+
+        Pattern p = Pattern.compile("([A-Z]+).*");
+        for (String name: tmpClassDir.list()) {
+            if (name.endsWith(".class")) {
+                Matcher m = p.matcher(name);
+                if (m.matches()) {
+                    found(m.group(1), name);
+                }
+            }
+        }
+
+        // for all classes that might have been compiled, check that
+        // all the classes in the source file get generated, or none do.
+        check("A", 3);
+        check("B", 3);
+        check("C", 3);
+        check("D", 3);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors");
+    }
+
+    void check(String prefix, int expect) {
+        List<String> names = map.get(prefix);
+        int found = (names == null ? 0 : names.size());
+        if (found == 0 || found == expect) {
+            System.err.println("Found " + found + " files for " + prefix + ": OK");
+            return;
+        }
+        error("Found " + found + " files for " + prefix + ": expected 0 or " + expect + " " + names);
+    }
+
+    void found(String prefix, String name) {
+        List<String> names = map.get(prefix);
+        if (names == null) {
+            names = new ArrayList<String>();
+            map.put(prefix, names);
+        }
+        names.add(name);
+    }
+
+    void error(String message) {
+        System.err.println(message);
+        errors++;
+    }
+
+    Map<String,List<String>> map = new HashMap<String,List<String>>();
+    int errors;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/byfile.ABD.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,17 @@
+[attribute A]
+[attribute A1]
+[attribute A2]
+[flow A]
+[flow A1]
+[flow A2]
+[desugar A]
+[desugar A1]
+[desugar A2]
+[generate code A]
+[generate code A1]
+[generate code A2]
+[attribute B]
+[attribute B1]
+B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
+[attribute B2]
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/byfile.ACD.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,19 @@
+[attribute A]
+[attribute A1]
+[attribute A2]
+[flow A]
+[flow A1]
+[flow A2]
+[desugar A]
+[desugar A1]
+[desugar A2]
+[generate code A]
+[generate code A1]
+[generate code A2]
+[attribute C]
+[attribute C1]
+[attribute C2]
+[flow C]
+[flow C1]
+C.java:12:17: compiler.err.unreachable.stmt
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/bytodo.ABD.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,23 @@
+[attribute A]
+[flow A]
+[desugar A]
+[generate code A]
+[attribute A1]
+[flow A1]
+[desugar A1]
+[generate code A1]
+[attribute A2]
+[flow A2]
+[desugar A2]
+[generate code A2]
+[attribute B]
+[flow B]
+[desugar B]
+[generate code B]
+[attribute B1]
+B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
+[attribute B2]
+[attribute D]
+[attribute D1]
+[attribute D2]
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/bytodo.ACD.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,24 @@
+[attribute A]
+[flow A]
+[desugar A]
+[generate code A]
+[attribute A1]
+[flow A1]
+[desugar A1]
+[generate code A1]
+[attribute A2]
+[flow A2]
+[desugar A2]
+[generate code A2]
+[attribute C]
+[flow C]
+[desugar C]
+[generate code C]
+[attribute C1]
+[flow C1]
+C.java:12:17: compiler.err.unreachable.stmt
+[attribute C2]
+[attribute D]
+[attribute D1]
+[attribute D2]
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/simple.ABD.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,11 @@
+[attribute A]
+[attribute A1]
+[attribute A2]
+[attribute B]
+[attribute B1]
+B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
+[attribute B2]
+[attribute D]
+[attribute D1]
+[attribute D2]
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test1/simple.ACD.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,16 @@
+[attribute A]
+[attribute A1]
+[attribute A2]
+[attribute C]
+[attribute C1]
+[attribute C2]
+[attribute D]
+[attribute D1]
+[attribute D2]
+[flow A]
+[flow A1]
+[flow A2]
+[flow C]
+[flow C1]
+C.java:12:17: compiler.err.unreachable.stmt
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test2/A.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+class A {
+
+    class A1 {
+    }
+
+    static class A2 extends B {
+    }
+
+    static class A3 extends B.Inner {
+    }
+
+    class A4 {
+        void m1() {
+            class A3m1 { }
+        }
+
+        void m2() {
+            new B() {
+            };
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test2/B.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+class B {
+    static class Inner {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test2/Test.java	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @compile/ref=byfile.AB.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=byfile A.java B.java
+ */
+
+/*
+ * @test
+ * @compile/ref=byfile.BA.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=byfile B.java A.java
+ */
+
+/*
+ * @test
+ * @compile/ref=bytodo.AB.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=bytodo A.java B.java
+ */
+
+/*
+ * @test
+ * @compile/ref=bytodo.BA.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=bytodo B.java A.java
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test2/byfile.AB.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,15 @@
+[attribute A]
+[flow A]
+[attribute B]
+[flow B]
+[desugar A]
+[generate code A.A1]
+[generate code A.A2]
+[generate code A.A3]
+[generate code A3m1]
+[generate code <anonymous A$A4$1>]
+[generate code A.A4]
+[generate code A]
+[desugar B]
+[generate code B.Inner]
+[generate code B]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test2/byfile.BA.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,15 @@
+[attribute B]
+[flow B]
+[desugar B]
+[generate code B.Inner]
+[generate code B]
+[attribute A]
+[flow A]
+[desugar A]
+[generate code A.A1]
+[generate code A.A2]
+[generate code A.A3]
+[generate code A3m1]
+[generate code <anonymous A$A4$1>]
+[generate code A.A4]
+[generate code A]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test2/bytodo.AB.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,15 @@
+[attribute A]
+[flow A]
+[attribute B]
+[flow B]
+[desugar A]
+[generate code A.A1]
+[generate code A.A2]
+[generate code A.A3]
+[generate code A3m1]
+[generate code <anonymous A$A4$1>]
+[generate code A.A4]
+[generate code A]
+[desugar B]
+[generate code B.Inner]
+[generate code B]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/policy/test2/bytodo.BA.out	Tue Sep 23 10:44:51 2008 -0700
@@ -0,0 +1,15 @@
+[attribute B]
+[flow B]
+[desugar B]
+[generate code B.Inner]
+[generate code B]
+[attribute A]
+[flow A]
+[desugar A]
+[generate code A.A1]
+[generate code A.A2]
+[generate code A.A3]
+[generate code A3m1]
+[generate code <anonymous A$A4$1>]
+[generate code A.A4]
+[generate code A]