JDK-8361088 : Update javax.management ArrayList classes iterator behaviour
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-06-30
  • Updated: 2025-06-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
The classes javax.management.AttributeList, and javax.management.relation.RoleList and UnresolvedRoleList all extend java.util.ArrayList, and do not override the set and add methods of the iterator returned by the listIterator method.

This may provide a way to make such lists contain objects of incorrect types.  The underlying list can be mutated using the iterator's set() or add() methods.


Comments
Might be helpful to have some quick note in the affected classes stating "...typesafe for updates made through the listIterator too", or words to that effect.
30-06-2025

Thanks [~darcy] ! I'm looking at adding this kind of test to the testcase I'm updating as part of the PR for CSR JDK-8359917. (and this issue can be not a bug)
30-06-2025

FYI, I wrote a small test program and the correct exception looks to be thrown: import javax.management.*; public class Test { public static void main(String... args) { Attribute foo = new Attribute("foo", 1); Attribute bar = new Attribute("bar", 2); AttributeList attribList = new AttributeList(2); attribList.add(foo); attribList.add(bar); var list2 = attribList.asList(); // make type safe var listIterator = attribList.listIterator(); while (listIterator.hasNext()) { listIterator.next(); listIterator.set("Busted"); } } }
30-06-2025