mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
6507179: javadoc -source 1.3 does not work with jdk6
Reviewed-by: mcimadamore
This commit is contained in:
parent
f33c28c7fb
commit
dd0f4f4cc6
5 changed files with 151 additions and 42 deletions
|
@ -100,9 +100,12 @@ public class Check {
|
||||||
|
|
||||||
boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
|
boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
|
||||||
boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED);
|
boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED);
|
||||||
|
boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings();
|
||||||
|
|
||||||
deprecationHandler = new MandatoryWarningHandler(log,verboseDeprecated, "deprecated");
|
deprecationHandler = new MandatoryWarningHandler(log, verboseDeprecated,
|
||||||
uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked, "unchecked");
|
enforceMandatoryWarnings, "deprecated");
|
||||||
|
uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked,
|
||||||
|
enforceMandatoryWarnings, "unchecked");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Switch: generics enabled?
|
/** Switch: generics enabled?
|
||||||
|
|
|
@ -34,7 +34,6 @@ import java.util.Set;
|
||||||
import javax.tools.DiagnosticListener;
|
import javax.tools.DiagnosticListener;
|
||||||
import javax.tools.JavaFileObject;
|
import javax.tools.JavaFileObject;
|
||||||
|
|
||||||
import com.sun.tools.javac.code.Source;
|
|
||||||
import com.sun.tools.javac.file.JavacFileManager;
|
import com.sun.tools.javac.file.JavacFileManager;
|
||||||
import com.sun.tools.javac.tree.JCTree;
|
import com.sun.tools.javac.tree.JCTree;
|
||||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||||
|
@ -86,10 +85,6 @@ public class Log {
|
||||||
*/
|
*/
|
||||||
public boolean emitWarnings;
|
public boolean emitWarnings;
|
||||||
|
|
||||||
/** Enforce mandatory warnings.
|
|
||||||
*/
|
|
||||||
private boolean enforceMandatoryWarnings;
|
|
||||||
|
|
||||||
/** Print stack trace on errors?
|
/** Print stack trace on errors?
|
||||||
*/
|
*/
|
||||||
public boolean dumpOnError;
|
public boolean dumpOnError;
|
||||||
|
@ -138,9 +133,6 @@ public class Log {
|
||||||
DiagnosticListener<? super JavaFileObject> diagListener =
|
DiagnosticListener<? super JavaFileObject> diagListener =
|
||||||
context.get(DiagnosticListener.class);
|
context.get(DiagnosticListener.class);
|
||||||
this.diagListener = diagListener;
|
this.diagListener = diagListener;
|
||||||
|
|
||||||
Source source = Source.instance(context);
|
|
||||||
this.enforceMandatoryWarnings = source.enforceMandatoryWarnings();
|
|
||||||
}
|
}
|
||||||
// where
|
// where
|
||||||
private int getIntOption(Options options, String optionName, int defaultValue) {
|
private int getIntOption(Options options, String optionName, int defaultValue) {
|
||||||
|
@ -473,10 +465,7 @@ public class Log {
|
||||||
* @param args Fields of the warning message.
|
* @param args Fields of the warning message.
|
||||||
*/
|
*/
|
||||||
public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) {
|
public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) {
|
||||||
if (enforceMandatoryWarnings)
|
|
||||||
report(diags.mandatoryWarning(source, pos, key, args));
|
report(diags.mandatoryWarning(source, pos, key, args));
|
||||||
else
|
|
||||||
report(diags.warning(source, pos, key, args));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Report a warning that cannot be suppressed.
|
/** Report a warning that cannot be suppressed.
|
||||||
|
@ -513,14 +502,28 @@ public class Log {
|
||||||
report(diags.note(source, wrap(pos), key, args));
|
report(diags.note(source, wrap(pos), key, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Provide a non-fatal notification, unless suppressed by the -nowarn option.
|
||||||
|
* @param file The file to which the note applies.
|
||||||
|
* @param key The key for the localized notification message.
|
||||||
|
* @param args Fields of the notification message.
|
||||||
|
*/
|
||||||
|
public void note(JavaFileObject file, String key, Object ... args) {
|
||||||
|
report(diags.note(wrap(file), null, key, args));
|
||||||
|
}
|
||||||
|
|
||||||
/** Provide a non-fatal notification, unless suppressed by the -nowarn option.
|
/** Provide a non-fatal notification, unless suppressed by the -nowarn option.
|
||||||
* @param key The key for the localized notification message.
|
* @param key The key for the localized notification message.
|
||||||
* @param args Fields of the notification message.
|
* @param args Fields of the notification message.
|
||||||
*/
|
*/
|
||||||
public void mandatoryNote(final JavaFileObject file, String key, Object ... args) {
|
public void mandatoryNote(final JavaFileObject file, String key, Object ... args) {
|
||||||
JCDiagnostic.DiagnosticSource wrapper = null;
|
report(diags.mandatoryNote(wrap(file), key, args));
|
||||||
if (file != null) {
|
}
|
||||||
wrapper = new JCDiagnostic.DiagnosticSource() {
|
|
||||||
|
private JCDiagnostic.DiagnosticSource wrap(final JavaFileObject file) {
|
||||||
|
if (file == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new JCDiagnostic.DiagnosticSource() {
|
||||||
public JavaFileObject getFile() {
|
public JavaFileObject getFile() {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -538,11 +541,6 @@ public class Log {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (enforceMandatoryWarnings)
|
|
||||||
report(diags.mandatoryNote(wrapper, key, args));
|
|
||||||
else
|
|
||||||
report(diags.note(wrapper, null, key, args));
|
|
||||||
}
|
|
||||||
|
|
||||||
private DiagnosticPosition wrap(int pos) {
|
private DiagnosticPosition wrap(int pos) {
|
||||||
return (pos == Position.NOPOS ? null : new SimpleDiagnosticPosition(pos));
|
return (pos == Position.NOPOS ? null : new SimpleDiagnosticPosition(pos));
|
||||||
|
|
|
@ -101,13 +101,17 @@ public class MandatoryWarningHandler {
|
||||||
* individual instances should be given, or whether an aggregate
|
* individual instances should be given, or whether an aggregate
|
||||||
* message should be generated at the end of the compilation.
|
* message should be generated at the end of the compilation.
|
||||||
* Typically set via -Xlint:option.
|
* Typically set via -Xlint:option.
|
||||||
|
* @param enforceMandatory
|
||||||
|
* True if mandatory warnings and notes are being enforced.
|
||||||
* @param prefix A common prefix for the set of message keys for
|
* @param prefix A common prefix for the set of message keys for
|
||||||
* the messages that may be generated.
|
* the messages that may be generated.
|
||||||
*/
|
*/
|
||||||
public MandatoryWarningHandler(Log log, boolean verbose, String prefix) {
|
public MandatoryWarningHandler(Log log, boolean verbose,
|
||||||
|
boolean enforceMandatory, String prefix) {
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.verbose = verbose;
|
this.verbose = verbose;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
|
this.enforceMandatory = enforceMandatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +126,7 @@ public class MandatoryWarningHandler {
|
||||||
|
|
||||||
if (log.nwarnings < log.MaxWarnings) {
|
if (log.nwarnings < log.MaxWarnings) {
|
||||||
// generate message and remember the source file
|
// generate message and remember the source file
|
||||||
log.mandatoryWarning(pos, msg, args);
|
logMandatoryWarning(pos, msg, args);
|
||||||
sourcesWithReportedWarnings.add(currentSource);
|
sourcesWithReportedWarnings.add(currentSource);
|
||||||
} else if (deferredDiagnosticKind == null) {
|
} else if (deferredDiagnosticKind == null) {
|
||||||
// set up deferred message
|
// set up deferred message
|
||||||
|
@ -163,12 +167,12 @@ public class MandatoryWarningHandler {
|
||||||
public void reportDeferredDiagnostic() {
|
public void reportDeferredDiagnostic() {
|
||||||
if (deferredDiagnosticKind != null) {
|
if (deferredDiagnosticKind != null) {
|
||||||
if (deferredDiagnosticArg == null)
|
if (deferredDiagnosticArg == null)
|
||||||
log.mandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix));
|
logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix));
|
||||||
else
|
else
|
||||||
log.mandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix), deferredDiagnosticArg);
|
logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix), deferredDiagnosticArg);
|
||||||
|
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
log.mandatoryNote(deferredDiagnosticSource, prefix + ".recompile");
|
logMandatoryNote(deferredDiagnosticSource, prefix + ".recompile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,4 +228,32 @@ public class MandatoryWarningHandler {
|
||||||
* deferredDiagnosticKind is updated.
|
* deferredDiagnosticKind is updated.
|
||||||
*/
|
*/
|
||||||
private Object deferredDiagnosticArg;
|
private Object deferredDiagnosticArg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if mandatory warnings and notes are being enforced.
|
||||||
|
*/
|
||||||
|
private final boolean enforceMandatory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports a mandatory warning to the log. If mandatory warnings
|
||||||
|
* are not being enforced, treat this as an ordinary warning.
|
||||||
|
*/
|
||||||
|
private void logMandatoryWarning(DiagnosticPosition pos, String msg,
|
||||||
|
Object... args) {
|
||||||
|
if (enforceMandatory)
|
||||||
|
log.mandatoryWarning(pos, msg, args);
|
||||||
|
else
|
||||||
|
log.warning(pos, msg, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports a mandatory note to the log. If mandatory notes are
|
||||||
|
* not being enforced, treat this as an ordinary note.
|
||||||
|
*/
|
||||||
|
private void logMandatoryNote(JavaFileObject file, String msg, Object... args) {
|
||||||
|
if (enforceMandatory)
|
||||||
|
log.mandatoryNote(file, msg, args);
|
||||||
|
else
|
||||||
|
log.note(file, msg, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
47
langtools/test/tools/javadoc/sourceOption/SourceOption.java
Normal file
47
langtools/test/tools/javadoc/sourceOption/SourceOption.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2006 Sun Microsystems, Inc. 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
|
||||||
|
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 6507179
|
||||||
|
* @summary Ensure that "-source" option isn't ignored.
|
||||||
|
* @author Scott Seligman
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.sun.javadoc.*;
|
||||||
|
|
||||||
|
public class SourceOption extends Doclet {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if (com.sun.tools.javadoc.Main.execute(
|
||||||
|
"javadoc",
|
||||||
|
"SourceOption",
|
||||||
|
new String[] {"-source", "1.3", "p"}) != 0)
|
||||||
|
throw new Error("Javadoc encountered warnings or errors.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean start(RootDoc root) {
|
||||||
|
root.classes(); // force parser into action
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
29
langtools/test/tools/javadoc/sourceOption/p/A.java
Normal file
29
langtools/test/tools/javadoc/sourceOption/p/A.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. 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
|
||||||
|
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package p;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
boolean assert; // illegal since 1.4
|
||||||
|
boolean enum; // illegal since 5
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue