JDK-8365829 : Multiple definitions of static 'phase_names'
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 26
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-08-20
  • Updated: 2025-08-28
  • Resolved: 2025-08-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 26
26 b13Fixed
Related Reports
Causes :  
Relates :  
Description
- "opto/phasetype.hpp" defines "static const char* phase_names[]" 
- "compiler/compilerEvent.cpp" defines "static GrowableArray<const char*>* phase_names".

This is not a problem when the two files are compiled as different translation units, but it causes a build failure if any of them is pulled in by a precompiled header:

```
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:59:36: error: redefinition of 'phase_names' with a different type: 'GrowableArray<const char *> *' vs 'const char *[100]'
   59 | static GrowableArray<const char*>* phase_names = nullptr;
      |                                    ^
/jdk/src/hotspot/share/opto/phasetype.hpp:147:20: note: previous definition is here
  147 | static const char* phase_names[] = {
      |                    ^
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:67:39: error: member reference base type 'const char *' is not a structure or union
   67 |     const u4 nof_entries = phase_names->length();
      |                            ~~~~~~~~~~~^ ~~~~~~
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:71:31: error: member reference base type 'const char *' is not a structure or union
   71 |       writer.write(phase_names->at(i));
      |                    ~~~~~~~~~~~^ ~~
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:77:34: error: member reference base type 'const char *' is not a structure or union
   77 |   for (int i = 0; i < phase_names->length(); i++) {
      |                       ~~~~~~~~~~~^ ~~~~~~
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:78:35: error: member reference base type 'const char *' is not a structure or union
   78 |     const char* name = phase_names->at(i);
      |                        ~~~~~~~~~~~^ ~~
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:91:9: error: comparison of array 'phase_names' equal to a null pointer is always false [-Werror,-Wtautological-pointer-compare]
   91 |     if (phase_names == nullptr) {
      |         ^~~~~~~~~~~    ~~~~~~~
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:92:19: error: array type 'const char *[100]' is not assignable
   92 |       phase_names = new (mtInternal) GrowableArray<const char*>(100, mtCompiler);
      |       ~~~~~~~~~~~ ^
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:103:24: error: member reference base type 'const char *' is not a structure or union
  103 |     index = phase_names->length();
      |             ~~~~~~~~~~~^ ~~~~~~
/jdk/src/hotspot/share/compiler/compilerEvent.cpp:104:16: error: member reference base type 'const char *' is not a structure or union
  104 |     phase_names->append(use_strdup ? os::strdup(phase_name) : phase_name);
      |     ~~~~~~~~~~~^ ~~~~~~
9 errors generated.
```
Comments
Changeset: 19882220 Branch: master Author: Francesco Andreuzzi <andreuzzi.francesco@gmail.com> Committer: Paul Hohensee <phh@openjdk.org> Date: 2025-08-22 17:36:52 +0000 URL: https://git.openjdk.org/jdk/commit/19882220ecb3eeaef763ccbb0aa4d7760c906222
22-08-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26851 Date: 2025-08-20 01:12:36 +0000
20-08-2025