List of usage examples for org.eclipse.jdt.core JavaCore COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE
String COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE
To view the source code for org.eclipse.jdt.core JavaCore COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE.
Click Source Link
From source file:org.eclipse.objectteams.otdt.tests.otjld.other.Java7.java
License:Open Source License
@SuppressWarnings("unchecked") public void testA01_tryWithResources02() { String fileName = OUTPUT_DIR + "/p1/data.txt"; new File(OUTPUT_DIR + "/p1").mkdirs(); Util.writeToFile("Hello Reader", fileName); Map options = getCompilerOptions(); options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, JavaCore.ERROR); runTest(new String[] { "p1/TeamA01twr01.java", "package p1;\n" + "import java.io.*;\n" + "public team class TeamA01twr01 {\n" + " protected class ReaderRole implements AutoCloseable playedBy TA01twr01 {\n" + " public char[] content;\n" + " protected void read12() throws IOException {\n" + " content = new char[12];\n" + " read(content);\n" + " }\n" + " void read(char[] chars) -> int read(char[] chars);\n" + " close -> close;\n" + " }\n" + " void test(String filename) throws Exception {\n" + " try (ReaderRole r = new ReaderRole(new TA01twr01(filename))) {\n" + " r.read12();\n" + " System.out.println(String.valueOf(r.content));\n" + " }\n" + " } \n" + " public static void main(String[] args) throws Exception {\n" + " new TeamA01twr01().test(\"" + fileName + "\");\n" + " }\n" + "}", "p1/TA01twr01.java", "package p1;\n" + "import java.io.*;\n" + "public class TA01twr01 extends FileReader {\n" + " public TA01twr01(String fileName) throws IOException {\n" + " super(fileName);\n" + " }\n" + " @Override\n" + " public void close() {\n" + " try {\n" + " super.close();\n" + " System.out.println(\"closed\");\n" + " } catch (IOException ioe) {\n" + " ioe.printStackTrace();\n" + " }\n" + " }\n" + "}", }, false, // no comp err "", "Hello Reader\n" + "closed", "", true, // force exec null, // libs false, // should not flush null, // vm args options, null, // requestor true);// skip javac }