langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
changeset 40837 d071bcc8d32e
parent 40606 eb2c81860c86
child 41527 e8f487b79e24
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Wed Sep 07 12:15:22 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Thu Sep 08 15:48:28 2016 +0200
@@ -838,8 +838,31 @@
     }
 
     private Stream<Element> localElements(Scope scope) {
-        @SuppressWarnings("unchecked")
-        Stream<Element> elements = Util.stream((Iterable<Element>)scope.getLocalElements());
+        //workaround for: JDK-8024687
+        Iterable<Element> elementsIt = () -> new Iterator<Element>() {
+            Iterator<? extends Element> it = scope.getLocalElements().iterator();
+            @Override
+            public boolean hasNext() {
+                while (true) {
+                    try {
+                        return it.hasNext();
+                    } catch (CompletionFailure cf) {
+                        //ignore...
+                    }
+                }
+            }
+            @Override
+            public Element next() {
+                while (true) {
+                    try {
+                        return it.next();
+                    } catch (CompletionFailure cf) {
+                        //ignore...
+                    }
+                }
+            }
+        };
+        Stream<Element> elements = Util.stream(elementsIt);
 
         if (scope.getEnclosingScope() != null &&
             scope.getEnclosingClass() != scope.getEnclosingScope().getEnclosingClass()) {