Bug 527086: [java9] Support Java 9
- fix failures in CompletionTests9 (missing deps config in new method)
- fix failures in Java9ElementTests (prematurely removed config)
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
index 1b341d8..1fb5621 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
@@ -2411,6 +2411,9 @@
 	}
 
 	private boolean checkForCNF(TypeReference ref, CompilationUnitDeclaration parsedUnit, boolean showAll) {
+//{ObjectTeams: protect:
+	  try (Config cfg = Dependencies.setup(this, this.parser, this.lookupEnvironment, true, true)) {
+// orig:
 		this.lookupEnvironment.buildTypeBindings(parsedUnit, null);
 		this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
 		parsedUnit.resolve();
@@ -2428,6 +2431,9 @@
 			parsedUnit.scope.faultInTypes();
 		}
 		return false; // should not come here - will throw exception
+// :giro
+	  }
+// SH}
 	}
 
 	private boolean completeOnPackageVisibilityStatements(boolean contextAccepted,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Config.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Config.java
index 19f7eaf..0df2f9e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Config.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Config.java
@@ -379,7 +379,7 @@
     	    {
     	        Config config = configStack.pop(); // remove Config
     		    assert(config != null);
-    		    if (--config.useCount > 0) {
+    		    if (--config.useCount > 0 && !configStack.contains(config)) {
     	            configStack.push(config); // still used
 					return;
 				}