RFR: 8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
Langer, Christoph
christoph.langer at sap.com
Mon May 13 07:29:28 UTC 2019
Hi Daniel,
unfortunately, your proposed solution does not work with javac. I get this in the build:
...\mercurial\jdk\src\java.net.http\share\classes\jdk\internal\net\http\ExchangeImpl.java:103: error: method thenCompose in class CompletableFuture<T> cannot be applied to given types;
return c2f.handle(factory).thenCompose(identity);
^
required: Function<? super CompletableFuture<? extends ExchangeImpl<U#1>>,? extends CompletionStage<U#2>>
found: Function<CompletableFuture<? extends ExchangeImpl<U#1>>,CompletableFuture<? extends ExchangeImpl<U#1>>>
reason: cannot infer type-variable(s) U#2
(argument mismatch; Function<CompletableFuture<? extends ExchangeImpl<U#1>>,CompletableFuture<? extends ExchangeImpl<U#1>>> cannot be converted to Function<? super CompletableFuture<? extends ExchangeImpl<U#1>>,? extends CompletionStage<U#2>>)
where U#1,U#2,T are type-variables:
U#1 extends Object declared in method <U#1>get(Exchange<U#1>,HttpConnection)
U#2 extends Object declared in method <U#2>thenCompose(Function<? super T,? extends CompletionStage<U#2>>)
T extends Object declared in class CompletableFuture
1 error
So I think we need to go back to my initial proposal which works for both, IDE and javac: http://cr.openjdk.java.net/~clanger/webrevs/8223553.0/
Thanks
Christoph
> -----Original Message-----
> From: Langer, Christoph
> Sent: Freitag, 10. Mai 2019 11:17
> To: Daniel Fuchs <daniel.fuchs at oracle.com>; core-libs-dev <core-libs-
> dev at openjdk.java.net>; net-dev <net-dev at openjdk.java.net>
> Cc: compiler-dev at openjdk.java.net
> Subject: RE: RFR: 8223553: Fix code constructs that do not compile with the
> Eclipse Java Compiler
>
> Hi Daniel,
>
> I fully agree, @SuppressWarnings should be avoided wherever possible.
>
> So, thanks for coming up with this alternative suggestion. It works and so I
> updated my webrev:
> http://cr.openjdk.java.net/~clanger/webrevs/8223553.1/
>
> Any reviews for the other 3 files?
>
> Thanks
> Christoph
>
> > -----Original Message-----
> > From: Daniel Fuchs <daniel.fuchs at oracle.com>
> > Sent: Donnerstag, 9. Mai 2019 17:24
> > To: Langer, Christoph <christoph.langer at sap.com>; core-libs-dev <core-
> libs-
> > dev at openjdk.java.net>; net-dev <net-dev at openjdk.java.net>
> > Cc: compiler-dev at openjdk.java.net
> > Subject: Re: RFR: 8223553: Fix code constructs that do not compile with the
> > Eclipse Java Compiler
> >
> > Hi Christoph,
> >
> > I'm only commenting on the HttpClient changes, I'll let
> > others comment on the other changes...
> >
> >
> http://cr.openjdk.java.net/~clanger/webrevs/8223553.0/src/java.net.http/s
> > hare/classes/jdk/internal/net/http/ExchangeImpl.java.udiff.html
> >
> > I have a profound dislike for using @SuppressedWarnings, unless
> > it's the only alternative. My preference would be to introduce
> > local variables, if that can make the compiler happy, until such time
> > where the issue is actually resolved...
> >
> > For instance, it seems that the following would work:
> >
> > // Use local variable assignments to keep other java compilers
> > // happy and avoid unchecked casts warnings
> > BiFunction<Http2Connection, Throwable, CompletableFuture<? extends
> > ExchangeImpl<U>>>
> > factory = (h2c, t) -> createExchangeImpl(h2c, t, exchange,
> > connection);
> > Function<CompletableFuture<? extends ExchangeImpl<U>>,
> > CompletableFuture<? extends ExchangeImpl<U>>>
> > identity = (cf) -> cf;
> > return c2f.handle(factory).thenCompose(identity);
> >
> >
> > best regards,
> >
> > -- daniel
> >
> > On 08/05/2019 09:02, Langer, Christoph wrote:
> > > Hi,
> > >
> > > please review a small change that I'd like to see in OpenJDK to get rid
> > > of compilation errors in the Eclipse IDE.
> > >
> > > It seems the root cause for the compilation errors is that javac would
> > > sometimes widen capture variables and is hence able to compile the
> > > places that I touch here. The EC4J compiler claims that it's following
> > > the spec more strictly and bails out at these places. I had posted about
> > > this on compiler-dev but got no reaction [0].
> > >
> > > So, as this seems to be some field of open work for the compiler/spec
> > > folks, I'd like to get EC4J quiesced by introducing some slight
> > > modifications to the original places which makes the code appeal a bit
> > > less elegant and fluent but will get rid of the compile errors.
> > >
> > > Please review:
> > >
> > > Bug: https://bugs.openjdk.java.net/browse/JDK-8223553
> > >
> > > Webrev: http://cr.openjdk.java.net/~clanger/webrevs/8223553.0/
> > >
> > > The modification to
> > >
> >
> src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.jav
> > a
> > > belongs to JSR-166, so I don't know if it needs some special handling.
> > >
> > > Thanks & Best regards
> > >
> > > Christoph
> > >
> > > [0]
> > > https://mail.openjdk.java.net/pipermail/compiler-dev/2019-
> > March/013054.html
> > >
More information about the net-dev
mailing list