-
Bug
-
Resolution: Fixed
-
P2
-
8
-
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
-