You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2012/08/04 11:06:21 UTC

svn commit: r1369292 - /commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java

Author: tn
Date: Sat Aug  4 09:06:21 2012
New Revision: 1369292

URL: http://svn.apache.org/viewvc?rev=1369292&view=rev
Log:
Add javadoc comment to prevent removal of a generics fix.

Modified:
    commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java

Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java?rev=1369292&r1=1369291&r2=1369292&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java Sat Aug  4 09:06:21 2012
@@ -520,10 +520,11 @@ public class TestCollectionUtils extends
         Collection<List<? extends Number>> col = new ArrayList<List<? extends Number>>();
         col.add(collectionA);
         col.add(collectionB);
-        Closure<List<? extends Number>> resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, testClosure);
+        Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col, testClosure);
         assertSame(testClosure, resultClosure);
         assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
-        resultClosure = CollectionUtils.forAllDo(col, null);
+        // fix for various java 1.6 versions: keep the specialization
+        resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, null);
         assertNull(resultClosure);
         assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
         resultClosure = CollectionUtils.forAllDo((Collection) null, testClosure);
@@ -542,6 +543,7 @@ public class TestCollectionUtils extends
         Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col.iterator(), testClosure);
         assertSame(testClosure, resultClosure);
         assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
+        // fix for various java 1.6 versions: keep the specialization
         resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col.iterator(), null);
         assertNull(resultClosure);
         assertTrue(collectionA.isEmpty() && collectionB.isEmpty());



Re: svn commit: r1369292 - /commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java

Posted by sebb <se...@gmail.com>.
On 4 August 2012 10:54, Thomas Neidhart <th...@gmail.com> wrote:
> On 08/04/2012 11:26 AM, sebb wrote:
>> On 4 August 2012 10:06,  <tn...@apache.org> wrote:
>>> Author: tn
>>> Date: Sat Aug  4 09:06:21 2012
>>> New Revision: 1369292
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1369292&view=rev
>>> Log:
>>> Add javadoc comment to prevent removal of a generics fix.
>>>
>>> Modified:
>>>     commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java
>>>
>>> Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java
>>> URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java?rev=1369292&r1=1369291&r2=1369292&view=diff
>>> ==============================================================================
>>> --- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java (original)
>>> +++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java Sat Aug  4 09:06:21 2012
>>> @@ -520,10 +520,11 @@ public class TestCollectionUtils extends
>>>          Collection<List<? extends Number>> col = new ArrayList<List<? extends Number>>();
>>>          col.add(collectionA);
>>>          col.add(collectionB);
>>> -        Closure<List<? extends Number>> resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, testClosure);
>>> +        Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col, testClosure);
>>>          assertSame(testClosure, resultClosure);
>>>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>>> -        resultClosure = CollectionUtils.forAllDo(col, null);
>>> +        // fix for various java 1.6 versions: keep the specialization
>>> +        resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, null);
>>>          assertNull(resultClosure);
>>>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>>>          resultClosure = CollectionUtils.forAllDo((Collection) null, testClosure);
>>> @@ -542,6 +543,7 @@ public class TestCollectionUtils extends
>>>          Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col.iterator(), testClosure);
>>>          assertSame(testClosure, resultClosure);
>>>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>>> +        // fix for various java 1.6 versions: keep the specialization
>>
>> Sorry, but what does that mean?
>
> hmm, would be "force type erasure" better?
>
> Certain java versions can not compile the following construct:
>
> resultClosure = CollectionUtils.forAllDo(col, null);
>
> when the return type is derived from a null argument parameter.

In which case, why not cast the null param?

That's sometimes needed even for non-generic code, so does not look
out of place.

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

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


Re: svn commit: r1369292 - /commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java

Posted by Thomas Neidhart <th...@gmail.com>.
On 08/04/2012 11:26 AM, sebb wrote:
> On 4 August 2012 10:06,  <tn...@apache.org> wrote:
>> Author: tn
>> Date: Sat Aug  4 09:06:21 2012
>> New Revision: 1369292
>>
>> URL: http://svn.apache.org/viewvc?rev=1369292&view=rev
>> Log:
>> Add javadoc comment to prevent removal of a generics fix.
>>
>> Modified:
>>     commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java
>>
>> Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java
>> URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java?rev=1369292&r1=1369291&r2=1369292&view=diff
>> ==============================================================================
>> --- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java (original)
>> +++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java Sat Aug  4 09:06:21 2012
>> @@ -520,10 +520,11 @@ public class TestCollectionUtils extends
>>          Collection<List<? extends Number>> col = new ArrayList<List<? extends Number>>();
>>          col.add(collectionA);
>>          col.add(collectionB);
>> -        Closure<List<? extends Number>> resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, testClosure);
>> +        Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col, testClosure);
>>          assertSame(testClosure, resultClosure);
>>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>> -        resultClosure = CollectionUtils.forAllDo(col, null);
>> +        // fix for various java 1.6 versions: keep the specialization
>> +        resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, null);
>>          assertNull(resultClosure);
>>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>>          resultClosure = CollectionUtils.forAllDo((Collection) null, testClosure);
>> @@ -542,6 +543,7 @@ public class TestCollectionUtils extends
>>          Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col.iterator(), testClosure);
>>          assertSame(testClosure, resultClosure);
>>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>> +        // fix for various java 1.6 versions: keep the specialization
> 
> Sorry, but what does that mean?

hmm, would be "force type erasure" better?

Certain java versions can not compile the following construct:

resultClosure = CollectionUtils.forAllDo(col, null);

when the return type is derived from a null argument parameter.

Thomas

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


Re: svn commit: r1369292 - /commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java

Posted by sebb <se...@gmail.com>.
On 4 August 2012 10:06,  <tn...@apache.org> wrote:
> Author: tn
> Date: Sat Aug  4 09:06:21 2012
> New Revision: 1369292
>
> URL: http://svn.apache.org/viewvc?rev=1369292&view=rev
> Log:
> Add javadoc comment to prevent removal of a generics fix.
>
> Modified:
>     commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java
>
> Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java
> URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java?rev=1369292&r1=1369291&r2=1369292&view=diff
> ==============================================================================
> --- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java (original)
> +++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/TestCollectionUtils.java Sat Aug  4 09:06:21 2012
> @@ -520,10 +520,11 @@ public class TestCollectionUtils extends
>          Collection<List<? extends Number>> col = new ArrayList<List<? extends Number>>();
>          col.add(collectionA);
>          col.add(collectionB);
> -        Closure<List<? extends Number>> resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, testClosure);
> +        Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col, testClosure);
>          assertSame(testClosure, resultClosure);
>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
> -        resultClosure = CollectionUtils.forAllDo(col, null);
> +        // fix for various java 1.6 versions: keep the specialization
> +        resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col, null);
>          assertNull(resultClosure);
>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>          resultClosure = CollectionUtils.forAllDo((Collection) null, testClosure);
> @@ -542,6 +543,7 @@ public class TestCollectionUtils extends
>          Closure<List<? extends Number>> resultClosure = CollectionUtils.forAllDo(col.iterator(), testClosure);
>          assertSame(testClosure, resultClosure);
>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
> +        // fix for various java 1.6 versions: keep the specialization

Sorry, but what does that mean?

>          resultClosure = CollectionUtils.<List<? extends Number>,Closure<List<? extends Number>>>forAllDo(col.iterator(), null);
>          assertNull(resultClosure);
>          assertTrue(collectionA.isEmpty() && collectionB.isEmpty());
>
>

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