diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-06-23 20:59:32 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-06-23 20:59:32 +0000 |
commit | c4468c342efcd45bdc6cc08ea9c06ea6edd75f69 (patch) | |
tree | ab41d9ebe5fb4fea3c179d70b3e4ed89738c93fc /java | |
parent | 7b5f1590c0b002ac59f31c5932977cb1d8d63339 (diff) | |
download | classpath-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.
Diffstat (limited to 'java')
-rw-r--r-- | java/lang/Enum.java | 5 | ||||
-rwxr-xr-x | java/lang/reflect/Constructor.java | 20 | ||||
-rw-r--r-- | java/lang/reflect/Field.java | 6 | ||||
-rw-r--r-- | java/lang/reflect/Method.java | 10 |
4 files changed, 22 insertions, 19 deletions
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; } /** |