JDK-8257466 : Improve enum iteration
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-12-01
  • Updated: 2020-12-22
  • Resolved: 2020-12-03
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.
JDK 16
16 b28Fixed
Related Reports
Relates :  
Relates :  
Description
Use of the new enum iteration facility has turned up some additional features that would be useful.

EnumRange and EnumIterator should provide a nested type name for the associated enum type.  This is useful when the range or iterator type isn't known but is instead itself a template parameter.

EnumRange should provide an index operation that converts from an enumerator to a zero-based index into the range. Some applications have arrays where the array elements are 1-1 with the enumerators in the range. Such an index function is useful for mapping from an enumerator value to the corresponding array index. This can be done with conversions to the underlying type, but that's kind of clumsy.

Some enums have ranges of values rather than named enumerators.  There are some additions to EnumIterator and EnumRange that are helpful when working with such enums.

- EnumRange should provide accessors for the range bounds. One can get them by dereferencing begin and end iterators, but that's kind of clumsy.

- The underlying EnumeratorRange and EnumTraits infrastructure should be extended to allow the range to be specified as start and (exclusive) end values of the enum's underlying type.

There also should be unit unit tests for enum iteration.

Comments
Changeset: 39325272 Author: Kim Barrett <kbarrett@openjdk.org> Date: 2020-12-03 04:26:23 +0000 URL: https://git.openjdk.java.net/jdk/commit/39325272
03-12-2020