Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48517
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Jan 2010 10:31:03 +0000 (10:31 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Jan 2010 10:31:03 +0000 (10:31 +0000)
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

java/javax/el/BeanELResolver.java
java/javax/el/ELContext.java
java/javax/el/ResourceBundleELResolver.java
java/org/apache/catalina/loader/WebappClassLoader.java
java/org/apache/el/lang/ELSupport.java
java/org/apache/el/lang/EvaluationContext.java
java/org/apache/el/parser/AstIdentifier.java
java/org/apache/el/parser/AstValue.java
java/org/apache/el/parser/SimpleNode.java
java/org/apache/naming/resources/VirtualDirContext.java

index cc00352..f4524f3 100644 (file)
@@ -37,8 +37,8 @@ public class BeanELResolver extends ELResolver {
 
        private final boolean readOnly;
 
-       private final ConcurrentCache<String, BeanProperties> cache = new ConcurrentCache<String, BeanProperties>(
-                       1000);
+       private final ConcurrentCache<String, BeanProperties> cache =
+           new ConcurrentCache<String, BeanProperties>(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;
                }
 
index 19f2f66..f06b874 100644 (file)
@@ -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();
         }
index 2eb3999..988958c 100644 (file)
@@ -100,8 +100,9 @@ public class ResourceBundleELResolver extends ELResolver {
        }
 
        @Override
-    @SuppressWarnings("unchecked") // Can't use Iterator<FeatureDescriptor> because API needs to match specification
-    public Iterator getFeatureDescriptors(ELContext context, Object base) {
+    // Can't use Iterator<FeatureDescriptor> because API needs to match specification
+    public @SuppressWarnings("unchecked") Iterator getFeatureDescriptors(
+            ELContext context, Object base) {
                if (base instanceof ResourceBundle) {
                        List<FeatureDescriptor> feats = new ArrayList<FeatureDescriptor>();
                        Enumeration<String> e = ((ResourceBundle) base).getKeys();
index 3e52686..625b2e8 100644 (file)
@@ -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<String> 
             List<String> driverNames = (List<String>) 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<String, ResourceEntry>
         Collection<ResourceEntry> values =
             ((HashMap<String,ResourceEntry>) resourceEntries.clone()).values();
         Iterator<ResourceEntry> loadedClasses = values.iterator();
@@ -1934,7 +1934,7 @@ public class WebappClassLoader
     }
 
 
-    @SuppressWarnings("deprecation")
+    @SuppressWarnings("deprecation") // thread.stop()
     private void clearReferencesThreads() {
         Thread[] threads = getThreads();
         
index 82c0f28..e1fa2d5 100644 (file)
@@ -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<Object> comparable = (Comparable<Object>) obj0;
             return (obj1 != null) ? comparable.compareTo(obj1) : 1;
         }
         if (obj1 instanceof Comparable<?>) {
-            @SuppressWarnings("unchecked")
+            @SuppressWarnings("unchecked") // checked above
             final Comparable<Object> comparable = (Comparable<Object>) obj1;
             return (obj0 != null) ? -comparable.compareTo(obj0) : -1;
         }
index f2d62a5..cc5827d 100644 (file)
@@ -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);
     }
 
index 540bee8..a8fc3e2 100644 (file)
@@ -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());
     }
index 9a5cb5d..834fe48 100644 (file)
@@ -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);
index 84e76b8..5250ffd 100644 (file)
@@ -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();
     }
 }
index 6a21769..eeee2a5 100644 (file)
@@ -147,9 +147,8 @@ public class VirtualDirContext extends FileDirContext {
     }
 
     @Override
-    @SuppressWarnings("unchecked")
-    protected ArrayList list(File file) {
-        ArrayList entries = super.list(file);
+    protected ArrayList<NamingEntry> list(File file) {
+        ArrayList<NamingEntry> entries = super.list(file);
 
         // adds virtual tlds for WEB-INF listing
         if ("WEB-INF".equals(file.getName())) {