harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Artem Aliev (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2425) [luni] java.util.concurrent.LinkedBlockingQueue.toArray(Object[]) do not set element next to the end of collection to null
Date Mon, 04 Dec 2006 13:08:21 GMT
[luni] java.util.concurrent.LinkedBlockingQueue.toArray(Object[]) do not set element next to
the end of collection to null
--------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-2425
                 URL: http://issues.apache.org/jira/browse/HARMONY-2425
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Artem Aliev


As specificaton says, if collection fits into array with room to spare, the
element in the array immediately following the end of the collection must be
set to null.

Test to reproduce:
import junit.framework.TestCase;

import java.util.concurrent.*;

public class Test extends TestCase {

        public void testcase() {
                LinkedBlockingQueue lbq = new LinkedBlockingQueue();
                int i = lbq.size();
                Object[] resulta, obja = new Object[] {
                                new Integer(1),
                                new Integer(42),
                                new Integer(53) };

        System.out.println("lbq = " + lbq);
        System.out.println("lbq.size() = " + lbq.size());
        for (int j = 0; j < obja.length; j++) {
            System.out.println("-1- obja[" + j + "] = " + obja[j]);
                }
        assertTrue("obja.length > lbq.size()", obja.length > lbq.size());
        resulta = lbq.toArray(obja);
        for (int j = 0; j < obja.length; j++) {
            System.out.println("-2- obja[" + j + "] = " + obja[j]);
                }
        for (int j = 0; j < resulta.length; j++) {
            System.out.println("resulta[" + j + "] = " + resulta[j]);
                }
        assertTrue("resulta[i] == null" , resulta[i] == null);
    }
}

Output on Harmony:
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software
Foundation or its licensors, as applicable.
java version "1.5.0" 
pre-alpha : not complete or compatible
svn = rsvn: '.' is not a working copy, (Sep 20 2006), Windows/ia32/msvc 1310,
release build
http://incubator.apache.org/harmony

.lbq = []
lbq.size() = 0
-1- obja[0] = 1
-1- obja[1] = 42
-1- obja[2] = 53
-2- obja[0] = 1
-2- obja[1] = 42
-2- obja[2] = 53
resulta[0] = 1
resulta[1] = 42
resulta[2] = 53
F
Time: 0.032
There was 1 failure:
1) testcase(Test)junit.framework.AssertionFailedError: resulta[i] == null
        at Test.testcase(Test.java:28)
        at java.lang.reflect.VMReflection.invokeMethod(Native Method)

FAILURES!!!
Tests run: 1,  Failures: 1,  Errors: 0

res = 1


Output on RI:
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
.lbq = []
lbq.size() = 0
-1- obja[0] = 1
-1- obja[1] = 42
-1- obja[2] = 53
-2- obja[0] = null
-2- obja[1] = 42
-2- obja[2] = 53
resulta[0] = null
resulta[1] = 42
resulta[2] = 53

Time: 0

OK (1 test)

res = 0


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message