JDK-8139040 : Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-10-07
  • Updated: 2016-09-15
  • Resolved: 2015-10-22
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 8 JDK 9
8u102Fixed 9 b93Fixed
Description
In several places variables are initializaed in switch statements or the like, where the default case is decorated with ShouldNotReachHere() and the initialization is missing.

In the debug build, ShouldNotReachHere() can be suppressed, so the uninitialized value actually can cause problems.

In opt builds, not all tools recognize the ShouldNotReachHere properly.

This adds a row of initializations where I encountered problems and enables -Wuninitialized with linux gcc 4.8.
This would find most of these warnings.  The flag works best in the product build, as it depends on compiler optimizations. 

This unveiled some missing initializations in constructors, as in compile.hpp and oopMap.hpp, that can actually cause wrong behavior.