--- a/langtools/test/tools/javac/doclint/DocLintTest.java Wed Oct 29 12:09:17 2014 +0100
+++ b/langtools/test/tools/javac/doclint/DocLintTest.java Wed Oct 29 17:25:23 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -109,44 +109,48 @@
void run() throws Exception {
javac = ToolProvider.getSystemJavaCompiler();
fm = javac.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
- file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
- @Override
- public CharSequence getCharContent(boolean ignoreEncoding) {
- return code;
- }
- };
+ try {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+ file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncoding) {
+ return code;
+ }
+ };
- test(Collections.<String>emptyList(),
- Main.Result.OK,
- EnumSet.noneOf(Message.class));
+ test(Collections.<String>emptyList(),
+ Main.Result.OK,
+ EnumSet.noneOf(Message.class));
- test(Arrays.asList("-Xdoclint:none"),
- Main.Result.OK,
- EnumSet.noneOf(Message.class));
+ test(Arrays.asList("-Xdoclint:none"),
+ Main.Result.OK,
+ EnumSet.noneOf(Message.class));
+
+ test(Arrays.asList(rawDiags, "-Xdoclint"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
+ Main.Result.OK,
+ EnumSet.of(Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
- Main.Result.OK,
- EnumSet.of(Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR9));
- test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR9));
+ test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
+ Main.Result.CMDERR,
+ EnumSet.of(Message.OPT_BADARG));
- test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
- Main.Result.CMDERR,
- EnumSet.of(Message.OPT_BADARG));
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ } finally {
+ fm.close();
+ }
}
void test(List<String> opts, Main.Result expectResult, Set<Message> expectMessages) {