JDK-8253402 : Convert vmSymbols::SID to enum class
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-09-21
  • Updated: 2020-12-11
  • Resolved: 2020-10-15
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 b21Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Convert vmSymbols::SID to enum class to provide better type safety. 

Also implement proper enumerators for this type of enums to avoid code like this (which might get out of bounds if you're not careful):

    for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
      vm_symbol_index[index] = (SID)index;
    }

The new iteration style is:

    for (vmSymbolID index : vmSymbolsIterator()) {
      vm_symbol_index[as_int(index)] = index;
    }


Also, implement type-safe casting from ints to SIDs, and vice versa.
Comments
Changeset: 7e5eb493 Author: Ioi Lam <iklam@openjdk.org> Date: 2020-10-15 05:52:54 +0000 URL: https://git.openjdk.java.net/jdk/commit/7e5eb493
15-10-2020