-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P2
-
Affects Version/s: 8
-
Component/s: docs
-
Verified
For a code like:
import java.io.IOException;
class LambdaWithMultiCatch {
public static void main(String[] args) {
Runnable r = () -> {
try {
throw new IOException();
} catch(IOException | IllegalArgumentException e) {
System.out.println("This code will generate a wrong exception table");
}
};
r.run();
}
}
javac will generate an incorrect exception table for method main. The generated exception table will look like:
Exception table:
from to target type
0 8 8 Class java/lang/Exception <---- no trace of IOException nor IllegalArgumentException
This is a known issue and developers should avoid using multi-catch statements inside lambda bodies till this issue is fixed.
import java.io.IOException;
class LambdaWithMultiCatch {
public static void main(String[] args) {
Runnable r = () -> {
try {
throw new IOException();
} catch(IOException | IllegalArgumentException e) {
System.out.println("This code will generate a wrong exception table");
}
};
r.run();
}
}
javac will generate an incorrect exception table for method main. The generated exception table will look like:
Exception table:
from to target type
0 8 8 Class java/lang/Exception <---- no trace of IOException nor IllegalArgumentException
This is a known issue and developers should avoid using multi-catch statements inside lambda bodies till this issue is fixed.
- relates to
-
JDK-8036942 javac generates incorrect exception table for multi-catch statements inside a lambda
-
- Closed
-