You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/29 20:38:08 UTC

svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Author: markt
Date: Mon Jul 29 18:38:08 2013
New Revision: 1508171

URL: http://svn.apache.org/r1508171
Log:
Remove unnecessary @SuppressWarnings

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Modified: tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java Mon Jul 29 18:38:08 2013
@@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
 
         // if the ServletContext has ORDERED_LIBS, then use that to specify the
         // set of JARs from WEB-INF/lib that should be used for loading services
-        @SuppressWarnings("unchecked")
         List<String> orderedLibs = (List<String>) context.getAttribute(ServletContext.ORDERED_LIBS);
         if (orderedLibs != null) {
             // handle ordered libs directly, ...



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Mark Thomas <ma...@apache.org>.
On 29/07/2013 22:12, Nick Williams wrote:
> 
> On Jul 29, 2013, at 3:02 PM, Mark Thomas wrote:
> 
>> On 29/07/2013 21:45, Nick Williams wrote:
>>> 
>>> On Jul 29, 2013, at 2:40 PM, Mark Thomas wrote:
>>> 
>>>> On 29/07/2013 21:04, Nick Williams wrote:
>>>>> On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
>>>>> 
>>>>>> This flags as a warning for me in IDEA without the
>>>>>> suppression. Isn't this an unchecked cast (Object to
>>>>>> List<String>)?
>>>> 
>>>> It is an unchecked cast but there is no way to avoid the cast
>>>> so there is no point the IDE flagging it as there is nothing
>>>> the developer can do to fix it. Eclipse added an option
>>>> (Ignore unavoidable generic type problems) not to flag issues
>>>> such as this as of a recent(ish) version.
>>>> 
>>>>> Yes, that's an unchecked cast. The @SuppressWarnings was not 
>>>>> unnecessary.
>>>> 
>>>> Yes, it is unchecked cast. However, the warning is pointless
>>>> and shouldn't have been generated in the first place.
>>>> 
>>>> The Tomcat 8 code base should not exhibit any warnings with
>>>> the defined Eclipse settings [1]. Ditto for FindBugs and
>>>> Checkstyle with the provided configurations.
>>> 
>>> Shouldn't it also not exhibit any warnings when compiled by the
>>> JDK?
>> 
>> That isn't the standard the Tomcat community decided to adopt.
> 
> When did that happen?

I don't recall. It will be in the archives and/or the svn history.

> It must've been before my time. I know I would
> have adamantly opposed such an adoption. Such decisions should be
> based on the platform, not the IDE.

The chances of anyone being involved in an open source project for any
length of time and agreeing with every single decision made is about
close to zero.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Nick Williams <ni...@nicholaswilliams.net>.
On Jul 29, 2013, at 3:02 PM, Mark Thomas wrote:

> On 29/07/2013 21:45, Nick Williams wrote:
>> 
>> On Jul 29, 2013, at 2:40 PM, Mark Thomas wrote:
>> 
>>> On 29/07/2013 21:04, Nick Williams wrote:
>>>> On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
>>>> 
>>>>> This flags as a warning for me in IDEA without the suppression.
>>>>> Isn't this an unchecked cast (Object to List<String>)?
>>> 
>>> It is an unchecked cast but there is no way to avoid the cast so
>>> there is no point the IDE flagging it as there is nothing the
>>> developer can do to fix it. Eclipse added an option (Ignore
>>> unavoidable generic type problems) not to flag issues such as this
>>> as of a recent(ish) version.
>>> 
>>>> Yes, that's an unchecked cast. The @SuppressWarnings was not
>>>> unnecessary.
>>> 
>>> Yes, it is unchecked cast. However, the warning is pointless and 
>>> shouldn't have been generated in the first place.
>>> 
>>> The Tomcat 8 code base should not exhibit any warnings with the
>>> defined Eclipse settings [1]. Ditto for FindBugs and Checkstyle
>>> with the provided configurations.
>> 
>> Shouldn't it also not exhibit any warnings when compiled by the JDK?
> 
> That isn't the standard the Tomcat community decided to adopt.

When did that happen? It must've been before my time. I know I would have adamantly opposed such an adoption. Such decisions should be based on the platform, not the IDE.

N
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Mark Thomas <ma...@apache.org>.
On 29/07/2013 21:45, Nick Williams wrote:
> 
> On Jul 29, 2013, at 2:40 PM, Mark Thomas wrote:
> 
>> On 29/07/2013 21:04, Nick Williams wrote:
>>> On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
>>> 
>>>> This flags as a warning for me in IDEA without the suppression.
>>>> Isn't this an unchecked cast (Object to List<String>)?
>> 
>> It is an unchecked cast but there is no way to avoid the cast so
>> there is no point the IDE flagging it as there is nothing the
>> developer can do to fix it. Eclipse added an option (Ignore
>> unavoidable generic type problems) not to flag issues such as this
>> as of a recent(ish) version.
>> 
>>> Yes, that's an unchecked cast. The @SuppressWarnings was not
>>> unnecessary.
>> 
>> Yes, it is unchecked cast. However, the warning is pointless and 
>> shouldn't have been generated in the first place.
>> 
>> The Tomcat 8 code base should not exhibit any warnings with the
>> defined Eclipse settings [1]. Ditto for FindBugs and Checkstyle
>> with the provided configurations.
> 
> Shouldn't it also not exhibit any warnings when compiled by the JDK?

That isn't the standard the Tomcat community decided to adopt.

Mrk

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Nick Williams <ni...@nicholaswilliams.net>.
On Jul 29, 2013, at 2:40 PM, Mark Thomas wrote:

> On 29/07/2013 21:04, Nick Williams wrote:
>> On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
>> 
>>> This flags as a warning for me in IDEA without the suppression. Isn't this
>>> an unchecked cast (Object to List<String>)?
> 
> It is an unchecked cast but there is no way to avoid the cast so there
> is no point the IDE flagging it as there is nothing the developer can do
> to fix it. Eclipse added an option (Ignore unavoidable generic type
> problems) not to flag issues such as this as of a recent(ish) version.
> 
>> Yes, that's an unchecked cast. The @SuppressWarnings was not unnecessary.
> 
> Yes, it is unchecked cast. However, the warning is pointless and
> shouldn't have been generated in the first place.
> 
> The Tomcat 8 code base should not exhibit any warnings with the defined
> Eclipse settings [1]. Ditto for FindBugs and Checkstyle with the
> provided configurations.

Shouldn't it also not exhibit any warnings when compiled by the JDK? "Some classes use unchecked or unsafe operations" is not something I want to see when compiling code. Remember Eclipse is just what some developers use. Other developers use other IDEs, and all IDEs have settings that can be argued for/against. The JDK, however, is what everyone uses to compile production code, ultimately, and it says that line is unchecked. @SuppressWarnings("unchecked") means, to me, "Someone has taken the time to look closely at this line and confirm that, indeed, it isn't problematic." Now I see that line of code after my compiler warns me and I say, "Oops, might this be a problem?"

N

> 
> The intention is to add additional checks over time although we haven't
> added any for a while.
> 
> Mark
> 
> http://svn.apache.org/viewvc/tomcat/trunk/res/ide-support/eclipse/java-compiler-errors-warnings.txt?view=annotate
> 
> 
>> 
>> N
>> 
>>> 
>>> 
>>> On Mon, Jul 29, 2013 at 11:38 AM, <ma...@apache.org> wrote:
>>> 
>>>> Author: markt
>>>> Date: Mon Jul 29 18:38:08 2013
>>>> New Revision: 1508171
>>>> 
>>>> URL: http://svn.apache.org/r1508171
>>>> Log:
>>>> Remove unnecessary @SuppressWarnings
>>>> 
>>>> Modified:
>>>>   tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>> 
>>>> Modified:
>>>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
>>>> 
>>>> ==============================================================================
>>>> --- tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>> (original)
>>>> +++ tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>> Mon Jul 29 18:38:08 2013
>>>> @@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
>>>> 
>>>>        // if the ServletContext has ORDERED_LIBS, then use that to
>>>> specify the
>>>>        // set of JARs from WEB-INF/lib that should be used for loading
>>>> services
>>>> -        @SuppressWarnings("unchecked")
>>>>        List<String> orderedLibs = (List<String>)
>>>> context.getAttribute(ServletContext.ORDERED_LIBS);
>>>>        if (orderedLibs != null) {
>>>>            // handle ordered libs directly, ...
>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Jeremy Boynes <jb...@apache.org>.
On Mon, Jul 29, 2013 at 2:08 PM, Mark Thomas <ma...@apache.org> wrote:

> On 29/07/2013 22:56, Nick Williams wrote:
> >
> > On Jul 29, 2013, at 3:53 PM, Jeremy Boynes wrote:
> >
> >> This is what lies under the syntactic sugar, and causes no warnings in
> >> javac or IDEA (and I presume Eclipse). Should we stick to it?
> >
> > I would say no. This is why generics exist, so that you don't have to
> write code like that.
>
> +1.
>
> It occurs to me that this might have been better as an explicit method
> on the ServletContext rather than as a special attribute. Given the J2EE
> view on backwards compatibility, this isn't to change but it is
> something to keep an eye out for in future specs.
>

Much better as a explicit method but there we go ...

I'm wary of IDE-specific suppressions as well. There is a legitimate reason
for this warning (the risk of CCE when the List is accessed) and the
annotation indicates that we are acknowledging that and deliberately
suppressing it, with the benefit that that decision is documented in the
code rather than externally in IDE settings.

Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Mark Thomas <ma...@apache.org>.
On 29/07/2013 22:56, Nick Williams wrote:
> 
> On Jul 29, 2013, at 3:53 PM, Jeremy Boynes wrote:
> 
>> This is what lies under the syntactic sugar, and causes no warnings in
>> javac or IDEA (and I presume Eclipse). Should we stick to it?
> 
> I would say no. This is why generics exist, so that you don't have to write code like that.

+1.

It occurs to me that this might have been better as an explicit method
on the ServletContext rather than as a special attribute. Given the J2EE
view on backwards compatibility, this isn't to change but it is
something to keep an eye out for in future specs.

Mark


> 
>>
>> Index: java/org/apache/catalina/startup/WebappServiceLoader.java
>> ===================================================================
>> --- java/org/apache/catalina/startup/WebappServiceLoader.java (revision
>> 1508175)
>> +++ java/org/apache/catalina/startup/WebappServiceLoader.java (working copy)
>> @@ -82,10 +82,11 @@
>>
>>         // if the ServletContext has ORDERED_LIBS, then use that to
>> specify the
>>         // set of JARs from WEB-INF/lib that should be used for loading
>> services
>> -        List<String> orderedLibs = (List<String>)
>> context.getAttribute(ServletContext.ORDERED_LIBS);
>> +        List<?> orderedLibs = (List<?>)
>> context.getAttribute(ServletContext.ORDERED_LIBS);
>>         if (orderedLibs != null) {
>>             // handle ordered libs directly, ...
>> -            for (String lib : orderedLibs) {
>> +            for (Object o : orderedLibs) {
>> +                String lib = (String) o;
>>                 URL jarUrl = context.getResource(LIB + lib);
>>                 if (jarUrl == null) {
>>                     // should not happen, just ignore
>>
>>
>>
>> On Mon, Jul 29, 2013 at 12:40 PM, Mark Thomas <ma...@apache.org> wrote:
>>
>>> On 29/07/2013 21:04, Nick Williams wrote:
>>>> On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
>>>>
>>>>> This flags as a warning for me in IDEA without the suppression. Isn't
>>> this
>>>>> an unchecked cast (Object to List<String>)?
>>>
>>> It is an unchecked cast but there is no way to avoid the cast so there
>>> is no point the IDE flagging it as there is nothing the developer can do
>>> to fix it. Eclipse added an option (Ignore unavoidable generic type
>>> problems) not to flag issues such as this as of a recent(ish) version.
>>>
>>>> Yes, that's an unchecked cast. The @SuppressWarnings was not unnecessary.
>>>
>>> Yes, it is unchecked cast. However, the warning is pointless and
>>> shouldn't have been generated in the first place.
>>>
>>> The Tomcat 8 code base should not exhibit any warnings with the defined
>>> Eclipse settings [1]. Ditto for FindBugs and Checkstyle with the
>>> provided configurations.
>>>
>>> The intention is to add additional checks over time although we haven't
>>> added any for a while.
>>>
>>> Mark
>>>
>>>
>>> http://svn.apache.org/viewvc/tomcat/trunk/res/ide-support/eclipse/java-compiler-errors-warnings.txt?view=annotate
>>>
>>>
>>>>
>>>> N
>>>>
>>>>>
>>>>>
>>>>> On Mon, Jul 29, 2013 at 11:38 AM, <ma...@apache.org> wrote:
>>>>>
>>>>>> Author: markt
>>>>>> Date: Mon Jul 29 18:38:08 2013
>>>>>> New Revision: 1508171
>>>>>>
>>>>>> URL: http://svn.apache.org/r1508171
>>>>>> Log:
>>>>>> Remove unnecessary @SuppressWarnings
>>>>>>
>>>>>> Modified:
>>>>>>
>>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>>>
>>>>>> Modified:
>>>>>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>>> URL:
>>>>>>
>>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
>>>>>>
>>>>>>
>>> ==============================================================================
>>>>>> ---
>>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>>> (original)
>>>>>> +++
>>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>>> Mon Jul 29 18:38:08 2013
>>>>>> @@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
>>>>>>
>>>>>>        // if the ServletContext has ORDERED_LIBS, then use that to
>>>>>> specify the
>>>>>>        // set of JARs from WEB-INF/lib that should be used for loading
>>>>>> services
>>>>>> -        @SuppressWarnings("unchecked")
>>>>>>        List<String> orderedLibs = (List<String>)
>>>>>> context.getAttribute(ServletContext.ORDERED_LIBS);
>>>>>>        if (orderedLibs != null) {
>>>>>>            // handle ordered libs directly, ...
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>>>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>>>>
>>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>>
>>>
>>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Nick Williams <ni...@nicholaswilliams.net>.
On Jul 29, 2013, at 3:53 PM, Jeremy Boynes wrote:

> This is what lies under the syntactic sugar, and causes no warnings in
> javac or IDEA (and I presume Eclipse). Should we stick to it?

I would say no. This is why generics exist, so that you don't have to write code like that.

> 
> Index: java/org/apache/catalina/startup/WebappServiceLoader.java
> ===================================================================
> --- java/org/apache/catalina/startup/WebappServiceLoader.java (revision
> 1508175)
> +++ java/org/apache/catalina/startup/WebappServiceLoader.java (working copy)
> @@ -82,10 +82,11 @@
> 
>         // if the ServletContext has ORDERED_LIBS, then use that to
> specify the
>         // set of JARs from WEB-INF/lib that should be used for loading
> services
> -        List<String> orderedLibs = (List<String>)
> context.getAttribute(ServletContext.ORDERED_LIBS);
> +        List<?> orderedLibs = (List<?>)
> context.getAttribute(ServletContext.ORDERED_LIBS);
>         if (orderedLibs != null) {
>             // handle ordered libs directly, ...
> -            for (String lib : orderedLibs) {
> +            for (Object o : orderedLibs) {
> +                String lib = (String) o;
>                 URL jarUrl = context.getResource(LIB + lib);
>                 if (jarUrl == null) {
>                     // should not happen, just ignore
> 
> 
> 
> On Mon, Jul 29, 2013 at 12:40 PM, Mark Thomas <ma...@apache.org> wrote:
> 
>> On 29/07/2013 21:04, Nick Williams wrote:
>>> On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
>>> 
>>>> This flags as a warning for me in IDEA without the suppression. Isn't
>> this
>>>> an unchecked cast (Object to List<String>)?
>> 
>> It is an unchecked cast but there is no way to avoid the cast so there
>> is no point the IDE flagging it as there is nothing the developer can do
>> to fix it. Eclipse added an option (Ignore unavoidable generic type
>> problems) not to flag issues such as this as of a recent(ish) version.
>> 
>>> Yes, that's an unchecked cast. The @SuppressWarnings was not unnecessary.
>> 
>> Yes, it is unchecked cast. However, the warning is pointless and
>> shouldn't have been generated in the first place.
>> 
>> The Tomcat 8 code base should not exhibit any warnings with the defined
>> Eclipse settings [1]. Ditto for FindBugs and Checkstyle with the
>> provided configurations.
>> 
>> The intention is to add additional checks over time although we haven't
>> added any for a while.
>> 
>> Mark
>> 
>> 
>> http://svn.apache.org/viewvc/tomcat/trunk/res/ide-support/eclipse/java-compiler-errors-warnings.txt?view=annotate
>> 
>> 
>>> 
>>> N
>>> 
>>>> 
>>>> 
>>>> On Mon, Jul 29, 2013 at 11:38 AM, <ma...@apache.org> wrote:
>>>> 
>>>>> Author: markt
>>>>> Date: Mon Jul 29 18:38:08 2013
>>>>> New Revision: 1508171
>>>>> 
>>>>> URL: http://svn.apache.org/r1508171
>>>>> Log:
>>>>> Remove unnecessary @SuppressWarnings
>>>>> 
>>>>> Modified:
>>>>> 
>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>> 
>>>>> Modified:
>>>>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>> URL:
>>>>> 
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
>>>>> 
>>>>> 
>> ==============================================================================
>>>>> ---
>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>> (original)
>>>>> +++
>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>>> Mon Jul 29 18:38:08 2013
>>>>> @@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
>>>>> 
>>>>>        // if the ServletContext has ORDERED_LIBS, then use that to
>>>>> specify the
>>>>>        // set of JARs from WEB-INF/lib that should be used for loading
>>>>> services
>>>>> -        @SuppressWarnings("unchecked")
>>>>>        List<String> orderedLibs = (List<String>)
>>>>> context.getAttribute(ServletContext.ORDERED_LIBS);
>>>>>        if (orderedLibs != null) {
>>>>>            // handle ordered libs directly, ...
>>>>> 
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>>> 
>>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>> 
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Jeremy Boynes <jb...@apache.org>.
This is what lies under the syntactic sugar, and causes no warnings in
javac or IDEA (and I presume Eclipse). Should we stick to it?

Index: java/org/apache/catalina/startup/WebappServiceLoader.java
===================================================================
--- java/org/apache/catalina/startup/WebappServiceLoader.java (revision
1508175)
+++ java/org/apache/catalina/startup/WebappServiceLoader.java (working copy)
@@ -82,10 +82,11 @@

         // if the ServletContext has ORDERED_LIBS, then use that to
specify the
         // set of JARs from WEB-INF/lib that should be used for loading
services
-        List<String> orderedLibs = (List<String>)
context.getAttribute(ServletContext.ORDERED_LIBS);
+        List<?> orderedLibs = (List<?>)
context.getAttribute(ServletContext.ORDERED_LIBS);
         if (orderedLibs != null) {
             // handle ordered libs directly, ...
-            for (String lib : orderedLibs) {
+            for (Object o : orderedLibs) {
+                String lib = (String) o;
                 URL jarUrl = context.getResource(LIB + lib);
                 if (jarUrl == null) {
                     // should not happen, just ignore



On Mon, Jul 29, 2013 at 12:40 PM, Mark Thomas <ma...@apache.org> wrote:

> On 29/07/2013 21:04, Nick Williams wrote:
> > On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
> >
> >> This flags as a warning for me in IDEA without the suppression. Isn't
> this
> >> an unchecked cast (Object to List<String>)?
>
> It is an unchecked cast but there is no way to avoid the cast so there
> is no point the IDE flagging it as there is nothing the developer can do
> to fix it. Eclipse added an option (Ignore unavoidable generic type
> problems) not to flag issues such as this as of a recent(ish) version.
>
> > Yes, that's an unchecked cast. The @SuppressWarnings was not unnecessary.
>
> Yes, it is unchecked cast. However, the warning is pointless and
> shouldn't have been generated in the first place.
>
> The Tomcat 8 code base should not exhibit any warnings with the defined
> Eclipse settings [1]. Ditto for FindBugs and Checkstyle with the
> provided configurations.
>
> The intention is to add additional checks over time although we haven't
> added any for a while.
>
> Mark
>
>
> http://svn.apache.org/viewvc/tomcat/trunk/res/ide-support/eclipse/java-compiler-errors-warnings.txt?view=annotate
>
>
> >
> > N
> >
> >>
> >>
> >> On Mon, Jul 29, 2013 at 11:38 AM, <ma...@apache.org> wrote:
> >>
> >>> Author: markt
> >>> Date: Mon Jul 29 18:38:08 2013
> >>> New Revision: 1508171
> >>>
> >>> URL: http://svn.apache.org/r1508171
> >>> Log:
> >>> Remove unnecessary @SuppressWarnings
> >>>
> >>> Modified:
> >>>
>  tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
> >>>
> >>> Modified:
> >>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
> >>> URL:
> >>>
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
> >>>
> >>>
> ==============================================================================
> >>> ---
> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
> >>> (original)
> >>> +++
> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
> >>> Mon Jul 29 18:38:08 2013
> >>> @@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
> >>>
> >>>         // if the ServletContext has ORDERED_LIBS, then use that to
> >>> specify the
> >>>         // set of JARs from WEB-INF/lib that should be used for loading
> >>> services
> >>> -        @SuppressWarnings("unchecked")
> >>>         List<String> orderedLibs = (List<String>)
> >>> context.getAttribute(ServletContext.ORDERED_LIBS);
> >>>         if (orderedLibs != null) {
> >>>             // handle ordered libs directly, ...
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> >>> For additional commands, e-mail: dev-help@tomcat.apache.org
> >>>
> >>>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
>
>

Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Mark Thomas <ma...@apache.org>.
On 29/07/2013 21:04, Nick Williams wrote:
> On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:
> 
>> This flags as a warning for me in IDEA without the suppression. Isn't this
>> an unchecked cast (Object to List<String>)?

It is an unchecked cast but there is no way to avoid the cast so there
is no point the IDE flagging it as there is nothing the developer can do
to fix it. Eclipse added an option (Ignore unavoidable generic type
problems) not to flag issues such as this as of a recent(ish) version.

> Yes, that's an unchecked cast. The @SuppressWarnings was not unnecessary.

Yes, it is unchecked cast. However, the warning is pointless and
shouldn't have been generated in the first place.

The Tomcat 8 code base should not exhibit any warnings with the defined
Eclipse settings [1]. Ditto for FindBugs and Checkstyle with the
provided configurations.

The intention is to add additional checks over time although we haven't
added any for a while.

Mark

http://svn.apache.org/viewvc/tomcat/trunk/res/ide-support/eclipse/java-compiler-errors-warnings.txt?view=annotate


> 
> N
> 
>>
>>
>> On Mon, Jul 29, 2013 at 11:38 AM, <ma...@apache.org> wrote:
>>
>>> Author: markt
>>> Date: Mon Jul 29 18:38:08 2013
>>> New Revision: 1508171
>>>
>>> URL: http://svn.apache.org/r1508171
>>> Log:
>>> Remove unnecessary @SuppressWarnings
>>>
>>> Modified:
>>>    tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>>
>>> Modified:
>>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>> URL:
>>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
>>>
>>> ==============================================================================
>>> --- tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>> (original)
>>> +++ tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>>> Mon Jul 29 18:38:08 2013
>>> @@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
>>>
>>>         // if the ServletContext has ORDERED_LIBS, then use that to
>>> specify the
>>>         // set of JARs from WEB-INF/lib that should be used for loading
>>> services
>>> -        @SuppressWarnings("unchecked")
>>>         List<String> orderedLibs = (List<String>)
>>> context.getAttribute(ServletContext.ORDERED_LIBS);
>>>         if (orderedLibs != null) {
>>>             // handle ordered libs directly, ...
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Nick Williams <ni...@nicholaswilliams.net>.
On Jul 29, 2013, at 2:02 PM, Jeremy Boynes wrote:

> This flags as a warning for me in IDEA without the suppression. Isn't this
> an unchecked cast (Object to List<String>)?

Yes, that's an unchecked cast. The @SuppressWarnings was not unnecessary.

N

> 
> 
> On Mon, Jul 29, 2013 at 11:38 AM, <ma...@apache.org> wrote:
> 
>> Author: markt
>> Date: Mon Jul 29 18:38:08 2013
>> New Revision: 1508171
>> 
>> URL: http://svn.apache.org/r1508171
>> Log:
>> Remove unnecessary @SuppressWarnings
>> 
>> Modified:
>>    tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>> 
>> Modified:
>> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>> URL:
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
>> 
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>> (original)
>> +++ tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>> Mon Jul 29 18:38:08 2013
>> @@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
>> 
>>         // if the ServletContext has ORDERED_LIBS, then use that to
>> specify the
>>         // set of JARs from WEB-INF/lib that should be used for loading
>> services
>> -        @SuppressWarnings("unchecked")
>>         List<String> orderedLibs = (List<String>)
>> context.getAttribute(ServletContext.ORDERED_LIBS);
>>         if (orderedLibs != null) {
>>             // handle ordered libs directly, ...
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1508171 - /tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Posted by Jeremy Boynes <jb...@apache.org>.
This flags as a warning for me in IDEA without the suppression. Isn't this
an unchecked cast (Object to List<String>)?


On Mon, Jul 29, 2013 at 11:38 AM, <ma...@apache.org> wrote:

> Author: markt
> Date: Mon Jul 29 18:38:08 2013
> New Revision: 1508171
>
> URL: http://svn.apache.org/r1508171
> Log:
> Remove unnecessary @SuppressWarnings
>
> Modified:
>     tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
>
> Modified:
> tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1508171&r1=1508170&r2=1508171&view=diff
>
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
> (original)
> +++ tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
> Mon Jul 29 18:38:08 2013
> @@ -82,7 +82,6 @@ public class WebappServiceLoader<T> {
>
>          // if the ServletContext has ORDERED_LIBS, then use that to
> specify the
>          // set of JARs from WEB-INF/lib that should be used for loading
> services
> -        @SuppressWarnings("unchecked")
>          List<String> orderedLibs = (List<String>)
> context.getAttribute(ServletContext.ORDERED_LIBS);
>          if (orderedLibs != null) {
>              // handle ordered libs directly, ...
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>