Comments (13)
Been tinkering with this more. Copying over my notes shared elsewhere:
The generated lambdas do have to be decompiled by the IDE in the debugger, but they're pretty simple and easy to read once you understand the structure. Still not as nice as stepping through source though. Regular sources do show up in java 8 syntax. You even get the option to set a breakpoint on the lambda innards like normal java 8 code, except those breakpoints never actually get hit (which seems like a big minus).
The lack of being able to set a meaningful breakpoint seems pretty bad. Easy to trace back, once you hit one, but it's pretty much impossible to find the generated class that corresponds to a lambda without a breakpoint farther down the line. In light of that, I'm leaning toward not doing retrolambda.
For example: the following snippet
@Override
public final void onError(Throwable e) {
if (!isDisposed()) {
dispose();
try {
onError.accept(e); // Where onError was a method reference of a SingleObserver's onError
} catch (Exception e1) {
Exceptions.throwIfFatal(e1);
RxJavaPlugins.onError(new CompositeException(e, e1));
}
}
}
corresponds to this in the debugger when decompiled, where this is the actual backing implementation of the above onError
Consumer object in byte code:
// $FF: synthetic class
final class AutoDispose$AutoDisposingSingleObserverCreator$$Lambda$4 implements Consumer {
private final SingleObserver arg$1;
private AutoDispose$AutoDisposingSingleObserverCreator$$Lambda$4(SingleObserver var1) {
this.arg$1 = var1;
}
@Hidden
public void accept(Object var1) {
this.arg$1.onError((Throwable)var1);
}
public static Consumer lambdaFactory$(SingleObserver var0) {
return new AutoDispose$AutoDisposingSingleObserverCreator$$Lambda$4(var0);
}
}
Thoughts @tonycosentini @vinc3m1 @LukeStClair?
from autodispose.
We should prioritize debugging and using this over development IMO. It's not a huge thing - Java 7 isn't a big deal to me.
from autodispose.
With desugar coming to the android toolchain, should we move to Java 8 and assume people will use desugar?
from autodispose.
I would wait until stable release, but after that sure.
from autodispose.
What benefit does it give the library?
It seems like for consumers it adds a bit of friction for using this, no?
from autodispose.
It makes the library easier to read/write in by using the new syntax features. From a java library distribution standpoint - everyone writing a pure java project these days should really be on Java 8. On Android, with desugar, it should be zero friction since it all gets done at dexing.
from autodispose.
from autodispose.
I should have clarified - *when android gradle plugin 2.4 stable is released, not immediately.
from autodispose.
I'm not sure if you can assume that everyone will upgrade to 2.4 stable as soon as it is released. What is the downside of using Retrolambda until better adoption of newer tools?
from autodispose.
In testing with this, I found that consuming retrolambda'd libraries in Java 7 projects (retrolambda'd or not) actually added quite a bit of friction. Due to how the weaving works, you get no sources (only decompiled class files), and trying to step through them in the debugger is pretty hit or miss. Not to mention you can't actually open said generated classes due to not having sources, so you can't just go open them and set a breakpoint manually either :|.
The desugar approach they're taking with the gradle plugin actually works around this by treating the entire project as java 8 until you compile, at which point it will also desugar any Java 8-targeting libraries compiled with it.
from autodispose.
Another potential benefit: LifecycleScopeProvider could be moved to a separate (optional) artifact if we support default methods. It could just extend ScopeProvider and the default requestScope()
method would do the swizzling with a default implementation.
This works fine for android gradle projects, but could incur a nontrivial cost for buck/bazel builds where incremental compilation can't work some magic.
from autodispose.
Opened an issue on bazel to better understand how they avoid clean build churn - bazelbuild/bazel#4186
from autodispose.
Closing in favor of #198
from autodispose.
Related Issues (20)
- crash by fragment in removing state HOT 1
- ViewScopeProvider throws when Activity restarts. HOT 5
- Question: Incompatible with RxJava 2? HOT 4
- Unsubscribe unexpectedly when used in item of 'RecyclerView' inside 'ViewPager2' after page changed. HOT 1
- how to remove warning Missing Disposable handling: Apply AutoDispose or cache the Disposable instance manually and enable lenient mode. HOT 1
- I need AutoDispose proguard
- Help ,Why the main thread is required ? HOT 3
- Integrate kotlin ABI validator
- Please ignore
- Please ignore
- Obseravable called twice when completable scope. #416 HOT 3
- Unusable with lint 7.0.0-alpha14 (Jetpack Compose project) HOT 4
- How to use it in MVVM? HOT 2
- gradle 7.1 and AGP 7.0.0-beta05 HOT 3
- Snapshots and Building from source HOT 1
- Leak - DetachEventCompletable isn't removed when View is removed from ViewTree HOT 1
- lint lenient mode do not support kotlin lambda/when/if expressions HOT 1
- Question: how to implement a custom LifecycleScopeProvider HOT 1
- ERROR: R8: Missing class com.google.errorprone.annotations.DoNotMock (referenced from: autodispose2.ScopeProvider and 1 other context) HOT 3
- Service loader file missing in error prone plugin
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autodispose.