-
Bug
-
Resolution: Fixed
-
P3
-
11, 13, 15, 17
-
b27
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8278691 | 19 | Liam Miller-Cushon | P3 | Resolved | Fixed | team |
JDK-8310248 | 17.0.9-oracle | Vicente Arturo Romero Zaldivar | P3 | Resolved | Fixed | b01 |
JDK-8308649 | 17.0.8 | Yuri Nesterenko | P3 | Resolved | Fixed | b04 |
JDK-8310247 | 11.0.21-oracle | Vicente Arturo Romero Zaldivar | P3 | Resolved | Fixed | b01 |
JDK-8308925 | 11.0.20 | Yuri Nesterenko | P3 | Resolved | Fixed | b05 |
================================================
import java.util.stream.LongStream;
public class TestLambdas {
public static void main(String[] args) {
new TestLambdas().execute(0, 5);
}
public boolean assertLong(long l, long forbidden) {
if (l == forbidden) {
throw new AssertionError(forbidden);
}
return true;
}
public boolean assertLong2(long l, long forbidden) {
if (l == forbidden) {
throw new AssertionError(forbidden);
}
return true;
}
public void execute(long first, long last) {
for (int i = 0; i < 1000; i++) {
long forbidden = 4 + i;
System.out.println("first");
LongStream.range(first, 4).forEachOrdered((l) ->
assertLong(l, forbidden)
);
System.out.println("Second");
LongStream.range(first, last).forEachOrdered((l) ->
assertLong(l, forbidden)
);
System.out.println("Done");
}
}
}
================================================
An exception should be raised by the second lambda invocation, at line 31.
But the exception that gets printed says that it happened at line 27, which is not possible:
Exception in thread "main" java.lang.AssertionError: 4
at TestLambdas.assertLong(TestLambdas.java:10)
at TestLambdas.lambda$execute$0(TestLambdas.java:27)
at java.base/java.util.stream.Streams$RangeLongSpliterator.forEachRemaining(Streams.java:228)
at java.base/java.util.stream.LongPipeline$Head.forEachOrdered(LongPipeline.java:610)
at TestLambdas.execute(TestLambdas.java:30)
at TestLambdas.main(TestLambdas.java:5)
If run in the IDE instead the same code reports the correct location:
Exception in thread "main" java.lang.AssertionError: 4
at TestLambdas.assertLong(TestLambdas.java:10)
at TestLambdas.lambda$execute$1(TestLambdas.java:31)
at java.base/java.util.stream.Streams$RangeLongSpliterator.forEachRemaining(Streams.java:228)
at java.base/java.util.stream.LongPipeline$Head.forEachOrdered(LongPipeline.java:610)
at TestLambdas.execute(TestLambdas.java:30)
at TestLambdas.main(TestLambdas.java:5)
- backported by
-
JDK-8278691 Incorrect line number reported in exception stack trace thrown from a lambda expression
- Resolved
-
JDK-8308649 Incorrect line number reported in exception stack trace thrown from a lambda expression
- Resolved
-
JDK-8308925 Incorrect line number reported in exception stack trace thrown from a lambda expression
- Resolved
-
JDK-8310247 Incorrect line number reported in exception stack trace thrown from a lambda expression
- Resolved
-
JDK-8310248 Incorrect line number reported in exception stack trace thrown from a lambda expression
- Resolved
- relates to
-
JDK-8200301 deduplicate lambda methods
- Resolved
-
JDK-8318712 Lambda deduplication does not work when debugging info is generated
- Closed
- links to
-
Commit openjdk/jdk11u-dev/682728ef
-
Commit openjdk/jdk17u-dev/9cb01207
-
Commit openjdk/jdk/d7c283a0
-
Review openjdk/jdk11u-dev/1904
-
Review openjdk/jdk17u-dev/702
-
Review openjdk/jdk/6733