Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-6740: Reduce warnings emitted by javac #6

Uwe Schindler94b12beb4a23
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java
index 5202fb48ef5..9fa84346e16 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java
@@ -266,11 +266,11 @@ final class Stemmer {
// some state for traversing FSTs
final FST.BytesReader prefixReaders[] = new FST.BytesReader[3];
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked","rawtypes"})
final FST.Arc<IntsRef> prefixArcs[] = new FST.Arc[3];
final FST.BytesReader suffixReaders[] = new FST.BytesReader[3];
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked","rawtypes"})
final FST.Arc<IntsRef> suffixArcs[] = new FST.Arc[3];
diff --git a/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java b/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java
index 186876b52b7..b1fe2070a95 100644
--- a/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java
+++ b/lucene/classification/src/test/org/apache/lucene/classification/utils/ConfusionMatrixGeneratorTest.java
@@ -31,7 +31,7 @@ import org.junit.Test;
/**
* Tests for {@link ConfusionMatrixGenerator}
*/
-public class ConfusionMatrixGeneratorTest extends ClassificationTestBase {
+public class ConfusionMatrixGeneratorTest extends ClassificationTestBase<Object> {
@Test
public void testGetConfusionMatrixWithSNB() throws Exception {
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java
index 4f5384737a3..5189218b3e7 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/OrQuery.java
@@ -40,9 +40,9 @@ public class OrQuery extends ComposedQuery implements DistanceSubQuery {
@Override
public String distanceSubQueryNotAllowed() {
- Iterator sqi = getSubQueriesIterator();
+ Iterator<SrndQuery> sqi = getSubQueriesIterator();
while (sqi.hasNext()) {
- SrndQuery leq = (SrndQuery) sqi.next();
+ SrndQuery leq = sqi.next();
if (leq instanceof DistanceSubQuery) {
String m = ((DistanceSubQuery)leq).distanceSubQueryNotAllowed();
if (m != null) {
@@ -57,9 +57,10 @@ public class OrQuery extends ComposedQuery implements DistanceSubQuery {
@Override
public void addSpanQueries(SpanNearClauseFactory sncf) throws IOException {
- Iterator sqi = getSubQueriesIterator();
+ Iterator<SrndQuery> sqi = getSubQueriesIterator();
while (sqi.hasNext()) {
- ((DistanceSubQuery)sqi.next()).addSpanQueries(sncf);
+ SrndQuery s = sqi.next();
+ ((DistanceSubQuery) s).addSpanQueries(sncf);
}
}
}
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java
index aba4ef84035..df741756593 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/RewriteQuery.java
@@ -61,7 +61,7 @@ abstract class RewriteQuery<SQ extends SrndQuery> extends Query {
return false;
if (! getClass().equals(obj.getClass()))
return false;
- RewriteQuery other = (RewriteQuery)obj;
+ @SuppressWarnings("unchecked") RewriteQuery<SQ> other = (RewriteQuery<SQ>)obj;
return super.equals(obj)
&& fieldName.equals(other.fieldName)
&& qf.equals(other.qf)
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java
index 3abdd27e7cd..d3e5e81ef67 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java
@@ -176,9 +176,9 @@ public class QueryTemplateManager {
Element root = doc.createElement("Document");
doc.appendChild(root);
- Enumeration keysEnum = formProperties.keys();
+ Enumeration<?> keysEnum = formProperties.propertyNames();
while (keysEnum.hasMoreElements()) {
- String propName = (String) keysEnum.nextElement();
+ String propName = keysEnum.nextElement().toString();
String value = formProperties.getProperty(propName);
if ((value != null) && (value.length() > 0)) {
DOMUtils.insertChild(root, propName, value);
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
index 9d24e538a4e..efef8fa3d07 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
@@ -156,14 +156,13 @@ public class TestQueryParser extends QueryParserTestBase {
@SuppressWarnings("rawtype")
public void testProtectedCtors() throws Exception {
try {
- QueryParser.class.getConstructor(new Class[] {CharStream.class});
+ QueryParser.class.getConstructor(CharStream.class);
fail("please switch public QueryParser(CharStream) to be protected");
} catch (NoSuchMethodException nsme) {
// expected
}
try {
- QueryParser.class
- .getConstructor(new Class[] {QueryParserTokenManager.class});
+ QueryParser.class.getConstructor(QueryParserTokenManager.class);
fail("please switch public QueryParser(QueryParserTokenManager) to be protected");
} catch (NoSuchMethodException nsme) {
// expected