-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
"bindFragment" Method Signature #95
Comments
Because that would crash your app if you're not using the support library,
|
That's not true since Donut.
|
What is not true and how? This has nothing to do with Android (or Donut for
|
It won't. We do this all the time. It only crashes when you reflect on the class' method list (which nobody will be doing). |
Here's an example: In Okio we include overloads for public static Source source(File file) { ... }
public static Source source(Path path, OpenOption... options) { ... } |
There's a difference between method symbols and class symbols. If I follow That is different from what the class loader does. The class loader will Again, feel free though to revert that change and test it out. I'm more
|
That was why I referenced Donut's behavior. It was the last class loader which actually did throw in this case (method parameter type or method return type not present). It's why when you look in the support-v4 library, for example, you see all these stupid indirections to conditionally load API-specific implementation classes. In Eclair and after it is either completely silent or just writes a log line. I can get a test of it going at some point (or someone else watching can). |
That I was totally unaware of. That's interesting indeed. Would love to see
|
Honestly, what's even the point of |
Never used it. Your reasoning certainly seems sounds. My only concern was from a pure API standpoint. |
We probably can just start off with deprecating those two (in a separate PR) and going from there. |
See my comments in the PR. These methods are safe guards against a race
|
@dlew continuing the discussion of #105 here. The original discussions are here: ReactiveX/RxJava#1292 There were also multiple discussions (and PRs) for adding variants of I do see though how it's also causing trouble at the same time, so finding some middle ground, e.g. by making this change very explicit would be nice. Relevant: #3 |
Ok, the way it stands now this will actually fail at compilation time, not runtime (see #136). This is because the methods become "pure" overloads of each other. That is, they have the same name, return type, number of parameters, and type of second parameter. They only differ by the type of the first parameter. In the very few times I've done this, the overloads have differed in some way even if that difference produces the same API at the call site. A prime example: varargs. Changing the support-v4 variant's method signature to the following: bindFragment(android.support.v4.app.Fragment fragment, Observable<T> source, Object... dummy) actually works! You can also rename the method to So, which do we like? |
A little late for a reply I guess, but I'd prefer |
Per my comment above, it does not work. |
Ah yes, I missed |
It takes
Object
and uses uglyinstanceof
and runtime API checks. Why not just have two overloads?The text was updated successfully, but these errors were encountered: