summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2008-06-23 20:59:32 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2008-06-23 20:59:32 +0000
commitc4468c342efcd45bdc6cc08ea9c06ea6edd75f69 (patch)
treeab41d9ebe5fb4fea3c179d70b3e4ed89738c93fc
parent7b5f1590c0b002ac59f31c5932977cb1d8d63339 (diff)
downloadclasspath-c4468c342efcd45bdc6cc08ea9c06ea6edd75f69.tar.gz
2008-06-23 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/xml/xpath/CountFunction.java, * gnu/xml/xpath/EqualityExpr.java, * gnu/xml/xpath/Expr.java, * gnu/xml/xpath/IdFunction.java, * gnu/xml/xpath/LocalNameFunction.java, * gnu/xml/xpath/NameFunction.java, * gnu/xml/xpath/NamespaceUriFunction.java, * gnu/xml/xpath/ParenthesizedExpr.java, * gnu/xml/xpath/Steps.java, * gnu/xml/xpath/SumFunction.java, * gnu/xml/xpath/UnionExpr.java, * gnu/xml/xpath/XPathParser.java, * gnu/xml/xpath/XPathParser.y, * java/lang/Enum.java, * java/lang/reflect/Constructor.java, * java/lang/reflect/Field.java, * java/lang/reflect/Method.java: Reduce scope of unchecked warning suppression, and remove unneeded uses.
-rw-r--r--ChangeLog22
-rw-r--r--gnu/xml/xpath/CountFunction.java4
-rw-r--r--gnu/xml/xpath/EqualityExpr.java20
-rw-r--r--gnu/xml/xpath/Expr.java34
-rw-r--r--gnu/xml/xpath/IdFunction.java3
-rw-r--r--gnu/xml/xpath/LocalNameFunction.java4
-rw-r--r--gnu/xml/xpath/NameFunction.java15
-rw-r--r--gnu/xml/xpath/NamespaceUriFunction.java10
-rw-r--r--gnu/xml/xpath/ParenthesizedExpr.java8
-rw-r--r--gnu/xml/xpath/Steps.java14
-rw-r--r--gnu/xml/xpath/SumFunction.java8
-rw-r--r--gnu/xml/xpath/UnionExpr.java20
-rw-r--r--gnu/xml/xpath/XPathParser.java42
-rw-r--r--gnu/xml/xpath/XPathParser.y24
-rw-r--r--java/lang/Enum.java5
-rwxr-xr-xjava/lang/reflect/Constructor.java20
-rw-r--r--java/lang/reflect/Field.java6
-rw-r--r--java/lang/reflect/Method.java10
18 files changed, 180 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog
index f8147af23..c8c72ebab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2008-06-23 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/xml/xpath/CountFunction.java,
+ * gnu/xml/xpath/EqualityExpr.java,
+ * gnu/xml/xpath/Expr.java,
+ * gnu/xml/xpath/IdFunction.java,
+ * gnu/xml/xpath/LocalNameFunction.java,
+ * gnu/xml/xpath/NameFunction.java,
+ * gnu/xml/xpath/NamespaceUriFunction.java,
+ * gnu/xml/xpath/ParenthesizedExpr.java,
+ * gnu/xml/xpath/Steps.java,
+ * gnu/xml/xpath/SumFunction.java,
+ * gnu/xml/xpath/UnionExpr.java,
+ * gnu/xml/xpath/XPathParser.java,
+ * gnu/xml/xpath/XPathParser.y,
+ * java/lang/Enum.java,
+ * java/lang/reflect/Constructor.java,
+ * java/lang/reflect/Field.java,
+ * java/lang/reflect/Method.java:
+ Reduce scope of unchecked warning suppression,
+ and remove unneeded uses.
+
2008-06-23 Christian Thalinger <twisti@complang.tuwien.ac.at>
* include/jni.h [__cplusplus] (_Jv_JNIEnv): Renamed member p to
diff --git a/gnu/xml/xpath/CountFunction.java b/gnu/xml/xpath/CountFunction.java
index 25bbfa636..f29d83310 100644
--- a/gnu/xml/xpath/CountFunction.java
+++ b/gnu/xml/xpath/CountFunction.java
@@ -64,11 +64,11 @@ final class CountFunction
this.arg = arg;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
Object val = arg.evaluate(context, pos, len);
- return new Double((double) ((Collection<Node>) val).size());
+ return new Double((double) ((Collection<?>) val).size());
}
public Expr clone(Object context)
diff --git a/gnu/xml/xpath/EqualityExpr.java b/gnu/xml/xpath/EqualityExpr.java
index 0a8147d76..3b6fd568a 100644
--- a/gnu/xml/xpath/EqualityExpr.java
+++ b/gnu/xml/xpath/EqualityExpr.java
@@ -76,7 +76,6 @@ final class EqualityExpr
}
}
- @SuppressWarnings("unchecked")
private boolean evaluateImpl(Node context, int pos, int len)
{
Object left = lhs.evaluate(context, pos, len);
@@ -92,8 +91,11 @@ final class EqualityExpr
boolean frns = right instanceof Collection;
if (flns && frns)
{
- Collection<Node> lns = (Collection<Node>) left;
- Collection<Node> rns = (Collection<Node>) right;
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> lns = (Collection<Node>) left;
+ @SuppressWarnings("unchecked")
+ Collection<Node> rns = (Collection<Node>) right;
if (lns.isEmpty())
{
return false;
@@ -138,7 +140,9 @@ final class EqualityExpr
boolean frn = right instanceof Double;
if ((flns && frn) || (frns && fln))
{
- Collection<Node> ns = flns ? (Collection<Node>) left : (Collection<Node>) right;
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> ns = flns ? (Collection<Node>) left : (Collection<Node>) right;
double n = fln ? ((Double) left).doubleValue() :
((Double) right).doubleValue();
boolean all = true;
@@ -170,7 +174,9 @@ final class EqualityExpr
boolean frs = right instanceof String;
if ((flns && frs) || (frns && fls))
{
- Collection<Node> ns = flns ? (Collection<Node>) left : (Collection<Node>) right;
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> ns = flns ? (Collection<Node>) left : (Collection<Node>) right;
String s = fls ? (String) left : (String) right;
boolean all = true;
for (Node test : ns)
@@ -200,7 +206,9 @@ final class EqualityExpr
boolean frb = right instanceof Boolean;
if ((flns && frb) || (frns && flb))
{
- Collection<Node> ns = flns ? (Collection<Node>) left : (Collection<Node>) right;
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> ns = flns ? (Collection<Node>) left : (Collection<Node>) right;
boolean b = flb ? ((Boolean) left).booleanValue() :
((Boolean) right).booleanValue();
return _boolean(context, ns) == b;
diff --git a/gnu/xml/xpath/Expr.java b/gnu/xml/xpath/Expr.java
index 30d4baa5b..87ce3dfb6 100644
--- a/gnu/xml/xpath/Expr.java
+++ b/gnu/xml/xpath/Expr.java
@@ -115,7 +115,6 @@ public abstract class Expr
}
- @SuppressWarnings("unchecked")
public Object evaluate(Object item, QName returnType)
throws XPathExpressionException
{
@@ -144,7 +143,10 @@ public abstract class Expr
{
if (ret instanceof Collection)
{
- Collection<Node> ns = (Collection<Node>) ret;
+ /* Suppression is safe, as we know context
+ produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> ns = (Collection<Node>) ret;
switch (ns.size())
{
case 0:
@@ -169,7 +171,12 @@ public abstract class Expr
throw new XPathExpressionException("return value is not a node-set");
}
if (ret != null)
- ret = new ExprNodeSet((Collection<Node>) ret);
+ {
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodes = (Collection<Node>) ret;
+ ret = new ExprNodeSet(nodes);
+ }
}
}
return ret;
@@ -232,13 +239,14 @@ public abstract class Expr
* same document as the context node that have a unique ID equal to any of
* the tokens in the list.
*/
- @SuppressWarnings("unchecked")
public static Collection<Node> _id(Node context, Object object)
{
Set<Node> ret = new HashSet<Node>();
if (object instanceof Collection)
{
- Collection<Node> nodeSet = (Collection<Node>) object;
+ /* Suppression is safe, as the iteration will check each value is a Node */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodeSet = (Collection<Node>) object;
for (Iterator<Node> i = nodeSet.iterator(); i.hasNext(); )
{
String string = stringValue(i.next());
@@ -343,7 +351,6 @@ public abstract class Expr
/**
* Implementation of the XPath <code>string</code> function.
*/
- @SuppressWarnings("unchecked")
public static String _string(Node context, Object object)
{
if (object == null)
@@ -392,7 +399,10 @@ public abstract class Expr
}
if (object instanceof Collection)
{
- Collection<Node> nodeSet = (Collection<Node>) object;
+ /* Suppression is safe, as we fail immediately if the
+ * first element is not a Node and don't use the rest */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodeSet = (Collection<Node>) object;
if (nodeSet.isEmpty())
{
return "";
@@ -408,7 +418,6 @@ public abstract class Expr
/**
* Implementation of the XPath <code>boolean</code> function.
*/
- @SuppressWarnings("unchecked")
public static boolean _boolean(Node context, Object object)
{
if (object instanceof Boolean)
@@ -428,7 +437,7 @@ public abstract class Expr
}
if (object instanceof Collection)
{
- return ((Collection<Node>) object).size() != 0;
+ return ((Collection<?>) object).size() != 0;
}
return false; // TODO user defined types
}
@@ -438,7 +447,6 @@ public abstract class Expr
/**
* Implementation of the XPath <code>number</code> function.
*/
- @SuppressWarnings("unchecked")
public static double _number(Node context, Object object)
{
if (object == null)
@@ -455,8 +463,12 @@ public abstract class Expr
}
if (object instanceof Collection)
{
+ /* Suppression is safe, as we fail immediately if one
+ * of the elements is not a Node */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodeSet = (Collection<Node>) object;
// Convert node-set to string
- object = stringValue((Collection<Node>) object);
+ object = stringValue(nodeSet);
}
if (object instanceof String)
{
diff --git a/gnu/xml/xpath/IdFunction.java b/gnu/xml/xpath/IdFunction.java
index de6d3e4ba..b3d2208c8 100644
--- a/gnu/xml/xpath/IdFunction.java
+++ b/gnu/xml/xpath/IdFunction.java
@@ -72,11 +72,10 @@ public final class IdFunction
this.arg = arg;
}
- @SuppressWarnings("unchecked")
public boolean matches(Node context)
{
Object ret = evaluate(context, 1, 1);
- return !((Collection<Node>) ret).isEmpty();
+ return !((Collection<?>) ret).isEmpty();
}
@Override
diff --git a/gnu/xml/xpath/LocalNameFunction.java b/gnu/xml/xpath/LocalNameFunction.java
index a08a3df5f..dbad9d3b4 100644
--- a/gnu/xml/xpath/LocalNameFunction.java
+++ b/gnu/xml/xpath/LocalNameFunction.java
@@ -69,9 +69,11 @@ final class LocalNameFunction
this.arg = arg;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
Collection<Node> val = (arg == null) ? Collections.singleton(context) :
(Collection<Node>) arg.evaluate(context, pos, len);
return _local_name(context, val);
diff --git a/gnu/xml/xpath/NameFunction.java b/gnu/xml/xpath/NameFunction.java
index 7eefbc25c..239a53453 100644
--- a/gnu/xml/xpath/NameFunction.java
+++ b/gnu/xml/xpath/NameFunction.java
@@ -77,25 +77,30 @@ final class NameFunction
this.arg = arg;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
- Object val = (arg == null) ? Collections.singleton(context) :
- arg.evaluate(context, pos, len);
- return _name(context, (Collection<Node>) val);
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> val = (arg == null) ? Collections.singleton(context) :
+ (Collection<Node>) arg.evaluate(context, pos, len);
+ return _name(context, val);
}
+ @Override
public Expr clone(Object context)
{
return new NameFunction((arg == null) ? null :
arg.clone(context));
}
-
+
+ @Override
public boolean references(QName var)
{
return (arg == null) ? false : arg.references(var);
}
+ @Override
public String toString()
{
return (arg == null) ? "name()" : "name(" + arg + ")";
diff --git a/gnu/xml/xpath/NamespaceUriFunction.java b/gnu/xml/xpath/NamespaceUriFunction.java
index c988e2aaa..56da90f8c 100644
--- a/gnu/xml/xpath/NamespaceUriFunction.java
+++ b/gnu/xml/xpath/NamespaceUriFunction.java
@@ -69,12 +69,14 @@ final class NamespaceUriFunction
this.arg = arg;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
- Object val = (arg == null) ? Collections.singleton(context) :
- arg.evaluate(context, pos, len);
- return _namespace_uri(context, (Collection<Node>) val);
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> val = (arg == null) ? Collections.singleton(context) :
+ (Collection<Node>) arg.evaluate(context, pos, len);
+ return _namespace_uri(context, val);
}
public Expr clone(Object context)
diff --git a/gnu/xml/xpath/ParenthesizedExpr.java b/gnu/xml/xpath/ParenthesizedExpr.java
index 5ec3d2938..adadd6745 100644
--- a/gnu/xml/xpath/ParenthesizedExpr.java
+++ b/gnu/xml/xpath/ParenthesizedExpr.java
@@ -60,13 +60,17 @@ final class ParenthesizedExpr
this.expr = expr;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
Object ret = expr.evaluate(context, pos, len);
if (ret instanceof Collection)
{
- List<Node> list = new ArrayList<Node>((Collection<Node>) ret);
+ /* Suppression is safe, as we know context produces
+ Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodes = (Collection<Node>) ret;
+ List<Node> list = new ArrayList<Node>(nodes);
Collections.sort(list, documentOrderComparator);
ret = list;
}
diff --git a/gnu/xml/xpath/Steps.java b/gnu/xml/xpath/Steps.java
index de22432c4..427fbe201 100644
--- a/gnu/xml/xpath/Steps.java
+++ b/gnu/xml/xpath/Steps.java
@@ -160,7 +160,7 @@ public final class Steps
return Collections.emptySet();
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
//System.err.println(toString()+" evaluate");
@@ -172,13 +172,16 @@ public final class Steps
while (val instanceof Collection && i.hasNext())
{
Path rhs = (Path) i.next();
- val = rhs.evaluate(context, (Collection<Node>) val);
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodes = (Collection<Node>) val;
+ val = rhs.evaluate(context, nodes);
//System.err.println("\tevaluate "+rhs+" = "+val);
}
return val;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
Collection<Node> evaluate(Node context, Collection<Node> ns)
{
// Left to right
@@ -197,7 +200,10 @@ public final class Steps
Object ret = lhs.evaluate(node, pos++, len);
if (ret instanceof Collection)
{
- acc.addAll((Collection<Node>) ret);
+ /* Suppression is safe, as we know context produces Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodes = (Collection<Node>) ret;
+ acc.addAll(nodes);
}
}
ns = acc;
diff --git a/gnu/xml/xpath/SumFunction.java b/gnu/xml/xpath/SumFunction.java
index ce2989b4b..73db2a91d 100644
--- a/gnu/xml/xpath/SumFunction.java
+++ b/gnu/xml/xpath/SumFunction.java
@@ -66,14 +66,18 @@ final class SumFunction
this.arg = arg;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
Object val = arg.evaluate(context, pos, len);
double sum = 0.0d;
if (val instanceof Collection)
{
- for (Node node : ((Collection<Node>) val))
+ /* Suppression is safe, as we know context produces
+ Collection<Node> */
+ @SuppressWarnings("unchecked")
+ Collection<Node> nodes = (Collection<Node>) val;
+ for (Node node : nodes)
{
String s = stringValue(node);
sum += _number(context, s);
diff --git a/gnu/xml/xpath/UnionExpr.java b/gnu/xml/xpath/UnionExpr.java
index fcaee3d9b..03ae5c06d 100644
--- a/gnu/xml/xpath/UnionExpr.java
+++ b/gnu/xml/xpath/UnionExpr.java
@@ -74,21 +74,29 @@ public final class UnionExpr
return false;
}
- @Override @SuppressWarnings("unchecked")
+ @Override
public Object evaluate(Node context, int pos, int len)
{
Object left = lhs.evaluate(context, pos, len);
Object right = rhs.evaluate(context, pos, len);
+ List<Node> list;
if (left instanceof Collection && right instanceof Collection)
{
Set<Node> set = new HashSet<Node>();
- set.addAll ((Collection<Node>) left);
- set.addAll ((Collection<Node>) right);
- List<Node> list = new ArrayList<Node>(set);
+ /* Suppression is safe as addAll will check the types
+ of the elements and throw a ClassCastException as necessary */
+ @SuppressWarnings("unchecked")
+ Collection<Node> l = (Collection<Node>) left;
+ @SuppressWarnings("unchecked")
+ Collection<Node> r = (Collection<Node>) right;
+ set.addAll (l);
+ set.addAll (r);
+ list = new ArrayList<Node>(set);
Collections.sort(list, documentOrderComparator);
- return list;
}
- return Collections.EMPTY_SET;
+ else
+ list = Collections.emptyList();
+ return list;
}
public Expr clone(Object context)
diff --git a/gnu/xml/xpath/XPathParser.java b/gnu/xml/xpath/XPathParser.java
index 300f3161d..e8c8e94da 100644
--- a/gnu/xml/xpath/XPathParser.java
+++ b/gnu/xml/xpath/XPathParser.java
@@ -391,7 +391,6 @@ public class XPathParser
@return result of the last reduction, if any.
@throws yyException on irrecoverable parse error.
*/
- @SuppressWarnings("unchecked")
public Object yyparse (yyInput yyLex)
throws java.io.IOException, yyException {
if (yyMax <= 0) yyMax = 256; // initial size
@@ -566,20 +565,25 @@ case 9:
case 10:
// line 362 "XPathParser.y"
{
- yyVal = new Selector (Selector.CHILD, (List<Test>) yyVals[0+yyTop]);
- }
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>) yyVals[0+yyTop];
+ yyVal = new Selector (Selector.CHILD, tests);
+ }
break;
case 11:
// line 366 "XPathParser.y"
{
- yyVal = new Selector (Selector.ATTRIBUTE, (List<Test>) yyVals[0+yyTop]);
- }
+ /* This is safe as we create this in one of the other cases */
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>) yyVals[0+yyTop];
+ yyVal = new Selector (Selector.ATTRIBUTE, tests);
+ }
break;
case 12:
// line 370 "XPathParser.y"
{
- yyVal = new Selector (((Integer) yyVals[-2+yyTop]).intValue (), (List<Test>) yyVals[0+yyTop]);
- }
+ /* This is safe as we create this in one of the other cases */
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>) yyVals[0+yyTop];
+ yyVal = new Selector (((Integer) yyVals[-2+yyTop]).intValue (), tests);
+ }
break;
case 13:
// line 374 "XPathParser.y"
@@ -606,10 +610,11 @@ case 15:
case 16:
// line 391 "XPathParser.y"
{
- List<Test> list = (List<Test>)yyVals[-1+yyTop];
- list.add((Test) yyVals[0+yyTop]);
- yyVal = list;
- }
+ /* This is safe as we create this in one of the other cases */
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>)yyVals[-1+yyTop];
+ tests.add((Test) yyVals[0+yyTop]);
+ yyVal = tests;
+ }
break;
case 17:
// line 415 "XPathParser.y"
@@ -735,8 +740,10 @@ case 39:
case 40:
// line 512 "XPathParser.y"
{
- yyVal = lookupFunction((String) yyVals[-3+yyTop], (List) yyVals[-1+yyTop]);
- }
+ /* This is safe as we create this below */
+ @SuppressWarnings("unchecked") List<Expr> exprs = (List<Expr>) yyVals[-1+yyTop];
+ yyVal = lookupFunction((String) yyVals[-3+yyTop], exprs);
+ }
break;
case 41:
// line 519 "XPathParser.y"
@@ -749,10 +756,11 @@ case 41:
case 42:
// line 525 "XPathParser.y"
{
- List<Expr> list = (List<Expr>) yyVals[0+yyTop];
- list.add(0, (Expr) yyVals[-2+yyTop]);
- yyVal = list;
- }
+ /* This is safe as we create this above */
+ @SuppressWarnings("unchecked") List<Expr> list = (List<Expr>) yyVals[0+yyTop];
+ list.add(0, (Expr) yyVals[-2+yyTop]);
+ yyVal = list;
+ }
break;
case 44:
// line 535 "XPathParser.y"
diff --git a/gnu/xml/xpath/XPathParser.y b/gnu/xml/xpath/XPathParser.y
index 520e82384..a6d3fd130 100644
--- a/gnu/xml/xpath/XPathParser.y
+++ b/gnu/xml/xpath/XPathParser.y
@@ -360,15 +360,18 @@ relative_location_path:
step:
step_node_test
{
- $$ = new Selector (Selector.CHILD, (List) $1);
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>) $1;
+ $$ = new Selector (Selector.CHILD, tests);
}
| AT step_node_test
{
- $$ = new Selector (Selector.ATTRIBUTE, (List) $2);
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>) $2;
+ $$ = new Selector (Selector.ATTRIBUTE, tests);
}
| axis_name DOUBLE_COLON step_node_test
{
- $$ = new Selector (((Integer) $1).intValue (), (List) $3);
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>) $3;
+ $$ = new Selector (((Integer) $1).intValue (), tests);
}
| DOT
{
@@ -391,8 +394,9 @@ step_node_test:
}
| step_node_test predicate
{
- List<Test> list = (List<Test>)$1;
- list.add((Test) $2);
+ /* This is safe as we create this in one of the other cases */
+ @SuppressWarnings("unchecked") List<Test> tests = (List<Test>)$1;
+ tests.add((Test) $2);
$$ = list;
}
;
@@ -508,11 +512,14 @@ primary_expr:
function_call:
function_name LP RP
{
- $$ = lookupFunction((String) $1, Collections.emptyList());
+ List<Expr> emptyList = Collections.emptyList();
+ $$ = lookupFunction((String) $1, emptyList);
}
| function_name LP argument_list RP
{
- $$ = lookupFunction((String) $1, (List) $3);
+ /* This is safe as we create this below */
+ @SuppressWarnings("unchecked") List<Expr> exprs = (List<Expr>) $3;
+ $$ = lookupFunction((String) $1, (List) exprs);
}
;
@@ -525,7 +532,8 @@ argument_list:
}
| expr COMMA argument_list
{
- List<Expr> list = (List<Expr>) $3;
+ /* This is safe as we create this above */
+ @SuppressWarnings("unchecked") List<Expr> list = (List<Expr>) $3;
list.add(0, (Expr) $1);
$$ = list;
}
diff --git a/java/lang/Enum.java b/java/lang/Enum.java
index fa217bb67..da2e40b8e 100644
--- a/java/lang/Enum.java
+++ b/java/lang/Enum.java
@@ -89,7 +89,6 @@ public abstract class Enum<T extends Enum<T>>
* @exception IllegalArgumentException when there is no value s in
* the enum etype.
*/
- @SuppressWarnings("unchecked")
public static <S extends Enum<S>> S valueOf(Class<S> etype, String s)
{
if (etype == null || s == null)
@@ -103,7 +102,9 @@ public abstract class Enum<T extends Enum<T>>
if (! f.isEnumConstant())
throw new IllegalArgumentException(s);
Class.setAccessible(f);
- return (S) f.get(null);
+ @SuppressWarnings("unchecked")
+ S val = (S) f.get(null);
+ return val;
}
catch (NoSuchFieldException exception)
{
diff --git a/java/lang/reflect/Constructor.java b/java/lang/reflect/Constructor.java
index 55b82e898..d9b7e8312 100755
--- a/java/lang/reflect/Constructor.java
+++ b/java/lang/reflect/Constructor.java
@@ -106,10 +106,12 @@ public final class Constructor<T>
* Gets the class that declared this constructor.
* @return the class that declared this member
*/
- @SuppressWarnings("unchecked")
public Class<T> getDeclaringClass()
{
- return (Class<T>) cons.getDeclaringClass();
+ // Inescapable as the VM layer is 1.4 based.
+ @SuppressWarnings("unchecked")
+ Class<T> declClass = (Class<T>) cons.getDeclaringClass();
+ return declClass;
}
/**
@@ -162,7 +164,6 @@ public final class Constructor<T>
*
* @return a list of the types of the constructor's parameters
*/
- @SuppressWarnings("unchecked")
public Class<?>[] getParameterTypes()
{
return (Class<?>[]) cons.getParameterTypes();
@@ -175,7 +176,6 @@ public final class Constructor<T>
*
* @return a list of the types in the constructor's throws clause
*/
- @SuppressWarnings("unchecked")
public Class<?>[] getExceptionTypes()
{
return (Class<?>[]) cons.getExceptionTypes();
@@ -310,12 +310,14 @@ public final class Constructor<T>
* @throws ExceptionInInitializerError if construction triggered class
* initialization, which then failed
*/
- @SuppressWarnings("unchecked")
public T newInstance(Object... args)
throws InstantiationException, IllegalAccessException,
InvocationTargetException
{
- return (T) cons.construct(args);
+ // Inescapable as the VM layer is 1.4 based.
+ @SuppressWarnings("unchecked")
+ T ins = (T) cons.construct(args);
+ return ins;
}
/**
@@ -424,10 +426,12 @@ public final class Constructor<T>
* <code>null</code> if no such annotation exists.
* @throws NullPointerException if the annotation class is <code>null</code>.
*/
- @SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
{
- return (T) cons.getAnnotation(annotationClass);
+ // Inescapable as the VM layer is 1.4 based.
+ @SuppressWarnings("unchecked")
+ T ann = (T) cons.getAnnotation(annotationClass);
+ return ann;
}
/**
diff --git a/java/lang/reflect/Field.java b/java/lang/reflect/Field.java
index 4c2c183c9..b9d928845 100644
--- a/java/lang/reflect/Field.java
+++ b/java/lang/reflect/Field.java
@@ -104,7 +104,6 @@ extends AccessibleObject implements Member
* is a non-inherited member.
* @return the class that declared this member
*/
- @SuppressWarnings("unchecked")
public Class<?> getDeclaringClass()
{
return (Class<?>) f.getDeclaringClass();
@@ -710,10 +709,11 @@ extends AccessibleObject implements Member
* <code>null</code> if no such annotation exists.
* @throws NullPointerException if the annotation class is <code>null</code>.
*/
- @SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
{
- return (T) f.getAnnotation(annotationClass);
+ // Inescapable as the VM layer is 1.4 based. T will erase to Annotation anyway.
+ @SuppressWarnings("unchecked") T ann = (T) f.getAnnotation(annotationClass);
+ return ann;
}
/**
diff --git a/java/lang/reflect/Method.java b/java/lang/reflect/Method.java
index e787fb3f6..0a532ddb6 100644
--- a/java/lang/reflect/Method.java
+++ b/java/lang/reflect/Method.java
@@ -104,7 +104,6 @@ extends AccessibleObject implements Member, GenericDeclaration
* is a non-inherited member.
* @return the class that declared this member
*/
- @SuppressWarnings("unchecked")
public Class<?> getDeclaringClass()
{
return (Class<?>) m.getDeclaringClass();
@@ -167,7 +166,6 @@ extends AccessibleObject implements Member, GenericDeclaration
* Gets the return type of this method.
* @return the type of this method
*/
- @SuppressWarnings("unchecked")
public Class<?> getReturnType()
{
return (Class<?>) m.getReturnType();
@@ -179,7 +177,6 @@ extends AccessibleObject implements Member, GenericDeclaration
*
* @return a list of the types of the method's parameters
*/
- @SuppressWarnings("unchecked")
public Class<?>[] getParameterTypes()
{
return (Class<?>[]) m.getParameterTypes();
@@ -192,7 +189,6 @@ extends AccessibleObject implements Member, GenericDeclaration
*
* @return a list of the types in the method's throws clause
*/
- @SuppressWarnings("unchecked")
public Class<?>[] getExceptionTypes()
{
return (Class<?>[]) m.getExceptionTypes();
@@ -474,10 +470,12 @@ extends AccessibleObject implements Member, GenericDeclaration
* <code>null</code> if no such annotation exists.
* @throws NullPointerException if the annotation class is <code>null</code>.
*/
- @SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
{
- return (T) m.getAnnotation(annotationClass);
+ // Inescapable as the VM layer is 1.4 based. T will erase to Annotation anyway.
+ @SuppressWarnings("unchecked")
+ T ann = (T) m.getAnnotation(annotationClass);
+ return ann;
}
/**