• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lambadas and Debugging

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 20
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 20
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic