8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
authorclanger
Fri, 24 May 2019 07:56:29 +0100
changeset 55022 9785b9fb328e
parent 55021 d84176dd57b0
child 55023 d56d8e40b6cd
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler Reviewed-by: smarks, dfuchs
src/java.base/share/classes/java/lang/invoke/MethodHandles.java
src/java.management/share/classes/java/lang/management/ManagementFactory.java
src/java.net.http/share/classes/jdk/internal/net/http/ExchangeImpl.java
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu May 23 18:47:24 2019 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Fri May 24 07:56:29 2019 +0100
@@ -4980,8 +4980,10 @@
 
         // Step 1C: determine loop return type.
         // Step 1D: check other types.
-        final Class<?> loopReturnType = fini.stream().filter(Objects::nonNull).map(MethodHandle::type).
-                map(MethodType::returnType).findFirst().orElse(void.class);
+        // local variable required here; see JDK-8223553
+        Stream<Class<?>> cstream = fini.stream().filter(Objects::nonNull).map(MethodHandle::type)
+                .map(MethodType::returnType);
+        final Class<?> loopReturnType = cstream.findFirst().orElse(void.class);
         loopChecks1cd(pred, fini, loopReturnType);
 
         // Step 2: determine parameter lists.
--- a/src/java.management/share/classes/java/lang/management/ManagementFactory.java	Thu May 23 18:47:24 2019 -0700
+++ b/src/java.management/share/classes/java/lang/management/ManagementFactory.java	Fri May 24 07:56:29 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. 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
@@ -872,12 +872,13 @@
     public static Set<Class<? extends PlatformManagedObject>>
            getPlatformManagementInterfaces()
     {
-        return platformComponents()
+        // local variable required here; see JDK-8223553
+        Stream<Class<? extends PlatformManagedObject>> pmos = platformComponents()
                 .stream()
                 .flatMap(pc -> pc.mbeanInterfaces().stream())
                 .filter(clazz -> PlatformManagedObject.class.isAssignableFrom(clazz))
-                .map(clazz -> clazz.asSubclass(PlatformManagedObject.class))
-                .collect(Collectors.toSet());
+                .map(clazz -> clazz.asSubclass(PlatformManagedObject.class));
+        return pmos.collect(Collectors.toSet());
     }
 
     private static final String NOTIF_EMITTER =
--- a/src/java.net.http/share/classes/jdk/internal/net/http/ExchangeImpl.java	Thu May 23 18:47:24 2019 -0700
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/ExchangeImpl.java	Fri May 24 07:56:29 2019 +0100
@@ -26,14 +26,15 @@
 package jdk.internal.net.http;
 
 import java.io.IOException;
+import java.net.http.HttpClient;
+import java.net.http.HttpResponse;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Executor;
-import java.util.function.Function;
-import java.net.http.HttpClient;
-import java.net.http.HttpResponse;
+
 import jdk.internal.net.http.common.Logger;
 import jdk.internal.net.http.common.MinimalFuture;
 import jdk.internal.net.http.common.Utils;
+
 import static java.net.http.HttpClient.Version.HTTP_1_1;
 
 /**
@@ -92,8 +93,10 @@
             CompletableFuture<Http2Connection> c2f = c2.getConnectionFor(request, exchange);
             if (debug.on())
                 debug.log("get: Trying to get HTTP/2 connection");
-            return c2f.handle((h2c, t) -> createExchangeImpl(h2c, t, exchange, connection))
-                    .thenCompose(Function.identity());
+            // local variable required here; see JDK-8223553
+            CompletableFuture<CompletableFuture<? extends ExchangeImpl<U>>> fxi =
+                c2f.handle((h2c, t) -> createExchangeImpl(h2c, t, exchange, connection));
+            return fxi.thenCompose(x->x);
         }
     }