• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Java 8 in Action: Debugging Java 8 code

 
Greenhorn
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raoul-Gabriel, Mario, and Alan,

I noticed there is a chapter in the book on "Tools, testing, debugging". I wonder whether debugging remains manageable and intuitional in such concise code employing streams, lambda expressions and the :: operator. Did you already have the chance to gain experience in debugging Java 8 code in some IDE? For instance, have you tried stepping into a lambda expression?

Thanks and regards
Ralf
 
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting question. I just tried with the following code (in eclipse):



I put a breakpoint on the first line of main(...), and then stepped into debugLambda(...). I then stepped into function.apply(...), and the execution pointer jumped back to the lambda in main(...). The variables box in the debug perspective showed one local variable called 'string', that had the value "12". Looked perfectly sensible and usable to me.
 
Author
Posts: 26
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ralf,

we renamed the chapter "Refactoring, Testing, and Debugging". The new ToC will be updated soon and the content should be up shortly. In a nutshell, this chapter has more emphasis on refactoring: we discuss patterns to apply in your code and how typical object-oriented design patterns can be refactored using lambdas

Regarding debugging, you can set break points in a lambda expressions as you would normally do in your code. However, make sure the lambda is on multiple lines so you can set a line individually. Similarly for a stream pipeline. Instead of writing:

stream.filter().map().reduce()

You should write:

stream.filter()
.map()
.reduce()

So you can set break points on the individual operations.

The Debugging section specifically discusses on to examine stack traces (lambda expression makes things slightly less readable) and how to debugg/log information in a stream pipeline using the operation peek().

 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic