This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Since there are not any rules (?) when TreeModel#getChildrenCount and TreeModel#getChildren are called it is hardly achievable to ensure correct behavior and prevent exception. Since, in the time between the TM#getChildrenCount and TM#getChildren are called, the debugging session might have changed, one can either return old cached (during TM#getChildrenCount) values from TM#getChildren was called (but again there is not any API contract that says when is what called) or I can return fresh values from TM#getChildren, which might cause AIOOBE and similar. We talked about it with Martin and he suggests to return Integer.MAX_VALUE as a temporary workaround until this is fixed.
The rule is - when the user expands the view and when you fire a model changed event. I agree that this API is not easy to use, but the bounds can always be checked to return the correct data. Simple if statements prevent from exceptions. There are basically three solutions: - cache the data berween TreeModel.getChildrenCount() and TreeModel.getChildren() - always return fresh data, but check the bounds - return Integer.MAX_VALUE from TreeModel.getChildrenCount() We definitely want to consider issue #105608, this is the reason why there are two methods for retrieval of children. This will definitely not be changed for 6.0. I would rather make this a duplicate of issue #105608, which should finally give a meaning to this API. Do you agree?
> I would rather make this a duplicate of issue #105608, which should finally give a meaning to this API. Do you agree? If the rules > - cache the data berween TreeModel.getChildrenCount() and TreeModel.getChildren() > - always return fresh data, but check the bounds > - return Integer.MAX_VALUE from TreeModel.getChildrenCount() holds and would be written down into the Javadoc (at least some of them), then why not. Since there would be some 'official' way how to use API correctly. Otherwise, I think that almost everybody implementing a debugger for NetBeans will run into the same problem - therefore without the Javadoc it is bug IMHO.
I consider these more like implementation hints than rules, since it's up to the implementor at the end. I'll add it into the Javadoc...
So, the Javadoc is extended: /shared/data/ccvs/repository/debuggercore/viewmodel/src/org/netbeans/spi/viewmodel/TreeModel.java,v <-- TreeModel.java new revision: 1.10; previous revision: 1.9 The rest will be solved in issue #105608. *** This issue has been marked as a duplicate of 105608 ***
Verified ... and Closing all issues resolved into NetBeans 6.7 and earlier.