Skip to content

In Android Studio debugger, enclosing class file's instance is not available #130

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jeff-huston opened this issue Apr 19, 2017 · 1 comment

Comments

@jeff-huston
Copy link

Test Project:

https://github.com/hustoj2/RetrolambdaDebuggerReducedTestCase

Environment:

Android Studio 2.3.1
Build #AI-162.3871768, built on April 1, 2017
JRE: 1.8.0_112-release-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

gradle-retrolambda 3.6.0 (the version of gradle-retrolambda doesn't appear to matter)

retrolambda versions affected

  • 2.5.0
  • 2.5.1

Test Steps:

  1. Clone https://github.com/hustoj2/RetrolambdaDebuggerReducedTestCase
  2. Set breakpoint at MainActivity line 27 (Snackbar#make()) within the lambda
  3. Set app's build.gradle to retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.4.0' (should already be set to this on master)
  4. gradlew clean assemble --refresh-dependencies
  5. perform gradle sync
  6. debug app
  7. Results: MainActivity.this IS accessible from debugger
  8. Change app's build.gradle to retrolambdaConfig 2.5.0
  9. gradlew clean assemble --refresh-dependencies
  10. perform gradle sync
  11. debug app on same emulator/device
  12. Results: MainActivity.this IS NOT accessible from debugger
  13. Change app's build.gradle back to retrolambdaConfig 2.4.0
  14. gradlew clean assemble --refresh-dependencies
  15. perform gradle sync
  16. debug app on same emulator/device
  17. Results: MainActivity.this IS accessible from debugger again

Notes:

  • Setting any breakpoints outside the lambda behaves as expected.
  • When setting a breakpoint within this lambda, the debugger cannot access the MainActivity instance, its member variables, or instance methods. This is true within Android Studio's Variables window, Watches window, and Evaluate Expression window.
  • MainActivity.this is always accessible within the lambda from the code itself; just not during debugging
  • If I change the reference to MainActivity.this to reference the isAccessibleFromLambda member variable instead, I get the same behavior with the above steps.
  • If I remove any reference to the enclosing class file's instance from within the lambda, then even on retrolambda:2.4.0 I still can't access MainActivity.this within the debugger at that breakpoint. I'd still prefer to be able to have access to the enclosing class file's instance in that case, but I'm not sure what the expected behavior is in that case based on how retrolambda works.
  • The same behavior was exhibited with older versions of gradle-retrolambda. Originally I observed the different behavior between gradle-retrolambda:3.4.0 and gradle-retrolambda:3.5.0, but I believe I've traced that back to the default version of retrolambda that gets pulled in by those versions of gradle-retrolambda. The differentiating factor appears to be the version of the retrolambda dependency that gets pulled in.
@luontola
Copy link
Owner

luontola commented Dec 28, 2017

Looks like Android Studio 3.0.1 is smarter and can show this.

screenshot

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants