HighTechTalks DotNet Forums  

Bug in ArrayList.toArray() method?

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss Bug in ArrayList.toArray() method? in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Keith McLeod
 
Posts: n/a

Default Bug in ArrayList.toArray() method? - 02-18-2005 , 10:51 AM






We are writing a GIS application in C# and using Vivid Solutions’ Java
Topology Suite converted to J# for our Computational Geometry library. I am
receiving a null reference exception on the following line of code…

object [] list = spatialIndex.query(new Envelope( minX + (ix * tileWidth),
minX + ((ix + 1) * tileWidth), maxY - (iy * tileHeight), maxY - ((iy + 1) *
tileHeight))).toArray();

This is the method being called…
protected List query(Object searchBounds) {
if (!built) { build(); }
ArrayList matches = new ArrayList();
if (itemBoundables.isEmpty()) {
Assert.isTrue(root.getBounds() == null);
return matches;
}
if (getIntersectsOp().intersects(root.getBounds(), searchBounds)) {
query(searchBounds, root, matches);
}
return matches;
}

I’ve stepped through the code and get all the way to the second "return
matches" statement. The matches object is indeed instantiated and has objects
(in this case they are ints) in it so it is definitely not null. This method
is used throughout the rest of the application and works fine. It just seems
to be the toArray method that is giving us a problem. I’m wondering if this
is a known bug in the J# runtime. We are using the J# redistributable package
1.1 along with the J# supplemental UI library.

One more bit of information, if I step through this code more than twice,
the exception then becomes a System.EngineException and I have to reboot my
computer.

Thank you in advance for any information you can provide regarding this issue.

Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default RE: Bug in ArrayList.toArray() method? - 02-22-2005 , 04:42 AM






Hi Keith,

Thanks for reporting this issue.
However is it possible for you to narrow it down to a small sample so that
I can compile and reproduce the problem?
This will help us in investigating the problem and get back to you sooner.

Thanks,
Amit
--------------------
Quote:
Thread-Topic: Bug in ArrayList.toArray() method?
thread-index: AcUV0abSJ5nTNayHT9mGp1q7fvXziQ==
X-WBNR-Posting-Host: 69.14.219.148
From: =?Utf-8?B?S2VpdGggTWNMZW9k?= <KeithMcLeod (AT) discussions (DOT) microsoft.com
Subject: Bug in ArrayList.toArray() method?
Date: Fri, 18 Feb 2005 07:51:04 -0800
Lines: 35
Message-ID: <43F84242-058E-4710-87B6-B3F16AC89021 (AT) microsoft (DOT) com
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.vjsharp
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.vjsharp:1135
X-Tomcat-NG: microsoft.public.dotnet.vjsharp

We are writing a GIS application in C# and using Vivid Solutions’ Java
Topology Suite converted to J# for our Computational Geometry library. I
am
receiving a null reference exception on the following line of code…

object [] list = spatialIndex.query(new Envelope( minX + (ix * tileWidth),
minX + ((ix + 1) * tileWidth), maxY - (iy * tileHeight), maxY - ((iy + 1)
*
tileHeight))).toArray();

This is the method being called…
protected List query(Object searchBounds) {
if (!built) { build(); }
ArrayList matches = new ArrayList();
if (itemBoundables.isEmpty()) {
Assert.isTrue(root.getBounds() == null);
return matches;
}
if (getIntersectsOp().intersects(root.getBounds(), searchBounds)) {
query(searchBounds, root, matches);
}
return matches;
}

I’ve stepped through the code and get all the way to the second "return
matches" statement. The matches object is indeed instantiated and has
objects
(in this case they are ints) in it so it is definitely not null. This
method
is used throughout the rest of the application and works fine. It just
seems
to be the toArray method that is giving us a problem. I’m wondering if
this
is a known bug in the J# runtime. We are using the J# redistributable
package
1.1 along with the J# supplemental UI library.

One more bit of information, if I step through this code more than twice,
the exception then becomes a System.EngineException and I have to reboot
my
computer.

Thank you in advance for any information you can provide regarding this
issue.



Reply With Quote
  #3  
Old   
Steve Hickman
 
Posts: n/a

Default RE: Bug in ArrayList.toArray() method? - 03-08-2005 , 11:53 AM



The problem may not be with toArray(). I've noticed that ArrayList will
occasionally be improperly constructed, with nextItem being null when in fact
I'm not at the end of the list. In these situations, the length of the
ArrayList as shown in the .NET debugger shows more items than I can navigate
to by opening nextItem. However, if I open prevItem and then the nextItem of
the prevItem, I can always (so far at least) get to all the items on the
list. This construction problem, when I've seen it, has always happened
between the first and second items in the ArrayList.

I haven't yet figured out the exact cause of this. The problem is showing up
consistently for me right now, but the code where it shows up works the first
4 times it executes, then consistently fails the 5th time with an improperly
constructed list. I'd provide a simple example if I could, but I don't have
one at this time.

"Keith McLeod" wrote:

Quote:
We are writing a GIS application in C# and using Vivid Solutions’ Java
Topology Suite converted to J# for our Computational Geometry library. I am
receiving a null reference exception on the following line of code…

object [] list = spatialIndex.query(new Envelope( minX + (ix * tileWidth),
minX + ((ix + 1) * tileWidth), maxY - (iy * tileHeight), maxY - ((iy + 1) *
tileHeight))).toArray();

This is the method being called…
protected List query(Object searchBounds) {
if (!built) { build(); }
ArrayList matches = new ArrayList();
if (itemBoundables.isEmpty()) {
Assert.isTrue(root.getBounds() == null);
return matches;
}
if (getIntersectsOp().intersects(root.getBounds(), searchBounds)) {
query(searchBounds, root, matches);
}
return matches;
}

I’ve stepped through the code and get all the way to the second "return
matches" statement. The matches object is indeed instantiated and has objects
(in this case they are ints) in it so it is definitely not null. This method
is used throughout the rest of the application and works fine. It just seems
to be the toArray method that is giving us a problem. I’m wondering if this
is a known bug in the J# runtime. We are using the J# redistributable package
1.1 along with the J# supplemental UI library.

One more bit of information, if I step through this code more than twice,
the exception then becomes a System.EngineException and I have to reboot my
computer.

Thank you in advance for any information you can provide regarding this issue.

Reply With Quote
  #4  
Old   
Steve Hickman
 
Posts: n/a

Default RE: Bug in ArrayList.toArray() method? - 03-08-2005 , 12:09 PM



My apologies - I misposted. The bug I'm experiencing is with LinkedList, not
ArrayList.

"Steve Hickman" wrote:

Quote:
The problem may not be with toArray(). I've noticed that ArrayList will
occasionally be improperly constructed, with nextItem being null when in fact
I'm not at the end of the list. In these situations, the length of the
ArrayList as shown in the .NET debugger shows more items than I can navigate
to by opening nextItem. However, if I open prevItem and then the nextItem of
the prevItem, I can always (so far at least) get to all the items on the
list. This construction problem, when I've seen it, has always happened
between the first and second items in the ArrayList.

I haven't yet figured out the exact cause of this. The problem is showing up
consistently for me right now, but the code where it shows up works the first
4 times it executes, then consistently fails the 5th time with an improperly
constructed list. I'd provide a simple example if I could, but I don't have
one at this time.

"Keith McLeod" wrote:

We are writing a GIS application in C# and using Vivid Solutions’ Java
Topology Suite converted to J# for our Computational Geometry library. I am
receiving a null reference exception on the following line of code…

object [] list = spatialIndex.query(new Envelope( minX + (ix * tileWidth),
minX + ((ix + 1) * tileWidth), maxY - (iy * tileHeight), maxY - ((iy + 1) *
tileHeight))).toArray();

This is the method being called…
protected List query(Object searchBounds) {
if (!built) { build(); }
ArrayList matches = new ArrayList();
if (itemBoundables.isEmpty()) {
Assert.isTrue(root.getBounds() == null);
return matches;
}
if (getIntersectsOp().intersects(root.getBounds(), searchBounds)) {
query(searchBounds, root, matches);
}
return matches;
}

I’ve stepped through the code and get all the way to the second "return
matches" statement. The matches object is indeed instantiated and has objects
(in this case they are ints) in it so it is definitely not null. This method
is used throughout the rest of the application and works fine. It just seems
to be the toArray method that is giving us a problem. I’m wondering if this
is a known bug in the J# runtime. We are using the J# redistributable package
1.1 along with the J# supplemental UI library.

One more bit of information, if I step through this code more than twice,
the exception then becomes a System.EngineException and I have to reboot my
computer.

Thank you in advance for any information you can provide regarding this issue.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.