I'm looking for a definition of the parts that occurs around a lambda in the Java 8 stack trace
For example this code
Object inputData = someData();
myList.stream().forEach(listItem -> {
Query query = (Query) listItem.getSingle().apply(this.getId());
Object data = diffUtils.applyProjection(query, inputData);
myStringCollection.stream()
.filter(destination -> myPredicateMethod(listItem, destination))
.forEach(destination -> myProcessMethod(destination, data));
}
sometimes produces this exception.
at [CLASS].lambda$null$2([CLASS].java:85)
at [CLASS]$$Lambda$64/730559617.accept(Unknown Source)
What is the different parts describing in the exception? What is the "null", "2", "64", "730559617" and "Unknown Source" telling me?
A more elaborated example can be found here (but here the "null" in my exception above is not present). http://blog.takipi.com/the-dark-side-of-lambda-expressions-in-java-8/
Analyze external stack tracesFrom the main menu, select Code | Analyze Stack Trace or Thread Dump. In the Analyze Stack Trace dialog that opens, paste the external stack trace or thread dump into the Put a stacktrace here: text area. Click OK. The stack trace is displayed in the Run tool window.
The stack trace includes information about program subroutines and can be used to debug or troubleshoot and is often used to create log files. These exceptions could be custom (defined by the user) or built-in. Examples include RuntimeException , NullPointerException , and ArrayIndexOutofBoundsException .
A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.
The lambda code nested inside a method inside a class can access any effectively-final variables found within that method & class. Creating a class that implements the functional interface does not give you such direct access to the state of the calling code.
There is no standard definition for that this generated class name is. This is deliberate to avoid you writing code which depends on it making it harder for the designers to change it later.
That being said, what little you can read is;
$
is global counter for lambda. This depends on the order in which code for lambdas is generated.The "Unknown Source" is telling you this generated code has no debug information associated with it.
We are looking at a library for changing the toString for a lambda to give you an idea of code associated with it. i.e. it will look like the code of the lambda at least for trivial cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With