mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
lambda: catch exception by SAM method substitution (IDEA-116441)
(cherry picked from commit 0bce39590bdcc6e6a74c0dcedbb02add3333e685)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class Main48 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
templateMethod(( ) -> {
|
||||
throw new IOException();
|
||||
});
|
||||
}
|
||||
|
||||
static void templateMethod(RunnableWithException<IOException> r) {
|
||||
try {
|
||||
r.run();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
interface RunnableWithException<E extends Exception> {
|
||||
void run() throws E;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user