diff --git a/.github/actions/build-jtreg/action.yml b/.github/actions/build-jtreg/action.yml index 0ba9937fb45..a9c046e9dd9 100644 --- a/.github/actions/build-jtreg/action.yml +++ b/.github/actions/build-jtreg/action.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/.github/actions/get-bundles/action.yml b/.github/actions/get-bundles/action.yml index 270d15159a0..a356aa9fd8d 100644 --- a/.github/actions/get-bundles/action.yml +++ b/.github/actions/get-bundles/action.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/.github/actions/get-gtest/action.yml b/.github/actions/get-gtest/action.yml index d38d33eabd8..7a329460a6e 100644 --- a/.github/actions/get-gtest/action.yml +++ b/.github/actions/get-gtest/action.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/.github/actions/get-jtreg/action.yml b/.github/actions/get-jtreg/action.yml index 4bb671d25d1..36c895fc59d 100644 --- a/.github/actions/get-jtreg/action.yml +++ b/.github/actions/get-jtreg/action.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/.github/actions/get-msys2/action.yml b/.github/actions/get-msys2/action.yml index d93b6e3763b..308230ebf2e 100644 --- a/.github/actions/get-msys2/action.yml +++ b/.github/actions/get-msys2/action.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/.github/actions/upload-bundles/action.yml b/.github/actions/upload-bundles/action.yml index ca5366f3d6c..78fb0a94bfd 100644 --- a/.github/actions/upload-bundles/action.yml +++ b/.github/actions/upload-bundles/action.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/.github/workflows/build-alpine-linux.yml b/.github/workflows/build-alpine-linux.yml index 0d366a4bdd0..c39962fa07f 100644 --- a/.github/workflows/build-alpine-linux.yml +++ b/.github/workflows/build-alpine-linux.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ on: jobs: build-linux: name: build - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 container: image: alpine:3.20 @@ -96,6 +96,8 @@ jobs: --with-boot-jdk=${{ steps.bootjdk.outputs.path }} --with-zlib=system --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none + --with-native-debug-symbols-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index b3c63f488a0..a0642d469aa 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ on: jobs: build-cross-compile: name: build - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false @@ -179,6 +179,8 @@ jobs: --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} --with-sysroot=sysroot --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none + --with-native-debug-symbols-level=1 CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index f398625cb2c..791b53a3f04 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ on: jobs: build-linux: name: build - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false @@ -115,9 +115,21 @@ jobs: if [[ '${{ inputs.apt-architecture }}' != '' ]]; then sudo dpkg --add-architecture ${{ inputs.apt-architecture }} fi - sudo apt-get update - sudo apt-get install --only-upgrade apt - sudo apt-get install gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }} + sudo apt update + sudo apt install --only-upgrade apt + sudo apt install \ + gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} \ + g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} \ + libasound2-dev${{ steps.arch.outputs.suffix }} \ + libcups2-dev${{ steps.arch.outputs.suffix }} \ + libfontconfig1-dev${{ steps.arch.outputs.suffix }} \ + libx11-dev${{ steps.arch.outputs.suffix }} \ + libxext-dev${{ steps.arch.outputs.suffix }} \ + libxrandr-dev${{ steps.arch.outputs.suffix }} \ + libxrender-dev${{ steps.arch.outputs.suffix }} \ + libxt-dev${{ steps.arch.outputs.suffix }} \ + libxtst-dev${{ steps.arch.outputs.suffix }} \ + ${{ inputs.apt-extra-packages }} sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} - name: 'Configure' @@ -131,6 +143,8 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --with-zlib=system --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none + --with-native-debug-symbols-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 0a12df668e5..484e616fad7 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -110,6 +110,8 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --with-zlib=system --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none + --with-native-debug-symbols-level=1 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index a3091b94cef..4dafc016a99 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -134,6 +134,7 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --with-msvc-toolset-version=${{ inputs.msvc-toolset-version }} --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d8663fab1a..85ec75f343c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ jobs: prepare: name: 'Prepare the run' - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 env: # List of platforms to exclude by default EXCLUDED_PLATFORMS: 'alpine-linux-x64' @@ -327,8 +327,8 @@ jobs: uses: ./.github/workflows/build-macos.yml with: platform: macos-x64 - runs-on: 'macos-13' - xcode-toolset-version: '14.3.1' + runs-on: 'macos-15-intel' + xcode-toolset-version: '16.4' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }} @@ -340,8 +340,8 @@ jobs: uses: ./.github/workflows/build-macos.yml with: platform: macos-aarch64 - runs-on: 'macos-14' - xcode-toolset-version: '15.4' + runs-on: 'macos-15' + xcode-toolset-version: '16.4' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }} @@ -405,7 +405,7 @@ jobs: with: platform: linux-x64 bootjdk-platform: linux-x64 - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }} debug-suffix: -debug @@ -419,7 +419,7 @@ jobs: with: platform: linux-x64 bootjdk-platform: linux-x64 - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }} static-suffix: "-static" @@ -432,9 +432,9 @@ jobs: with: platform: macos-aarch64 bootjdk-platform: macos-aarch64 - runs-on: macos-14 + runs-on: macos-15 dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }} - xcode-toolset-version: '15.4' + xcode-toolset-version: '16.4' debug-suffix: -debug test-windows-x64: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2c8916a369..8f33454305e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/.gitignore b/.gitignore index 9145a9fa67b..0743489f8ec 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,9 @@ NashornProfile.txt **/core.[0-9]* *.rej *.orig +test/benchmarks/**/target +/src/hotspot/CMakeLists.txt +/src/hotspot/compile_commands.json +/src/hotspot/cmake-build-debug/ +/src/hotspot/.cache/ +/src/hotspot/.idea/ diff --git a/.jcheck/conf b/.jcheck/conf index 60881e74d2a..25af49f8ef8 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1,7 +1,7 @@ [general] project=jdk jbs=JDK -version=26 +version=27 [checks] error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace,problemlists,copyright diff --git a/README.md b/README.md index b3f30676b3c..e939f6a9ca4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Welcome to the JDK! For build instructions please see the -[online documentation](https://openjdk.org/groups/build/doc/building.html), +[online documentation](https://git.openjdk.org/jdk/blob/master/doc/building.md), or either of these files: - [doc/building.html](doc/building.html) (html version) diff --git a/bin/generate-symbol-data.sh b/bin/generate-symbol-data.sh index 283757a6918..14d8763ad81 100644 --- a/bin/generate-symbol-data.sh +++ b/bin/generate-symbol-data.sh @@ -38,7 +38,7 @@ # directory. # - open a terminal program and run these commands: # cd "${JDK_CHECKOUT}"/src/jdk.compiler/share/data/symbols -# bash ../../../../../make/scripts/generate-symbol-data.sh "${JDK_N_INSTALL}" +# bash ../../../../../bin/generate-symbol-data.sh "${JDK_N_INSTALL}" # - this command will generate or update data for "--release N" into the ${JDK_CHECKOUT}/src/jdk.compiler/share/data/symbols # directory, updating all registration necessary. If the goal was to update the data, and there are no # new or changed files in the ${JDK_CHECKOUT}/src/jdk.compiler/share/data/symbols directory after running this script, diff --git a/doc/building.html b/doc/building.html index 99eb3e0c473..8e5a7625371 100644 --- a/doc/building.html +++ b/doc/building.html @@ -541,6 +541,11 @@ href="#apple-xcode">Apple Xcode on some strategies to deal with this.
It is recommended that you use at least macOS 14 and Xcode 15.4, but earlier versions may also work.
+Starting with Xcode 26, introduced in macOS 26, the Metal toolchain
+no longer comes bundled with Xcode, so it needs to be installed
+separately. This can either be done via the Xcode's Settings/Components
+UI, or in the command line calling
+xcodebuild -downloadComponent metalToolchain.
The standard macOS environment contains the basic tooling needed to build, but for external libraries a package manager is recommended. The JDK uses homebrew in the examples, but @@ -668,7 +673,7 @@ update.
(Note that this version is often presented as "MSVC 14.28", and reported by cl.exe as 19.28.) Older versions will not be accepted byconfigure and will not work. The maximum accepted version
-of Visual Studio is 2022.
+of Visual Studio is 2026.
If you have multiple versions of Visual Studio installed,
configure will by default pick the latest. You can request
a specific version to be used by setting
diff --git a/doc/building.md b/doc/building.md
index 047255d1848..b626027f101 100644
--- a/doc/building.md
+++ b/doc/building.md
@@ -352,6 +352,11 @@ on some strategies to deal with this.
It is recommended that you use at least macOS 14 and Xcode 15.4, but
earlier versions may also work.
+Starting with Xcode 26, introduced in macOS 26, the Metal toolchain no longer
+comes bundled with Xcode, so it needs to be installed separately. This can
+either be done via the Xcode's Settings/Components UI, or in the command line
+calling `xcodebuild -downloadComponent metalToolchain`.
+
The standard macOS environment contains the basic tooling needed to build, but
for external libraries a package manager is recommended. The JDK uses
[homebrew](https://brew.sh/) in the examples, but feel free to use whatever
@@ -468,7 +473,7 @@ available for this update.
The minimum accepted version is Visual Studio 2019 version 16.8. (Note that
this version is often presented as "MSVC 14.28", and reported by cl.exe as
19.28.) Older versions will not be accepted by `configure` and will not work.
-The maximum accepted version of Visual Studio is 2022.
+The maximum accepted version of Visual Studio is 2026.
If you have multiple versions of Visual Studio installed, `configure` will by
default pick the latest. You can request a specific version to be used by
diff --git a/doc/hotspot-style.html b/doc/hotspot-style.html
index f1c25dab7f4..362245cd00a 100644
--- a/doc/hotspot-style.html
+++ b/doc/hotspot-style.html
@@ -114,7 +114,7 @@ id="toc-compatibility-with-c11">Compatibility with C11
id="toc-additional-permitted-features">Additional Permitted
Features
-
This section describes that subset. Features from the C++98/03 -language may be used unless explicitly excluded here. Features from +language may be used unless explicitly forbidden here. Features from C++11, C++14, and C++17 may be explicitly permitted or explicitly -excluded, and discussed accordingly here. There is a third category, +forbidden, and discussed accordingly here. There is a third category, undecided features, about which HotSpot developers have not yet reached a consensus, or perhaps have not discussed at all. Use of these features -is also excluded.
+is also forbidden.(The use of some features may not be immediately obvious and may slip in anyway, since the compiler will accept them. The code review process is the main defense against this.)
Some features are discussed in their own subsection, typically to provide more extensive discussion or rationale for limitations. Features that don't have their own subsection are listed in omnibus feature -sections for permitted, excluded, and undecided features.
+sections for permitted, forbidden, and undecided features.Lists of new features for C++11, C++14, and C++17, along with links to their descriptions, can be found in the online documentation for some of the compilers and libraries. The C++17 Standard is the definitive @@ -594,14 +594,15 @@ title="Runtime Type Information">RTTI
are deemed not worthwhile, given the alternatives.Do not use the standard global allocation and deallocation functions -(operator new and related functions). Use of these functions by HotSpot -code is disabled for some platforms.
+(globaloperator new and related functions), other than the
+non-allocating forms of those functions. Use of these functions by
+HotSpot code is disabled for some platforms.
Rationale: HotSpot often uses "resource" or "arena" allocation. Even where heap allocation is used, the standard global functions are avoided -in favor of wrappers around malloc and free that support the VM's Native -Memory Tracking (NMT) feature. Typically, uses of the global operator -new are inadvertent and therefore often associated with memory -leaks.
+in favor of wrappers aroundmalloc and free
+that support the JVM's Native Memory Tracking (NMT) feature. Typically,
+uses of the global operator new are inadvertent and
+therefore often associated with memory leaks.
Native memory allocation failures are often treated as non-recoverable. The place where "out of memory" is (first) detected may be an innocent bystander, unrelated to the actual culprit.
@@ -648,7 +649,39 @@ for anonymous namespaces. class="uri">https://sourceware.org/bugzilla/show_bug.cgi?id=16874Avoid using the C++ Standard Library.
+Only curated parts of the C++ Standard Library may be used by HotSpot +code.
+Functions that may throw exceptions must not be used. This is in +accordance with the HotSpot policy of not +using exceptions.
+Also in accordance with HotSpot policy, the standard global allocator must not be +used. This means that uses of standard container classes cannot +presently be used, as doing so requires specialization on some allocator +type that is integrated with the existing HotSpot allocation mechanisms. +(Such allocators may be provided in the future.)
+Standard Library identifiers should usually be fully qualified;
+using directives must not be used to bring Standard Library
+identifiers into scope just to remove the need for namespace
+qualification. Requiring qualification makes it easy to distinguish
+between references to external libraries and code that is part of
+HotSpot.
As with language features, Standard Library facilities are either +permitted, explicitly forbidden, or undecided (and so implicitly +forbidden).
+Most HotSpot code should not directly #include C++
+Standard Library headers. HotSpot provides a set of wrapper headers for
+the Standard Library headers containing permitted definitions. These
+wrappers are in the cppstdlib directory, with the same name
+as the corresponding Standard Library header and a .hpp
+extension. These wrappers provide a place for any additional code (some
+of which may be platform-specific) needed to support HotSpot usage.
These wrappers also provide a place to document HotSpot usage, +including any restrictions. The set of wrappers and the usage +documentation should be considered part of HotSpot style. Any changes +are subject to the same process as applies to this document. (For +historical reasons, there may be many direct inclusions of some C++ +Standard Library headers.)
Historically, HotSpot has mostly avoided use of the Standard Library.
(It used to be impossible to use most of it in shared code, because @@ -661,46 +694,60 @@ in mid-2017. Support for Solaris was removed in 2020.)
of Standard Library facilities is exceptions. HotSpot does not use exceptions and, for platforms which allow doing so, builds with them turned off. Many Standard Library facilities implicitly or explicitly -use exceptions.assert. An issue that is quickly encountered is the
assert macro name collision (JDK-8007770).
-Some mechanism for addressing this would be needed before much of the
-Standard Library could be used. (Not all Standard Library
-implementations use assert in header files, but some do.)
assert in
+header files, but some do.) HotSpot provides a mechanism for addressing
+this, by establishing a scope around the include of a library header
+where the HotSpot assert macro is suppressed. One of the
+reasons for using wrapper headers rather than directly including
+standard headers is to provide a central place to deal with this issue
+for each header.
Memory allocation. HotSpot requires explicit control over where
allocations occur. The C++98/03 std::allocator class is too
-limited to support our usage. (Changes in more recent Standards may
-remove this limitation.)
Implementation vagaries. Bugs, or simply different implementation choices, can lead to different behaviors among the various Standard -Libraries we need to deal with.
Inconsistent naming conventions. HotSpot and the C++ Standard use different naming conventions. The coexistence of those different -conventions might appear jarring and reduce readability.
There are a few exceptions to this rule.
+conventions might appear jarring and reduce readability. However, +experience in some other code bases suggests this isn't a significant +problem, so long as Standard Library names are namespace-qualified. It +is tempting to bring the Standard Library names into scope via a +using std; directive. Doing so makes writing code using
+those names easier, since the qualifiers don't need to be included. But
+there are several reasons not to do that.
#include <new> to use placement new,
-std::nothrow, and std::nothrow_t.#include <limits> to use
-std::numeric_limits.#include <type_traits> with some restrictions,
-listed below.#include <cstddef> to use
-std::nullptr_t and std::max_align_t.There is a risk of future name collisions. Additional Standard +Library headers may be included, adding to the list of names being used. +Also, future versions of the Standard Library may add currently unknown +names to the headers already being included.
It may harm readability. Code where this is relevant is a mixture +of the local HotSpot naming conventions and the Standard Library's (or +other 3rd-party library's) naming conventions. With only unqualified +names, any distinctions from the naming conventions for the different +code sources are lost. Instead one may end up with an undifferentiated +mess, where it's not obvious whether an identifier is from local code +that is inconsistent with HotSpot style (and there's a regretable amount +of that for historical reasons), or is following some other convention. +Having the qualifiers disambiguates that.
It can be helpful to know, at a glance, whether the definition is +in HotSpot or elsewhere, for purposes of looking up the definition or +documentation.
Certain restrictions apply to the declarations provided by
-<type_traits>.
alignof operator should be used rather than
-std::alignment_of<>.TODO: Rather than directly #including (permitted) Standard Library -headers, use a convention of #including wrapper headers (in some -location like hotspot/shared/stdcpp). This provides a single place for -dealing with issues we might have for any given header, esp. -platform-specific issues.
Use type deduction only if it makes the code clearer or safer. Do not use it merely to avoid the inconvenience of writing an explicit type, @@ -990,8 +1037,8 @@ running destructors at exit can lead to problems.
Some of the approaches used in HotSpot to avoid dynamic initialization include:
Use the Deferred<T> class template. Add a call
-to its initialization function at an appropriate place during VM
+
Use the DeferredStatic<T> class template. Add
+a call to its initialization function at an appropriate place during VM
initialization. The underlying object is never destroyed.
For objects of class type, use a variable whose value is a
pointer to the class, initialized to nullptr. Provide an
@@ -1577,10 +1624,10 @@ href="http://wg21.link/p0138r2">p0138r2)
Allow typename in template template parameter (n4051) — template template parameters
are barely used (if at all) in HotSpot, but there's no reason to
-artificially disallow this syntactic regularization in any such
+artificially forbid this syntactic regularization in any such
uses.
The use of structured bindings p0217r3 is forbidden. Preferred @@ -1622,8 +1669,33 @@ initialization for classes with base classes (p0017r1). HotSpot makes very little use of aggregate classes, preferring explicit constructors even for very simple classes.
-<algorithm>, <iterator>,
+<numeric>
Not useful without standard containers
+or similar classes in HotSpot.
<bitset> - Overlap with HotSpot
+BitMap.
<cassert>, assert.h - HotSpot has
+its own assert macro.
<exception>, <stdexcept> -
+Use of exceptions is not
+permitted.
Thread support - <thread>,
+<mutex>, <shared_mutex>,
+<condition_varible>, <future>
+HotSpot has its own threading support.
Streams - HotSpot doesn't use the C++ I/O library.
<scoped_allocator> - Not useful without
+specialized allocators.
<string> - Requires allocator support, similar
+to standard containers.
<typeinfo>, <typeindex>
+Use of runtime type information
+is not permitted.
<valarray> - May allocate, but is not
+allocator-aware.
New string and character literals
<tuple>
+— Prefer named access to class objects, rather than indexed access to
+anonymous heterogeneous sequences. In particular, a standard-layout
+class is preferred to a tuple.
std::invoke<>() (n4169)
<chrono>
+— The argument for chrono is that our existing APIs aren't serving us
+well. chrono provides strong type safety. We've had multiple cases of
+mistakes like a double seconds being treated as double milliseconds or
+vice versa, and other similar errors. But it would be a large effort to
+adopt chrono. We'd also need to decide whether to use the predefined
+clocks or hook up chrono to our clocks. It may be that using the
+predefined clocks is fine, but it's a question that needs careful
+study.
<initializer_list>
+— The potential ambiguity between some forms of direct initialization
+and initializer list initialization, and the resolution of that
+ambiguity, is unfortunate.
<ratio>
+— <ratio> is a compile-time rational
+arithmetic package. It's also fixed (though parameterized) precision.
+It's not a general purpose rational arithmetic facility. It appears to
+have started out as an implementation detail of chrono, and was
+extracted and promoted to a public facility in the belief that it has
+broader utility.
<system_error>
+— We don't really have a generally agreed upon mechanism for managing
+errors. Instead, we have a plethora of bespoke ad hoc mechanisms.
+Managing errors is a topic of substantial discussion.
+<system_error> might end up being a part of a result
+from that discussion.