Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/surroundWithTry/afterField.java
Tagir Valeev 6e87cb9bfd RefactoringUtil#ensureCodeBlock enhanced and used in Surround with try-catch
Fixes IDEA-178781 "Surround with try-catch" QuickFix for "Unhandled exception" in a field initializer
Enables stream-to-loop in field initializer
Fixes stream-to-loop in for initializer
Disables stream-to-loop in for update
2017-09-12 13:34:43 +07:00

19 lines
380 B
Java

// "Surround with try/catch" "true"
import java.io.IOException;
class C {
static final String S;
static {
try {
S = getString();
} catch (IOException e) {
e.printStackTrace();
}
}
static String getString() throws IOException {
if(Math.random() > 0.5) throw new IOException();
return "foo";
}
}