Today os.hpp includes os_linux.hpp
https://github.com/openjdk/jdk/blob/399071369173921a9fee0cae88a5f7e44e26d33d/src/hotspot/share/runtime/os.hpp#L874
https://github.com/openjdk/jdk/blob/399071369173921a9fee0cae88a5f7e44e26d33d/src/hotspot/os/linux/os_linux.hpp#L33
This means that the definition of the os::Linux class (over 400 lines) is always included via os.hpp, but os::Linux is used only by Linux-specific files.
To improve modularity and JDK build time, we should move the definition of os::Linux to its own header file that's not automatically included by os.hpp.
C++ allows the definition of a nested class (os::Linux) to be outside of the definition of the enclosing class (os).
https://en.cppreference.com/w/cpp/language/nested_types
class enclose {
class nested1; // forward declaration
class nested2; // forward declaration
class nested1 {}; // definition of nested class
};
class enclose::nested2 { }; // definition of nested class
https://github.com/openjdk/jdk/blob/399071369173921a9fee0cae88a5f7e44e26d33d/src/hotspot/share/runtime/os.hpp#L874
https://github.com/openjdk/jdk/blob/399071369173921a9fee0cae88a5f7e44e26d33d/src/hotspot/os/linux/os_linux.hpp#L33
This means that the definition of the os::Linux class (over 400 lines) is always included via os.hpp, but os::Linux is used only by Linux-specific files.
To improve modularity and JDK build time, we should move the definition of os::Linux to its own header file that's not automatically included by os.hpp.
C++ allows the definition of a nested class (os::Linux) to be outside of the definition of the enclosing class (os).
https://en.cppreference.com/w/cpp/language/nested_types
class enclose {
class nested1; // forward declaration
class nested2; // forward declaration
class nested1 {}; // definition of nested class
};
class enclose::nested2 { }; // definition of nested class
- duplicates
-
JDK-8290840 Refactor the "os" class
-
- Resolved
-
- links to
-
Review openjdk/jdk/9423