JDK-8342639 : Global operator new in adlc has wrong exception spec
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 24
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-10-18
  • Updated: 2025-06-19
  • Resolved: 2025-06-07
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 b02Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
In adlc/main.cpp there is a global definition of
`operator new(size_t, int, const char*, int) throw()`
https://github.com/openjdk/jdk/blob/309b929147e7dddfa27879ff31b1eaad271def85/src/hotspot/share/adlc/main.cpp#L494-L498

It is conditionally defined, being defined for
`!defined(_WIN32) || _WIN64`
and used to (until JDK-8288094) additionally be defined if
`_MSC_VER < 14`
with a comment that VS 2005 provides a definition.

(Other than the _MSC_VER check removal, this has been present since before the mercurial age.)

So it is defined for non-Windows and _WIN64, and (previously) for _WIN32 with a sufficiantly old version of VS.

So what is this for?  Well, it turns out there is a declaration for it in vcruntime_new_debug.h, so it's part of the VS runtime support.  That declaration doesn't have the nothrow exception specification that our definition has.  I stumbled across this when trying to build with C++17, where the exception specification mismatch gets rejected.  The nothrow exception spec was added by JDK-8021954.  It should have been removed by JDK-8305590, but appears to have been overlooked.

We don't use it directly. I didn't try to figure out whether we ever used it directly, but doubt it. I suspect we never did, and it only exists to support building adlc in some configuration where debug declarations from the VS runtime library were used but the corresponding library wasn't linked or didn't provide a definition.

The simplest change that would permit building with C++17 is to remove the nothrow exception specification from our definition.

Additionally, it seems likely that defining it for non-Windows is unnecessary, and we could remove the `!defined(_WIN32)` part of the conditional.

It might even be that we can remove the definition entirely.

Our definition calls the global `operator new(size_t)`, and the default implementation throws, though I'm not sure what it does when building with exceptions disabled.  And JDK-8306579 might also be relevant.  These all seem like arguments for removing the definition entirely if we can.

Comments
Changeset: e94ad551 Branch: master Author: Kim Barrett <kbarrett@openjdk.org> Date: 2025-06-07 20:34:34 +0000 URL: https://git.openjdk.org/jdk/commit/e94ad551c6d31b91ec066f92f9bbdb956f54e887
07-06-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25668 Date: 2025-06-06 06:07:43 +0000
06-06-2025

JDK-8339783 is removing the conditionalization of the definition, since with the removal of 32bit windows support the conditional is always true.
30-10-2024

It's only Windows configurations that might get tripped up by removal. Since the prootype only shows up in a debug header, there might be some debug option that leads to needing it.
28-10-2024

Note that the adlc is only used during the build, so running builds on various platforms is sufficient. I've quickly tried building on linux x64, ppc64le and AIX and found no problems after removing the problematic new operator. +1 for removing it!
28-10-2024

I did a bit of experimenting with removing the definition entirely. Didn't run into any problems in Oracle's CI up through tier5. I can't be sure there isn't some oddball configuration that will get tripped up by the removal, but it seems promising.
19-10-2024