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.
There appears to be a problem with the get(int) accessor method on List objects implemented by MDR. We have MOF modelled a RecordType class which has on ordered collection of RecordField. This is correctly specified in the generated RecordType JMI interface as: List getRecordFields(); The contract of the List's get(int index) method is that it should throw an IndexOutOfBoundsException under the following conditions: if ((index < 0 ) || (index >= list.size())) throw new IndexOutOfBoundsException(); However for the underlying List implemented by MDR for a List defined in a JMI interface, the followwing occurs: if (list.size() == 0) // throws Exceptions correctly if ((list.size() > 0) && (index < 0)) // Returns element #0 if ((list.size() > 0) && (index >= list.size())) // throws Exceptions correctly For Example the following code will not throw an IndexOutOfBoundsException ... ... // Create a RecordType object which aggregates a List of RecordFields RecordType recordType = pkg.getRecordType ().createRecordType(); List fields = recordType.getRecordFields(); // Create some field Objects in the List RecordField field = pkg.getRecordField().createRecordField (); field.setName("First Field"); recordType.getRecordFields().add(field); field = pkg.getRecordField().createRecordField(); field.setName("Second Field"); recordType.getRecordFields().add(field); field = pkg.getRecordField().createRecordField(); field.setName("Third Field"); recordType.getRecordFields().add(field); try { RecordField rf = (RecordField)fields.get(-1); fail("Failed to throw OOB Exception"); } catch (IndexOutOfBoundsException aioobe) { // OK }
I need a clarification. The recordField feature of RecordType class is a reference or an attribute? (I need to know this, because in each of these two cases it is handled by different implementation of the List interface).
OK, I think I have fixed it. Since I do not have your test, I haven't tested it, but I am quite sure that it is fixed. Please let me know if you try it (by either marking this issue as verified or reopened if it does not work). Fix is in the CVS.
I have tested and verified this fix.