jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William L Thomson Jr (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JCLOUDS-1333) Cannot compile jclouds with Guava 21+
Date Fri, 16 Feb 2018 07:29:00 GMT

    [ https://issues.apache.org/jira/browse/JCLOUDS-1333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16366674#comment-16366674
] 

William L Thomson Jr commented on JCLOUDS-1333:
-----------------------------------------------

Finally figured out what is going wrong here. Seems static function imports are bad.

Changing
import static com.google.common.base.Functions.compose;
to
import com.google.common.base.Functions;

Then replacing compose with Functions.compose, and it builds fine under Java  9. In fact there
are other issues with static imports. It seems the compiler confuses them with internal classes.
From what I have seen, unless there is a need or benefit to static imports of methods. I would
avoid such and just import the classes and call the methods via Class.method. The shorthand
is seeming to cause issues, and not worth it IMHO.

Now the real issue will come from having to change some other methods. getHostText is now
getHost. Not sure how you all want to handle that, but either need different classes or to
modify sources based on version of guava. That is basically all the guava changes. There are
some other for gson.

You can see me making the changes via sed.
https://github.com/Obsidian-StudiosInc/os-xtoo/blob/master/dev-java/jclouds-core/jclouds-core-9999.ebuild#L55

PR to fix just this issue, should be good under any java version
https://github.com/jclouds/jclouds/pull/1180

> Cannot compile jclouds with Guava 21+
> -------------------------------------
>
>                 Key: JCLOUDS-1333
>                 URL: https://issues.apache.org/jira/browse/JCLOUDS-1333
>             Project: jclouds
>          Issue Type: Improvement
>          Components: jclouds-core
>    Affects Versions: 2.1.0
>            Reporter: Andrew Gaul
>            Priority: Major
>              Labels: guava
>
> jclouds has compatibility with Guava 18-22 but we cannot compile using 21+ due to some
kind of Guava vs Java 8 Function class type error:
> {noformat}
> /home/gaul/work/jclouds/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java:102:
error: method compose in interface java.util.function.Function<T,R> cannot be applied
to given types;
>          transformer = compose(Function.class.cast(wrappingTransformer), transformer);
>                        ^
>   required: java.util.function.Function<? super V,? extends HttpRequest>
>   found:    com.google.common.base.Function,com.google.common.base.Function<HttpResponse,CAP#1>
>   reason: cannot infer type-variable(s) V
>     (actual and formal argument lists differ in length)
>   where V,T,R are type-variables:
>     V extends Object declared in method <V>compose(java.util.function.Function<?
super V,? extends T>)
>     T extends Object declared in interface java.util.function.Function
>     R extends Object declared in interface java.util.function.Function
>   where CAP#1 is a fresh type-variable:
>     CAP#1 extends Object from capture of ?
> /home/gaul/work/jclouds/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java:189:
error: method compose in interface java.util.function.Function<T,R> cannot be applied
to given types;
>             transformer = compose(new OnlyElementOrNull(), transformer);
>                           ^
>   required: java.util.function.Function<? super V,? extends HttpRequest>
>   found:    OnlyElementOrNull,com.google.common.base.Function<HttpResponse,CAP#1>
>   reason: cannot infer type-variable(s) V
>     (actual and formal argument lists differ in length)
>   where V,T,R are type-variables:
>     V extends Object declared in method <V>compose(java.util.function.Function<?
super V,? extends T>)
>     T extends Object declared in interface java.util.function.Function
>     R extends Object declared in interface java.util.function.Function
>   where CAP#1 is a fresh type-variable:
>     CAP#1 extends Object from capture of ?
> {noformat}
> This does not affect applications from using Guava 21-22 but does impact our compatibility
testing.  Note that you need to set {{maven.compile.source}} to 1.8 to test Guava 21+.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message