• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lambadas and Debugging  RSS feed

 
Maciek Stoszko
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lambadas are great, their power of expression is remarkable. However I do find it difficult, if not frustrating, debugging the "lambda" code. There does not seem to be a good "lambda support" in the debuggers in (Intellij or Eclipse), they seem to be loosing the context for the code being investigated. Any hints on how to deal with it?

Regards,
Maciej
 
Stephan van Hulst
Saloon Keeper
Posts: 6985
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch Maciek!

Keep your lambdas short! If it's anything more than a little expression with a few operators, write a method instead, and pass a method reference instead of a lambda. When the method is applied, your IDE should be able to debug it normally.
 
Roel De Nijs
Marshal
Posts: 11004
161
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maciek Stoszko,

First of all, a warm welcome to CodeRanch!

There does not seem to be a good "lambda support" in the debuggers in (Intellij or Eclipse), they seem to be loosing the context for the code being investigated. Any hints on how to deal with it?

A few months ago I had a similar question about how to debug lambdas.

Hope it helps!
Kind regards,
Roel

PS. If you really want to debug the forbidden dance, I think you should start with carefully watching the video
 
Maurice Naftalin
Author
Greenhorn
Posts: 20
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maciej

It's taken me a while to answer this question because I wanted to see what debugger support for lambdas is currently like. It hasn't been good in the past – blog posts like this have complained about the problem you mention, of losing the context (local variables in the enclosing method). Actually I don't think the problem was ever that serious, since you could always drop back to the stack frame for the enclosing method, but it was inconvenient. Now, though, the underlying JDK bug that caused that problem is fixed (as of 8u60b25 – last month, I think), and according to this thread the symptoms have gone from Netbeans and Intellij Idea. I haven't checked this myself, I'm afraid.

The problems of debugging stream code are something else – but you didn't ask about them

Regards
Maurice
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't grant the cow simply for that post, but for the great effort you have put in to answering questions on this forum in the last week. Thank you
 
Maurice Naftalin
Author
Greenhorn
Posts: 20
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much, Campbell. It's taken me a while sometimes, but I've answered nearly all of them – only one left to go! There have been some interesting questions amongst them – many thanks to the people who asked them, and many thanks to JavaRanch for having me!

Regards
Maurice
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!