8181155: Fix lint warnings in JAXP repo: fallthrough and static

Reviewed-by: lancea, rriggs
This commit is contained in:
Joe Wang 2017-10-30 17:32:38 -07:00
parent f32470d85f
commit b366f4f349
23 changed files with 57 additions and 33 deletions

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -181,6 +181,7 @@ public abstract class Utility {
* @throws IOException if a failure from reading from the bytes argument * @throws IOException if a failure from reading from the bytes argument
* occurs * occurs
*/ */
@SuppressWarnings("fallthrough") // by design for case Const.INSTANCEOF
public static String codeToString(final ByteSequence bytes, final ConstantPool constant_pool, public static String codeToString(final ByteSequence bytes, final ConstantPool constant_pool,
final boolean verbose) throws IOException { final boolean verbose) throws IOException {
final short opcode = (short) bytes.readUnsignedByte(); final short opcode = (short) bytes.readUnsignedByte();

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -175,6 +175,7 @@ class BCELFactory extends EmptyVisitor {
@Override @Override
@SuppressWarnings("fallthrough") // by design for case Const.ANEWARRAY
public void visitAllocationInstruction( final AllocationInstruction i ) { public void visitAllocationInstruction( final AllocationInstruction i ) {
Type type; Type type;
if (i instanceof CPInstruction) { if (i instanceof CPInstruction) {

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -54,6 +54,7 @@ final class Message extends Instruction {
return Type.Void; return Type.Void;
} }
@SuppressWarnings("fallthrough") // at default
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool(); final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList(); final InstructionList il = methodGen.getInstructionList();

View File

@ -232,6 +232,7 @@ final class Step extends RelativeLocationPath {
translateStep(classGen, methodGen, hasPredicates() ? _predicates.size() - 1 : -1); translateStep(classGen, methodGen, hasPredicates() ? _predicates.size() - 1 : -1);
} }
@SuppressWarnings("fallthrough") // at case NodeTest.ANODE and NodeTest.ELEMENT
private void translateStep(ClassGenerator classGen, private void translateStep(ClassGenerator classGen,
MethodGenerator methodGen, MethodGenerator methodGen,
int predicateIndex) { int predicateIndex) {

View File

@ -191,6 +191,7 @@ final class Whitespace extends TopLevelElement {
* Scans through the rules vector and looks for a rule of higher * Scans through the rules vector and looks for a rule of higher
* priority that contradicts the current rule. * priority that contradicts the current rule.
*/ */
@SuppressWarnings("fallthrough") // case RULE_NAMESPACE
private static WhitespaceRule findContradictingRule(List<WhitespaceRule> rules, private static WhitespaceRule findContradictingRule(List<WhitespaceRule> rules,
WhitespaceRule rule) { WhitespaceRule rule) {
for (WhitespaceRule currentRule : rules) { for (WhitespaceRule currentRule : rules) {

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -73,6 +74,7 @@ class XPathLexer implements com.sun.java_cup.internal.runtime.Scanner {
* name instead of a keyword (Jira-1912). Look two tokens behind * name instead of a keyword (Jira-1912). Look two tokens behind
* to desambiguate expressions like "* and *" or "and * and". * to desambiguate expressions like "* and *" or "and * and".
*/ */
@SuppressWarnings("fallthrough")
Symbol disambiguateOperator(int ss) throws Exception { Symbol disambiguateOperator(int ss) throws Exception {
switch (last) { switch (last) {
case sym.STAR: case sym.STAR:
@ -745,6 +747,7 @@ class XPathLexer implements com.sun.java_cup.internal.runtime.Scanner {
":13,-1:2,184:10,-1:3,76,184,76:3,-1:4,184:6,64,-1:2,76,-1:6,184:5,-1:3,184:" + ":13,-1:2,184:10,-1:3,76,184,76:3,-1:4,184:6,64,-1:2,76,-1:6,184:5,-1:3,184:" +
"4,232,184:8,-1:2,184:10,-1:3,76,184,76:3"); "4,232,184:8,-1:2,184:10,-1:3,76,184,76:3");
@SuppressWarnings("fallthrough") // at case 18 and -1
public com.sun.java_cup.internal.runtime.Symbol next_token () public com.sun.java_cup.internal.runtime.Symbol next_token ()
throws java.io.IOException, throws java.io.IOException,
Exception Exception

View File

@ -1591,13 +1591,13 @@ class parser_actions {
RESULT = new CurrentCall(fname); RESULT = new CurrentCall(fname);
} }
else if (fname == parser.getQNameIgnoreDefaultNs("number")) { else if (fname == parser.getQNameIgnoreDefaultNs("number")) {
RESULT = new NumberCall(fname, parser.EmptyArgs); RESULT = new NumberCall(fname, XPathParser.EmptyArgs);
} }
else if (fname == parser.getQNameIgnoreDefaultNs("string")) { else if (fname == parser.getQNameIgnoreDefaultNs("string")) {
RESULT = new StringCall(fname, parser.EmptyArgs); RESULT = new StringCall(fname, XPathParser.EmptyArgs);
} }
else if (fname == parser.getQNameIgnoreDefaultNs("concat")) { else if (fname == parser.getQNameIgnoreDefaultNs("concat")) {
RESULT = new ConcatCall(fname, parser.EmptyArgs); RESULT = new ConcatCall(fname, XPathParser.EmptyArgs);
} }
else if (fname == parser.getQNameIgnoreDefaultNs("true")) { else if (fname == parser.getQNameIgnoreDefaultNs("true")) {
RESULT = new BooleanExpr(true); RESULT = new BooleanExpr(true);
@ -1609,10 +1609,10 @@ class parser_actions {
RESULT = new NameCall(fname); RESULT = new NameCall(fname);
} }
else if (fname == parser.getQNameIgnoreDefaultNs("generate-id")) { else if (fname == parser.getQNameIgnoreDefaultNs("generate-id")) {
RESULT = new GenerateIdCall(fname, parser.EmptyArgs); RESULT = new GenerateIdCall(fname, XPathParser.EmptyArgs);
} }
else if (fname == parser.getQNameIgnoreDefaultNs("string-length")) { else if (fname == parser.getQNameIgnoreDefaultNs("string-length")) {
RESULT = new StringLengthCall(fname, parser.EmptyArgs); RESULT = new StringLengthCall(fname, XPathParser.EmptyArgs);
} }
else if (fname == parser.getQNameIgnoreDefaultNs("position")) { else if (fname == parser.getQNameIgnoreDefaultNs("position")) {
RESULT = new PositionCall(fname); RESULT = new PositionCall(fname);
@ -1627,7 +1627,7 @@ class parser_actions {
RESULT = new NamespaceUriCall(fname); RESULT = new NamespaceUriCall(fname);
} }
else { else {
RESULT = new FunctionCall(fname, parser.EmptyArgs); RESULT = new FunctionCall(fname, XPathParser.EmptyArgs);
} }
parser_result = new Symbol(16/*FunctionCall*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT); parser_result = new Symbol(16/*FunctionCall*/, (parser_stack.get(parser_top-2)).left, (parser_stack.get(parser_top-0)).right, RESULT);

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -1278,11 +1279,13 @@ public final class SAXImpl extends SAX2DTM2
// For "attribute::p:*", the principal node kind is // For "attribute::p:*", the principal node kind is
// attribute // attribute
m_baseIterator = getAxisIterator(axis); m_baseIterator = getAxisIterator(axis);
break;
} }
case Axis.NAMESPACE: { case Axis.NAMESPACE: {
// This covers "namespace::p:*". It is syntactically // This covers "namespace::p:*". It is syntactically
// correct, though it doesn't make much sense. // correct, though it doesn't make much sense.
m_baseIterator = getAxisIterator(axis); m_baseIterator = getAxisIterator(axis);
break;
} }
default: { default: {
// In all other cases, the principal node kind is // In all other cases, the principal node kind is

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -145,6 +145,7 @@ public class TransletOutputHandlerFactory {
_indentNumber = value; _indentNumber = value;
} }
@SuppressWarnings("fallthrough") // intentional at case STAX, SAX
public SerializationHandler getSerializationHandler() public SerializationHandler getSerializationHandler()
throws IOException, ParserConfigurationException throws IOException, ParserConfigurationException
{ {

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -161,8 +161,8 @@ public class DeferredDocumentTypeImpl
if (((DocumentImpl)getOwnerDocument()).allowGrammarAccess){ if (((DocumentImpl)getOwnerDocument()).allowGrammarAccess){
insertBefore(node, last); insertBefore(node, last);
last = node; last = node;
break;
} }
break;
} }
// NOTE: Should never get here! -Ac // NOTE: Should never get here! -Ac

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -439,7 +439,7 @@ class XSDElementTraverser extends XSDAbstractTraverser {
fSchemaHandler.checkForDuplicateNames( fSchemaHandler.checkForDuplicateNames(
(schemaDoc.fTargetNamespace == null) ? ","+DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME) (schemaDoc.fTargetNamespace == null) ? ","+DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME)
: schemaDoc.fTargetNamespace+","+ DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME), : schemaDoc.fTargetNamespace+","+ DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME),
fSchemaHandler.ATTRIBUTE_TYPE, fSchemaHandler.getIDRegistry(), fSchemaHandler.getIDRegistry_sub(), XSDHandler.ATTRIBUTE_TYPE, fSchemaHandler.getIDRegistry(), fSchemaHandler.getIDRegistry_sub(),
child, schemaDoc); child, schemaDoc);
} }
} else if (childName.equals(SchemaSymbols.ELT_KEYREF)) { } else if (childName.equals(SchemaSymbols.ELT_KEYREF)) {

View File

@ -3025,6 +3025,7 @@ public class XSDHandler {
return newComponents; return newComponents;
} }
@SuppressWarnings("fallthrough")
private void expandRelatedComponents(XSObject component,List<XSObject>componentList, Map<String, List<String>> dependencies) { private void expandRelatedComponents(XSObject component,List<XSObject>componentList, Map<String, List<String>> dependencies) {
short componentType = component.getType(); short componentType = component.getType();
switch (componentType) { switch (componentType) {

View File

@ -600,6 +600,7 @@ public class AbstractDOMParser extends AbstractXMLDocumentParser {
* *
* @throws XNIException Thrown by application to signal an error. * @throws XNIException Thrown by application to signal an error.
*/ */
@SuppressWarnings("fallthrough") // by design at case LSParserFilter.FILTER_SKIP
public void comment (XMLString text, Augmentations augs) throws XNIException { public void comment (XMLString text, Augmentations augs) throws XNIException {
if (fInDTD) { if (fInDTD) {
if (fInternalSubset != null && !fInDTDExternalSubset) { if (fInternalSubset != null && !fInDTDExternalSubset) {
@ -673,6 +674,7 @@ public class AbstractDOMParser extends AbstractXMLDocumentParser {
* *
* @throws XNIException Thrown by handler to signal an error. * @throws XNIException Thrown by handler to signal an error.
*/ */
@SuppressWarnings("fallthrough") // by design at case LSParserFilter.FILTER_REJECT
public void processingInstruction (String target, XMLString data, Augmentations augs) public void processingInstruction (String target, XMLString data, Augmentations augs)
throws XNIException { throws XNIException {
@ -1416,6 +1418,7 @@ public class AbstractDOMParser extends AbstractXMLDocumentParser {
* *
* @throws XNIException Thrown by handler to signal an error. * @throws XNIException Thrown by handler to signal an error.
*/ */
@SuppressWarnings("fallthrough") // by design at case LSParserFilter.FILTER_REJECT
public void endCDATA (Augmentations augs) throws XNIException { public void endCDATA (Augmentations augs) throws XNIException {
fInCDATASection = false; fInCDATASection = false;
@ -2596,6 +2599,7 @@ public class AbstractDOMParser extends AbstractXMLDocumentParser {
* or removed fFistChunk must be set to true, otherwise some data can be lost. * or removed fFistChunk must be set to true, otherwise some data can be lost.
* *
*/ */
@SuppressWarnings("fallthrough") // by design at case LSParserFilter.FILTER_REJECT
protected void setCharacterData (boolean sawChars){ protected void setCharacterData (boolean sawChars){
// handle character data // handle character data

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -1697,6 +1697,7 @@ implements DTM, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
* @return String Value of this node, or null if not * @return String Value of this node, or null if not
* meaningful for this node type. * meaningful for this node type.
*/ */
@SuppressWarnings("fallthrough")
public String getNodeValue(int nodeHandle) public String getNodeValue(int nodeHandle)
{ {
nodes.readSlot(nodeHandle, gotslot); nodes.readSlot(nodeHandle, gotslot);

View File

@ -1651,6 +1651,7 @@ public class DOM2DTM extends DTMDefaultBaseIterators
* @param node Node whose subtree is to be walked, gathering the * @param node Node whose subtree is to be walked, gathering the
* contents of all Text or CDATASection nodes. * contents of all Text or CDATASection nodes.
*/ */
@SuppressWarnings("fallthrough")
protected static void dispatchNodeData(Node node, protected static void dispatchNodeData(Node node,
org.xml.sax.ContentHandler ch, org.xml.sax.ContentHandler ch,
int depth) int depth)

View File

@ -1020,6 +1020,7 @@ public abstract class BaseMarkupSerializer
* @throws IOException An I/O exception occured while * @throws IOException An I/O exception occured while
* serializing * serializing
*/ */
@SuppressWarnings("fallthrough") // by design at case Node.DOCUMENT_FRAGMENT_NODE
protected void serializeNode( Node node ) protected void serializeNode( Node node )
throws IOException throws IOException
{ {

View File

@ -62,6 +62,7 @@ public class FilterExprWalker extends AxesWalker
* *
* @throws javax.xml.transform.TransformerException * @throws javax.xml.transform.TransformerException
*/ */
@SuppressWarnings("fallthrough")
public void init(Compiler compiler, int opPos, int stepType) public void init(Compiler compiler, int opPos, int stepType)
throws javax.xml.transform.TransformerException throws javax.xml.transform.TransformerException
{ {

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -299,7 +299,7 @@ public class MatchPatternIterator extends LocPathIterator
System.out.println(", "+m_cdtm.getNodeName(n)); System.out.println(", "+m_cdtm.getNodeName(n));
// if(m_cdtm.getNodeName(n).equals("near-east")) // if(m_cdtm.getNodeName(n).equals("near-east"))
System.out.println("pattern: "+m_pattern.toString()); System.out.println("pattern: "+m_pattern.toString());
m_pattern.debugWhatToShow(m_pattern.getWhatToShow()); NodeTest.debugWhatToShow(m_pattern.getWhatToShow());
} }
XObject score = m_pattern.execute(xctxt); XObject score = m_pattern.execute(xctxt);

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -554,6 +554,7 @@ public class WalkerFactory
* *
* @throws javax.xml.transform.TransformerException * @throws javax.xml.transform.TransformerException
*/ */
@SuppressWarnings("fallthrough") // by design at case OpCodes.FROM_DESCENDANTS
private static boolean isOptimizableForDescendantIterator( private static boolean isOptimizableForDescendantIterator(
Compiler compiler, int stepOpCodePos, int stepIndex) Compiler compiler, int stepOpCodePos, int stepIndex)
throws javax.xml.transform.TransformerException throws javax.xml.transform.TransformerException
@ -1102,7 +1103,7 @@ public class WalkerFactory
System.out.print(", predAxis: " + Axis.getNames(ai.getAxis())); System.out.print(", predAxis: " + Axis.getNames(ai.getAxis()));
System.out.print(", what: "); System.out.print(", what: ");
System.out.print(" "); System.out.print(" ");
ai.debugWhatToShow(ai.getWhatToShow()); NodeTest.debugWhatToShow(ai.getWhatToShow());
} }
int argLen = compiler.getFirstPredicateOpPos(opPos); int argLen = compiler.getFirstPredicateOpPos(opPos);
@ -1621,6 +1622,7 @@ public class WalkerFactory
* *
* @throws javax.xml.transform.TransformerException * @throws javax.xml.transform.TransformerException
*/ */
@SuppressWarnings("fallthrough") // by design at case OpCodes.FROM_ROOT
private static boolean isNaturalDocOrder( private static boolean isNaturalDocOrder(
Compiler compiler, int stepOpCodePos, int stepIndex, int analysis) Compiler compiler, int stepOpCodePos, int stepIndex, int analysis)
throws javax.xml.transform.TransformerException throws javax.xml.transform.TransformerException

View File

@ -106,6 +106,7 @@ class Lexer
* *
* @throws javax.xml.transform.TransformerException * @throws javax.xml.transform.TransformerException
*/ */
@SuppressWarnings("fallthrough") // on purpose at case '-', '(' and default
void tokenize(String pat, List<String> targetStrings) void tokenize(String pat, List<String> targetStrings)
throws javax.xml.transform.TransformerException throws javax.xml.transform.TransformerException
{ {

View File

@ -1,6 +1,6 @@
/* /*
* reserved comment block * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT REMOVE OR ALTER! * @LastModified: Oct 2017
*/ */
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -65,7 +65,7 @@ public class ContextMatchStepPattern extends StepPattern
if (xctxt.getIteratorRoot() == xctxt.getCurrentNode()) if (xctxt.getIteratorRoot() == xctxt.getCurrentNode())
return getStaticScore(); return getStaticScore();
else else
return this.SCORE_NONE; return NodeTest.SCORE_NONE;
} }
/** /**

View File

@ -116,7 +116,7 @@ public class StepPattern extends NodeTest implements SubContextList, ExpressionO
m_targetString = PsuedoNames.PSEUDONAME_ROOT; m_targetString = PsuedoNames.PSEUDONAME_ROOT;
break; break;
case DTMFilter.SHOW_ELEMENT : case DTMFilter.SHOW_ELEMENT :
if (this.WILD == m_name) if (WILD.equals(m_name))
m_targetString = PsuedoNames.PSEUDONAME_ANY; m_targetString = PsuedoNames.PSEUDONAME_ANY;
else else
m_targetString = m_name; m_targetString = m_name;

View File

@ -586,7 +586,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler
// note funky case: localname can be null // note funky case: localname can be null
// when declaring the default prefix, and // when declaring the default prefix, and
// yet the uri isn't null. // yet the uri isn't null.
atts.addAttribute (nsSupport.XMLNS, prefix, atts.addAttribute (NamespaceSupport.XMLNS, prefix,
attQName.intern(), type, value); attQName.intern(), type, value);
else else
atts.addAttribute ("", "", atts.addAttribute ("", "",