/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 7013272 7127924
* @summary Automatically generate info about how compiler resource keys are used
* @build Example ArgTypeCompilerFactory MessageFile MessageInfo
*/
/*
* See CR 7127924 for info on why othervm is used.
*/
/**
* Utility to manipulate compiler.properties, and suggest info comments based
* on information derived from running examples.
*
* Options:
* -examples dir location of examples directory
* -o file output file
* -check just check message file
* -ensureNewlines ensure newline after each entry
* -fixIndent fix indentation of continuation lines
* -sort sort messages
* -verbose verbose output
* -replace replace comments instead of merging comments
* file javac compiler.properties file
*
*/
public class MessageInfo {
if (jtreg) {
// use standard jtreg scratch directory: the current directory
} else {
MessageInfo.class.getName()
}
try {
return;
} finally {
/* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the
* jtreg scratch directory, which is the current directory.
* In case someone is faking jtreg mode, make sure to only
* clean tmpDir when it is reasonable to do so.
*/
if (tmpDir.isDirectory() &&
}
}
if (jtreg)
else
}
void usage() {
}
boolean verbose = false;
boolean ensureNewlines = false;
boolean fixIndent = false;
boolean sort = false;
boolean replace = false;
ensureNewlines = true;
fixIndent = true;
sort = true;
verbose = true;
replace = true;
check = true;
return false;
} else {
return false;
}
}
usage();
return true;
}
error("must set output file for these options");
return false;
}
if (notYetFile == null) {
}
d = d.getParentFile();
if (f.exists()) {
msgFile = f;
break;
}
}
}
if (jtreg) {
return true;
}
error("no message file available");
return false;
}
}
try {
} catch (IOException e) {
error("problem reading message file: " + e);
return false;
}
if (ensureNewlines)
if (fixIndent)
if (sort)
if (m == null) {
continue;
}
continue;
if (!replace) {
error("Cannot merge info for " + k);
else
}
}
} else
m.setInfo(suggestedInfo);
}
if (check)
try {
} catch (IOException e) {
error("problem writing file: " + e);
return false;
}
return (errors == 0);
}
if (notYetList == null)
else
}
}
}
l = l.next;
l.insertAfter("");
}
}
l = l.next;
}
}
}
l.remove();
}
}
}
continue;
if (colon == -1)
continue;
int i = 0;
}
}
}
return map;
}
/**
* Get the complete set of examples to be checked.
*/
if (isValidExample(f))
}
return results;
}
}
/**
* Get the contents of the "not-yet" list.
*/
try {
if (hash != -1)
}
} catch (IOException e) {
throw new Error(e);
}
return results;
}
/**
* Read the contents of a file.
*/
try {
} finally {
}
}
/**
* Report an error.
*/
errors++;
}
static boolean jtreg;
int errors;
/**
* Clean the contents of a directory.
*/
boolean ok = true;
if (f.isDirectory())
}
return ok;
}
}