Index: /trunk/ProjectFortress/src/com/sun/fortress/repository/GraphRepository.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/repository/GraphRepository.java (revision 3288)
+++ /trunk/ProjectFortress/src/com/sun/fortress/repository/GraphRepository.java (revision 3289)
@@ -460,5 +460,8 @@
                 @Override
                 public Boolean apply(GraphNode g){
-                    return g instanceof ApiGraphNode && staleOrDependsOnStale.get(g);
+                    return g instanceof ApiGraphNode && (staleOrDependsOnStale.get(g) ||
+                            // TODO need to fix the whole date-stamp thing for APIs.
+                            foreignJava.definesApi(((ApiGraphNode)g).getName())
+                            );
                 }
             };
@@ -628,10 +631,14 @@
         try{
             APIName api_name = node.getName();
-            File fdot = findFile(api_name, ProjectProperties.API_SOURCE_SUFFIX);
-            CompilationUnit api = Parser.parseFileConvertExn(fdot);
-            if (api instanceof Api) {
-                return (Api) api;
+            if (foreignJava.definesApi(api_name)) {
+                return (Api) foreignJava.fakeApi(api_name).ast();
             } else {
-                throw StaticError.make("Unexpected parse of API " + api_name, "");
+                File fdot = findFile(api_name, ProjectProperties.API_SOURCE_SUFFIX);
+                CompilationUnit api = Parser.parseFileConvertExn(fdot);
+                if (api instanceof Api) {
+                    return (Api) api;
+                } else {
+                    throw StaticError.make("Unexpected parse of API " + api_name, "");
+                }
             }
         } catch ( FileNotFoundException e ){
Index: /trunk/ProjectFortress/src/com/sun/fortress/repository/ForeignJava.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/repository/ForeignJava.java (revision 3288)
+++ /trunk/ProjectFortress/src/com/sun/fortress/repository/ForeignJava.java (revision 3289)
@@ -64,6 +64,6 @@
 public class ForeignJava {
 
-    /** given an API Name, what Java classes does it import?  (Name of existing
-     * Java class, not its wrapper.)
+    /** given an API Name, what Java classes does it import?  (Existing
+     * Java class, not its compiled Fortress wrapper class.)
      */
     MultiMap<APIName, Class> javaImplementedAPIs = new MultiMap<APIName, Class>();
@@ -263,4 +263,9 @@
         generatedImports.putItem(importing_package, api_name);
         
+        /*
+         * Ensure that the API and class appear.
+         */
+        javaImplementedAPIs.putItem(api_name,imported_class);
+        
         Id name = NodeFactory.makeId(span, imported_class.getSimpleName());
         
@@ -396,20 +401,10 @@
             Set<APIName> gi = generatedImports.get(name);
             if (gi != null)
-            for (APIName a : gi) {
-                AliasedAPIName aan = NodeFactory.makeAliasedAPIName(a);
-                /*
-                 * Hoping to lie, slightly, to static analysis. This is
-                 * technically speaking a "foreign" import, but the import is
-                 * already known to the ForeignJava data structures, and this
-                 * allows use of fully qualified (hence unambiguous) references
-                 * to classes from other packages in the generated API.
-                 * 
-                 * So, one lie -- no foreign annotation.
-                 */
-                ImportApi iapi = NodeFactory.makeImportApi(span, Option
-                        .<String> none(), Useful.list(aan));
-                imports.add(iapi);
-            }
-
+                for (APIName a : gi) {
+                    importAnApi(imports, a);
+                }
+            // Implicitly import.
+            importAnApi(imports, NodeFactory.makeAPIName(span, "FortressLibrary"));
+            
             List<Decl> decls = new ArrayList<Decl>();
             for (Decl d : apiToStaticDecls.get(name)) {
@@ -422,5 +417,22 @@
         }
         return result;
-        
+
+    }
+
+    private void importAnApi(List<Import> imports, APIName a) {
+        AliasedAPIName aan = NodeFactory.makeAliasedAPIName(a);
+        /*
+         * Hoping to lie, slightly, to static analysis. This is
+         * technically speaking a "foreign" import, but the import
+         * is already known to the ForeignJava data structures, and
+         * this allows use of fully qualified (hence unambiguous)
+         * references to classes from other packages in the
+         * generated API.
+         * 
+         * So, one lie -- no foreign annotation.
+         */
+        ImportApi iapi = NodeFactory.makeImportApi(span, Option
+                .<String> none(), Useful.list(aan));
+        imports.add(iapi);
     }
     
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java (revision 3246)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java (revision 3289)
@@ -1,4 +1,4 @@
 /*******************************************************************************
-    Copyright 2008 Sun Microsystems, Inc.,
+    Copyright 2009 Sun Microsystems, Inc.,
     4150 Network Circle, Santa Clara, California 95054, U.S.A.
     All rights reserved.
@@ -303,4 +303,6 @@
             Option<APIName> realApiOpt = _env.apiName(originalApi);
             if (realApiOpt.isNone()) {
+                // retry for debugging purposes
+                realApiOpt = _env.apiName(originalApi);
                 error("Undefined API: " + NodeUtil.nameString(originalApi), originalApi);
                 return that;
Index: /trunk/ProjectFortress/not_passing_yet/trivialForeignImport.fss
===================================================================
--- /trunk/ProjectFortress/not_passing_yet/trivialForeignImport.fss (revision 3289)
+++ /trunk/ProjectFortress/not_passing_yet/trivialForeignImport.fss (revision 3289)
@@ -0,0 +1,26 @@
+(*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+ ******************************************************************************)
+
+component trivialForeignImport
+import java java.util.{Map, Map.Entry}
+export Executable
+
+run(args:String...) = do
+ println("Hello, World!")
+end
+
+end
