提交 72284490 编写于 作者: J jjg

6795903: fix latent build warnings in langtools repository

Reviewed-by: darcy
上级 1d56195a
...@@ -66,7 +66,7 @@ javac.no.jdk.warnings = -XDignore.symbol.file=true ...@@ -66,7 +66,7 @@ javac.no.jdk.warnings = -XDignore.symbol.file=true
# set the following to -version to verify the versions of javac being used # set the following to -version to verify the versions of javac being used
javac.version.opt = javac.version.opt =
# in time, there should be no exceptions to -Xlint:all # in time, there should be no exceptions to -Xlint:all
javac.lint.opts = -Xlint:all,-deprecation,-fallthrough,-serial,-unchecked,-cast javac.lint.opts = -Xlint:all -Werror
# options for the <javadoc> task for javac # options for the <javadoc> task for javac
javadoc.jls3.url=http://java.sun.com/docs/books/jls/ javadoc.jls3.url=http://java.sun.com/docs/books/jls/
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package com.sun.tools.apt.comp; package com.sun.tools.apt.comp;
public class AnnotationProcessingError extends Error { public class AnnotationProcessingError extends Error {
private static final long serialVersionUID = 3279196183341719287L;
AnnotationProcessingError(Throwable cause) { AnnotationProcessingError(Throwable cause) {
super(cause); super(cause);
} }
......
...@@ -316,8 +316,13 @@ public class Apt extends ListBuffer<Env<AttrContext>> { ...@@ -316,8 +316,13 @@ public class Apt extends ListBuffer<Env<AttrContext>> {
} }
providers = list.iterator(); providers = list.iterator();
} else } else {
providers = sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL); @SuppressWarnings("unchecked")
Iterator<AnnotationProcessorFactory> iter =
sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL);
providers = iter;
}
} }
java.util.Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> factoryToAnnotation = java.util.Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> factoryToAnnotation =
......
...@@ -26,4 +26,6 @@ ...@@ -26,4 +26,6 @@
package com.sun.tools.apt.comp; package com.sun.tools.apt.comp;
public class UsageMessageNeededException extends RuntimeException {} public class UsageMessageNeededException extends RuntimeException {
private static final long serialVersionUID = -3265159608992825840L;
}
...@@ -233,6 +233,7 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler { ...@@ -233,6 +233,7 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>(); ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
try { try {
JavacFileManager fm = (JavacFileManager)fileManager;
//parse all files //parse all files
ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>(); ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
for (List<String> l = filenames; l.nonEmpty(); l = l.tail) { for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
...@@ -250,7 +251,8 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler { ...@@ -250,7 +251,8 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
continue; continue;
} }
} }
trees.append(parse(l.head)); JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
trees.append(parse(fo));
} }
//enter symbols for all files //enter symbols for all files
......
...@@ -30,6 +30,8 @@ import com.sun.mirror.apt.RoundCompleteEvent; ...@@ -30,6 +30,8 @@ import com.sun.mirror.apt.RoundCompleteEvent;
import com.sun.mirror.apt.RoundState; import com.sun.mirror.apt.RoundState;
public class RoundCompleteEventImpl extends RoundCompleteEvent { public class RoundCompleteEventImpl extends RoundCompleteEvent {
private static final long serialVersionUID = 7067621446720784300L;
public RoundCompleteEventImpl(AnnotationProcessorEnvironment source, public RoundCompleteEventImpl(AnnotationProcessorEnvironment source,
RoundState rs) { RoundState rs) {
super(source, rs); super(source, rs);
......
...@@ -252,6 +252,7 @@ class AnnotationProxyMaker { ...@@ -252,6 +252,7 @@ class AnnotationProxyMaker {
*/ */
private void typeMismatch(final Method method, final Attribute attr) { private void typeMismatch(final Method method, final Attribute attr) {
value = new ExceptionProxy() { value = new ExceptionProxy() {
private static final long serialVersionUID = 8473323277815075163L;
public String toString() { public String toString() {
return "<error>"; // eg: @Anno(value=<error>) return "<error>"; // eg: @Anno(value=<error>)
} }
...@@ -270,6 +271,7 @@ class AnnotationProxyMaker { ...@@ -270,6 +271,7 @@ class AnnotationProxyMaker {
* type. * type.
*/ */
private static class MirroredTypeExceptionProxy extends ExceptionProxy { private static class MirroredTypeExceptionProxy extends ExceptionProxy {
private static final long serialVersionUID = 6662035281599933545L;
private MirroredTypeException ex; private MirroredTypeException ex;
...@@ -311,6 +313,7 @@ class AnnotationProxyMaker { ...@@ -311,6 +313,7 @@ class AnnotationProxyMaker {
* types. * types.
*/ */
private static class MirroredTypesExceptionProxy extends ExceptionProxy { private static class MirroredTypesExceptionProxy extends ExceptionProxy {
private static final long serialVersionUID = -6670822532616693951L;
private MirroredTypesException ex; private MirroredTypesException ex;
......
...@@ -64,7 +64,7 @@ public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable { ...@@ -64,7 +64,7 @@ public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable {
* {@inheritDoc} * {@inheritDoc}
*/ */
public TypeParameterDeclaration getDeclaration() { public TypeParameterDeclaration getDeclaration() {
TypeSymbol sym = (TypeSymbol) type.tsym; TypeSymbol sym = type.tsym;
return env.declMaker.getTypeParameterDeclaration(sym); return env.declMaker.getTypeParameterDeclaration(sym);
} }
......
...@@ -37,6 +37,7 @@ import java.io.IOException; ...@@ -37,6 +37,7 @@ import java.io.IOException;
*/ */
public class Annotation { public class Annotation {
static class InvalidAnnotation extends AttributeException { static class InvalidAnnotation extends AttributeException {
private static final long serialVersionUID = -4620480740735772708L;
InvalidAnnotation(String msg) { InvalidAnnotation(String msg) {
super(msg); super(msg);
} }
......
...@@ -32,6 +32,7 @@ package com.sun.tools.classfile; ...@@ -32,6 +32,7 @@ package com.sun.tools.classfile;
* deletion without notice.</b> * deletion without notice.</b>
*/ */
public class AttributeException extends Exception { public class AttributeException extends Exception {
private static final long serialVersionUID = -4231486387714867770L;
AttributeException() { } AttributeException() { }
AttributeException(String msg) { AttributeException(String msg) {
......
...@@ -37,6 +37,7 @@ import java.io.IOException; ...@@ -37,6 +37,7 @@ import java.io.IOException;
*/ */
public class Code_attribute extends Attribute { public class Code_attribute extends Attribute {
public class InvalidIndex extends AttributeException { public class InvalidIndex extends AttributeException {
private static final long serialVersionUID = -8904527774589382802L;
InvalidIndex(int index) { InvalidIndex(int index) {
this.index = index; this.index = index;
} }
......
...@@ -38,6 +38,7 @@ import java.io.IOException; ...@@ -38,6 +38,7 @@ import java.io.IOException;
public class ConstantPool { public class ConstantPool {
public class InvalidIndex extends ConstantPoolException { public class InvalidIndex extends ConstantPoolException {
private static final long serialVersionUID = -4350294289300939730L;
InvalidIndex(int index) { InvalidIndex(int index) {
super(index); super(index);
} }
...@@ -50,6 +51,7 @@ public class ConstantPool { ...@@ -50,6 +51,7 @@ public class ConstantPool {
} }
public class UnexpectedEntry extends ConstantPoolException { public class UnexpectedEntry extends ConstantPoolException {
private static final long serialVersionUID = 6986335935377933211L;
UnexpectedEntry(int index, int expected_tag, int found_tag) { UnexpectedEntry(int index, int expected_tag, int found_tag) {
super(index); super(index);
this.expected_tag = expected_tag; this.expected_tag = expected_tag;
...@@ -67,6 +69,7 @@ public class ConstantPool { ...@@ -67,6 +69,7 @@ public class ConstantPool {
} }
public class InvalidEntry extends ConstantPoolException { public class InvalidEntry extends ConstantPoolException {
private static final long serialVersionUID = 1000087545585204447L;
InvalidEntry(int index, int tag) { InvalidEntry(int index, int tag) {
super(index); super(index);
this.tag = tag; this.tag = tag;
...@@ -82,6 +85,7 @@ public class ConstantPool { ...@@ -82,6 +85,7 @@ public class ConstantPool {
} }
public class EntryNotFound extends ConstantPoolException { public class EntryNotFound extends ConstantPoolException {
private static final long serialVersionUID = 2885537606468581850L;
EntryNotFound(Object value) { EntryNotFound(Object value) {
super(-1); super(-1);
this.value = value; this.value = value;
......
...@@ -33,6 +33,7 @@ package com.sun.tools.classfile; ...@@ -33,6 +33,7 @@ package com.sun.tools.classfile;
* deletion without notice.</b> * deletion without notice.</b>
*/ */
public class ConstantPoolException extends Exception { public class ConstantPoolException extends Exception {
private static final long serialVersionUID = -2324397349644754565L;
ConstantPoolException(int index) { ConstantPoolException(int index) {
this.index = index; this.index = index;
} }
......
...@@ -38,6 +38,7 @@ import java.io.IOException; ...@@ -38,6 +38,7 @@ import java.io.IOException;
*/ */
public class Descriptor { public class Descriptor {
public class InvalidDescriptor extends DescriptorException { public class InvalidDescriptor extends DescriptorException {
private static final long serialVersionUID = 1L;
InvalidDescriptor(String desc) { InvalidDescriptor(String desc) {
this.desc = desc; this.desc = desc;
this.index = -1; this.index = -1;
......
...@@ -33,4 +33,5 @@ package com.sun.tools.classfile; ...@@ -33,4 +33,5 @@ package com.sun.tools.classfile;
* deletion without notice.</b> * deletion without notice.</b>
*/ */
public class DescriptorException extends Exception { public class DescriptorException extends Exception {
private static final long serialVersionUID = 2411890273788901032L;
} }
...@@ -37,6 +37,7 @@ import java.io.IOException; ...@@ -37,6 +37,7 @@ import java.io.IOException;
*/ */
public class StackMapTable_attribute extends Attribute { public class StackMapTable_attribute extends Attribute {
static class InvalidStackMap extends AttributeException { static class InvalidStackMap extends AttributeException {
private static final long serialVersionUID = -5659038410855089780L;
InvalidStackMap(String msg) { InvalidStackMap(String msg) {
super(msg); super(msg);
} }
......
...@@ -119,7 +119,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { ...@@ -119,7 +119,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
*/ */
protected void generateIndex() { protected void generateIndex() {
for (int i = 0; i < groupList.size(); i++) { for (int i = 0; i < groupList.size(); i++) {
String groupname = (String)groupList.get(i); String groupname = groupList.get(i);
List<PackageDoc> list = groupPackageMap.get(groupname); List<PackageDoc> list = groupPackageMap.get(groupname);
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
printIndexContents(list.toArray(new PackageDoc[list.size()]), printIndexContents(list.toArray(new PackageDoc[list.size()]),
......
...@@ -402,7 +402,7 @@ public class SerializedFormBuilder extends AbstractBuilder { ...@@ -402,7 +402,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
public void buildFieldSerializationOverview(ClassDoc classDoc) { public void buildFieldSerializationOverview(ClassDoc classDoc) {
if (classDoc.definesSerializableFields()) { if (classDoc.definesSerializableFields()) {
FieldDoc serialPersistentField = FieldDoc serialPersistentField =
(FieldDoc)((Util.asList(classDoc.serializableFields()).get(0))); Util.asList(classDoc.serializableFields()).get(0);
String comment = serialPersistentField.commentText(); String comment = serialPersistentField.commentText();
if (comment.length() > 0) { if (comment.length() > 0) {
fieldWriter.writeHeader( fieldWriter.writeHeader(
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package com.sun.tools.doclets.internal.toolkit.util; package com.sun.tools.doclets.internal.toolkit.util;
public class DocletAbortException extends RuntimeException { public class DocletAbortException extends RuntimeException {
private static final long serialVersionUID = -9131058909576418984L;
public DocletAbortException() { public DocletAbortException() {
} }
......
...@@ -471,6 +471,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { ...@@ -471,6 +471,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
private int value; private int value;
}; };
protected class CompileStates extends HashMap<Env<AttrContext>,CompileState> { protected class CompileStates extends HashMap<Env<AttrContext>,CompileState> {
private static final long serialVersionUID = 1812267524140424433L;
boolean isDone(Env<AttrContext> env, CompileState cs) { boolean isDone(Env<AttrContext> env, CompileState cs) {
CompileState ecs = get(env); CompileState ecs = get(env);
return ecs != null && ecs.isDone(cs); return ecs != null && ecs.isDone(cs);
......
...@@ -61,6 +61,7 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter { ...@@ -61,6 +61,7 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
* @param opts list of command-line options * @param opts list of command-line options
* @param msgs JavacMessages object used for i18n * @param msgs JavacMessages object used for i18n
*/ */
@SuppressWarnings("fallthrough")
BasicDiagnosticFormatter(Options opts, JavacMessages msgs) { BasicDiagnosticFormatter(Options opts, JavacMessages msgs) {
super(msgs, opts, true); super(msgs, opts, true);
initAvailableFormats(); initAvailableFormats();
......
...@@ -74,6 +74,7 @@ class Comment { ...@@ -74,6 +74,7 @@ class Comment {
* the tag text. * the tag text.
* </pre> * </pre>
*/ */
@SuppressWarnings("fallthrough")
class CommentStringParser { class CommentStringParser {
/** /**
* The entry point to the comment string parser * The entry point to the comment string parser
......
...@@ -111,6 +111,7 @@ public class Messager extends Log implements DocErrorReporter { ...@@ -111,6 +111,7 @@ public class Messager extends Log implements DocErrorReporter {
* @param warnWriter Stream for warnings * @param warnWriter Stream for warnings
* @param noticeWriter Stream for other messages * @param noticeWriter Stream for other messages
*/ */
@SuppressWarnings("deprecation")
protected Messager(Context context, protected Messager(Context context,
String programName, String programName,
PrintWriter errWriter, PrintWriter errWriter,
......
...@@ -51,6 +51,7 @@ public class TypeMaker { ...@@ -51,6 +51,7 @@ public class TypeMaker {
* @param errToClassDoc if true, ERROR type results in a ClassDoc; * @param errToClassDoc if true, ERROR type results in a ClassDoc;
* false preserves legacy behavior * false preserves legacy behavior
*/ */
@SuppressWarnings("fallthrough")
public static com.sun.javadoc.Type getType(DocEnv env, Type t, public static com.sun.javadoc.Type getType(DocEnv env, Type t,
boolean errToClassDoc) { boolean errToClassDoc) {
if (env.legacyDoclet) { if (env.legacyDoclet) {
......
...@@ -342,6 +342,6 @@ public abstract class Gen { ...@@ -342,6 +342,6 @@ public abstract class Gen {
fields.addAll(Arrays.asList(cd.fields())); fields.addAll(Arrays.asList(cd.fields()));
} }
return (FieldDoc[]) fields.toArray(new FieldDoc[fields.size()]); return fields.toArray(new FieldDoc[fields.size()]);
} }
} }
...@@ -32,6 +32,7 @@ package com.sun.tools.javap; ...@@ -32,6 +32,7 @@ package com.sun.tools.javap;
* deletion without notice.</b> * deletion without notice.</b>
*/ */
public class InternalError extends Error { public class InternalError extends Error {
private static final long serialVersionUID = 8114054446416187030L;
InternalError(Throwable t, Object... args) { InternalError(Throwable t, Object... args) {
super("Internal error", t); super("Internal error", t);
this.args = args; this.args = args;
......
...@@ -719,6 +719,7 @@ public class JavapPrinter { ...@@ -719,6 +719,7 @@ public class JavapPrinter {
/** /**
* Print constant pool entry information. * Print constant pool entry information.
*/ */
@SuppressWarnings("fallthrough")
public int PrintlnConstantEntry(int cpx) { public int PrintlnConstantEntry(int cpx) {
int size=1; int size=1;
byte tag=0; byte tag=0;
...@@ -757,6 +758,7 @@ public class JavapPrinter { ...@@ -757,6 +758,7 @@ public class JavapPrinter {
case CONSTANT_LONG: case CONSTANT_LONG:
case CONSTANT_DOUBLE: case CONSTANT_DOUBLE:
size=2; size=2;
// fall through
default: default:
out.println(str+";"); out.println(str+";");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册