-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate and replace Guava-using APIs in Scopes and QualifiedName #2978
base: main
Are you sure you want to change the base?
Conversation
@@ -486,7 +494,7 @@ public boolean startsWithIgnoreCase(QualifiedName prefix) { | |||
} | |||
|
|||
protected boolean startsWith(QualifiedName prefix, boolean ignoreCase) { | |||
Preconditions.checkArgument(prefix != null, "prefix must not be null"); | |||
Objects.requireNonNull(prefix, "prefix must not be null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now throws a NullPointerException
instead of an IllegalArgumentException
. I assume that's the reason for the test-failure.
Is that an acceptable change or should it continue to throw a IllegalArgumentException
if the argument is null?
87334e3
to
91bee50
Compare
91bee50
to
8e0c981
Compare
Just a quick comment, though I have yet to try that. If you pass a lambda expression to these methods, wouldn't you now get an ambiguous error from the Java compiler? |
The Guava interfaces extend the regular Java declarations. Thus the compiler would pick the more specific method and bind to the deprecated method. To get rid of deprecation warnings, client code would need to insert casts whenever a lambda expression was used. |
@szarnekow thanks! I'm not at a computer and I missed the inheritance relation. So no compilation error, but you need to cast to use the non deprecated version. Personally, I don't like that ;) |
Unfortunately, yes. I even had to add casts in this PR and I agree that that's not nice. The only alternative I see is to change the name of the replacement method or change its arguments if there are multiple. The latter is in my onion not so nice and not always possible. From a user-perspective, the former is not that bad. IIRC JDT now even offers a quick-fix to use the replacement (if only one method is mentioned in the |
I see another one: Accept the fact that Xtext and Xtext languages have a dependency on Guava. I may sound like a broken record, but please please pretty please let's carefully weigh our options wrt #2975 before jumping to conclusions and wasting time to change and/or review a ton of code. |
I'm all for discussing this, I just answered here first and my answer in #2975 took a bit time to write :) |
8e0c981
to
3eccb8a
Compare
Add new API methods in Scopes that usage
java.util.function.Function
instead ofcom.google.common.base.Function
andMap<K, Collection<V>>
instead ofMultimap<K, V>
and replace internal usages of Guava where simply possible.Part of #2975