From: markt Date: Tue, 12 Jan 2010 10:31:03 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48517 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2da3716968d2c2d3f72c5e0fd1786836c7e76b30;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48517 Reduce scope of @SupressWarnings and document reasoning Based on a patch by sebb git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@898275 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/javax/el/BeanELResolver.java b/java/javax/el/BeanELResolver.java index cc003521b..f4524f34b 100644 --- a/java/javax/el/BeanELResolver.java +++ b/java/javax/el/BeanELResolver.java @@ -37,8 +37,8 @@ public class BeanELResolver extends ELResolver { private final boolean readOnly; - private final ConcurrentCache cache = new ConcurrentCache( - 1000); + private final ConcurrentCache cache = + new ConcurrentCache(1000); public BeanELResolver() { this.readOnly = false; @@ -230,8 +230,8 @@ public class BeanELResolver extends ELResolver { this.type = descriptor.getPropertyType(); } - @SuppressWarnings("unchecked") // Can't use Class because API needs to match specification - public Class getPropertyType() { + // Can't use Class because API needs to match specification + public @SuppressWarnings("unchecked") Class getPropertyType() { return this.type; } diff --git a/java/javax/el/ELContext.java b/java/javax/el/ELContext.java index 19f2f6654..f06b8745d 100644 --- a/java/javax/el/ELContext.java +++ b/java/javax/el/ELContext.java @@ -39,16 +39,17 @@ public abstract class ELContext { this.resolved = false; } - @SuppressWarnings("unchecked") // Can't use Class because API needs to match specification - public Object getContext(Class key) { + // Can't use Class because API needs to match specification + public Object getContext(@SuppressWarnings("unchecked") Class key) { if (this.map == null) { return null; } return this.map.get(key); } - @SuppressWarnings("unchecked") // Can't use Class because API needs to match specification - public void putContext(Class key, Object contextObject) throws NullPointerException { + // Can't use Class because API needs to match specification + public void putContext(@SuppressWarnings("unchecked") Class key, + Object contextObject) throws NullPointerException { if (key == null || contextObject == null) { throw new NullPointerException(); } diff --git a/java/javax/el/ResourceBundleELResolver.java b/java/javax/el/ResourceBundleELResolver.java index 2eb3999e5..988958c26 100644 --- a/java/javax/el/ResourceBundleELResolver.java +++ b/java/javax/el/ResourceBundleELResolver.java @@ -100,8 +100,9 @@ public class ResourceBundleELResolver extends ELResolver { } @Override - @SuppressWarnings("unchecked") // Can't use Iterator because API needs to match specification - public Iterator getFeatureDescriptors(ELContext context, Object base) { + // Can't use Iterator because API needs to match specification + public @SuppressWarnings("unchecked") Iterator getFeatureDescriptors( + ELContext context, Object base) { if (base instanceof ResourceBundle) { List feats = new ArrayList(); Enumeration e = ((ResourceBundle) base).getKeys(); diff --git a/java/org/apache/catalina/loader/WebappClassLoader.java b/java/org/apache/catalina/loader/WebappClassLoader.java index 3e52686fb..625b2e8aa 100644 --- a/java/org/apache/catalina/loader/WebappClassLoader.java +++ b/java/org/apache/catalina/loader/WebappClassLoader.java @@ -1788,7 +1788,7 @@ public class WebappClassLoader defineClass("org.apache.catalina.loader.JdbcLeakPrevention", classBytes, 0, offset); Object obj = lpClass.newInstance(); - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // clearJdbcDriverRegistrations() returns List List driverNames = (List) obj.getClass().getMethod( "clearJdbcDriverRegistrations").invoke(obj); for (String name : driverNames) { @@ -1812,7 +1812,7 @@ public class WebappClassLoader private final void clearReferencesStaticFinal() { - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // resourceEntries is HashMap Collection values = ((HashMap) resourceEntries.clone()).values(); Iterator loadedClasses = values.iterator(); @@ -1934,7 +1934,7 @@ public class WebappClassLoader } - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") // thread.stop() private void clearReferencesThreads() { Thread[] threads = getThreads(); diff --git a/java/org/apache/el/lang/ELSupport.java b/java/org/apache/el/lang/ELSupport.java index 82c0f28ee..e1fa2d585 100644 --- a/java/org/apache/el/lang/ELSupport.java +++ b/java/org/apache/el/lang/ELSupport.java @@ -107,12 +107,12 @@ public class ELSupport { return coerceToString(obj0).compareTo(coerceToString(obj1)); } if (obj0 instanceof Comparable) { - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // checked above final Comparable comparable = (Comparable) obj0; return (obj1 != null) ? comparable.compareTo(obj1) : 1; } if (obj1 instanceof Comparable) { - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // checked above final Comparable comparable = (Comparable) obj1; return (obj0 != null) ? -comparable.compareTo(obj0) : -1; } diff --git a/java/org/apache/el/lang/EvaluationContext.java b/java/org/apache/el/lang/EvaluationContext.java index f2d62a578..cc5827d1f 100644 --- a/java/org/apache/el/lang/EvaluationContext.java +++ b/java/org/apache/el/lang/EvaluationContext.java @@ -54,8 +54,8 @@ public final class EvaluationContext extends ELContext { } @Override - @SuppressWarnings("unchecked") // Can't use Class because API needs to match specification in super-class - public Object getContext(Class key) { + // Can't use Class because API needs to match specification in superclass + public Object getContext(@SuppressWarnings("unchecked") Class key) { return this.elContext.getContext(key); } @@ -70,8 +70,9 @@ public final class EvaluationContext extends ELContext { } @Override - @SuppressWarnings("unchecked") // Can't use Class because API needs to match specification in super-class - public void putContext(Class key, Object contextObject) { + // Can't use Class because API needs to match specification in superclass + public void putContext(@SuppressWarnings("unchecked") Class key, + Object contextObject) { this.elContext.putContext(key, contextObject); } diff --git a/java/org/apache/el/parser/AstIdentifier.java b/java/org/apache/el/parser/AstIdentifier.java index 540bee8be..a8fc3e2a8 100644 --- a/java/org/apache/el/parser/AstIdentifier.java +++ b/java/org/apache/el/parser/AstIdentifier.java @@ -91,17 +91,19 @@ public final class AstIdentifier extends SimpleNode { ctx.getELResolver().setValue(ctx, null, this.image, value); } - @SuppressWarnings("unchecked") @Override - public Object invoke(EvaluationContext ctx, Class[] paramTypes, + // Interface el.parser.Node uses raw types (and is auto-generated) + public Object invoke(EvaluationContext ctx, + @SuppressWarnings("unchecked") Class[] paramTypes, Object[] paramValues) throws ELException { return this.getMethodExpression(ctx).invoke(ctx.getELContext(), paramValues); } - @SuppressWarnings("unchecked") @Override - public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) + // Interface el.parser.Node uses raw types (and is auto-generated) + public MethodInfo getMethodInfo(EvaluationContext ctx, + @SuppressWarnings("unchecked") Class[] paramTypes) throws ELException { return this.getMethodExpression(ctx).getMethodInfo(ctx.getELContext()); } diff --git a/java/org/apache/el/parser/AstValue.java b/java/org/apache/el/parser/AstValue.java index 9a5cb5d3d..834fe4866 100644 --- a/java/org/apache/el/parser/AstValue.java +++ b/java/org/apache/el/parser/AstValue.java @@ -161,9 +161,10 @@ public final class AstValue extends SimpleNode { } - @SuppressWarnings("unchecked") @Override - public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) + // Interface el.parser.Node uses raw types (and is auto-generated) + public MethodInfo getMethodInfo(EvaluationContext ctx, + @SuppressWarnings("unchecked") Class[] paramTypes) throws ELException { Target t = getTarget(ctx); Method m = ReflectionUtil.getMethod(t.base, t.property, paramTypes); @@ -171,9 +172,10 @@ public final class AstValue extends SimpleNode { .getParameterTypes()); } - @SuppressWarnings("unchecked") @Override - public Object invoke(EvaluationContext ctx, Class[] paramTypes, + // Interface el.parser.Node uses a raw type (and is auto-generated) + public Object invoke(EvaluationContext ctx, + @SuppressWarnings("unchecked") Class[] paramTypes, Object[] paramValues) throws ELException { Target t = getTarget(ctx); Method m = ReflectionUtil.getMethod(t.base, t.property, paramTypes); diff --git a/java/org/apache/el/parser/SimpleNode.java b/java/org/apache/el/parser/SimpleNode.java index 84e76b848..5250ffdde 100644 --- a/java/org/apache/el/parser/SimpleNode.java +++ b/java/org/apache/el/parser/SimpleNode.java @@ -153,15 +153,17 @@ public abstract class SimpleNode extends ELSupport implements Node { } } - @SuppressWarnings("unchecked") - public Object invoke(EvaluationContext ctx, Class[] paramTypes, + // Interface el.parser.Node uses raw types (and is auto-generated) + public Object invoke(EvaluationContext ctx, + @SuppressWarnings("unchecked") Class[] paramTypes, Object[] paramValues) throws ELException { throw new UnsupportedOperationException(); } - @SuppressWarnings("unchecked") + // Interface el.parser.Node uses a raw type (and is auto-generated) public MethodInfo getMethodInfo(EvaluationContext ctx, - Class[] paramTypes) throws ELException { + @SuppressWarnings("unchecked") Class[] paramTypes) + throws ELException { throw new UnsupportedOperationException(); } } diff --git a/java/org/apache/naming/resources/VirtualDirContext.java b/java/org/apache/naming/resources/VirtualDirContext.java index 6a21769ae..eeee2a5f5 100644 --- a/java/org/apache/naming/resources/VirtualDirContext.java +++ b/java/org/apache/naming/resources/VirtualDirContext.java @@ -147,9 +147,8 @@ public class VirtualDirContext extends FileDirContext { } @Override - @SuppressWarnings("unchecked") - protected ArrayList list(File file) { - ArrayList entries = super.list(file); + protected ArrayList list(File file) { + ArrayList entries = super.list(file); // adds virtual tlds for WEB-INF listing if ("WEB-INF".equals(file.getName())) {