Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-41675] Only require libmanagement_ext if it's actually needed. #5195

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ static StructuredGraph decodeSnippetGraph(SymbolicEncodedGraph encodedGraph, Res
private static void postDecode(DebugContext debug, StructuredGraph result, ResolvedJavaMethod original) {
debug.dump(DebugContext.VERBOSE_LEVEL, result, "Before PartialIntrinsicCallTargetNode replacement");
for (PartialIntrinsicCallTargetNode partial : result.getNodes(PartialIntrinsicCallTargetNode.TYPE)) {
// Ensure the orignal method matches
// Ensure the original method matches
assert partial.checkName(original);
ValueNode[] arguments = partial.arguments().toArray(new ValueNode[partial.arguments().size()]);
MethodCallTargetNode target = result.add(new MethodCallTargetNode(partial.invokeKind(), original,
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started/graalvm-community/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ The GraalVM Community distribution for Windows platforms includes OpenJDK with t
Currently, the GraalVM environment on Windows can be extended with [Native Image](../../reference-manual/native-image/README.md), [Java on Truffle](../../reference-manual/java-on-truffle/README.md), [LLVM runtime](../../reference-manual/llvm/README.md), WebAssembly, JavaScript and Node.js support.

## Prerequisites for Using Native Image on Windows
On Windows, Native Image requires Visual Studio Code and Microsoft Visual C++(MSVC).
On Windows, Native Image requires Visual Studio and Microsoft Visual C++(MSVC).
You can use Visual Studio 2017 version 15.9 or later.
There are two installation options:
- Install the Visual Studio Code Build Tools with the Windows 10 SDK
- Install Visual Studio Code with the Windows 10 SDK
- Install the Visual Studio Build Tools with the Windows 10 SDK
- Install Visual Studio with the Windows 10 SDK

The last prerequisite is the proper [Developer Command Prompt](https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019#developer_command_prompt_shortcuts) for your version of [Visual Studio](https://visualstudio.microsoft.com/vs/).
On Windows, the `native-image` tool only works when it is executed from the **x64 Native Tools Command Prompt**.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ The GraalVM Enterprise distribution for Windows platforms includes Oracle JDK wi
Currently, the GraalVM environment on Windows can be extended with [Native Image](../../reference-manual/native-image/README.md), [Java on Truffle](../../reference-manual/java-on-truffle/README.md), [LLVM runtime](../../reference-manual/llvm/README.md), WebAssembly, JavaScript and Node.js support.

## Prerequisites for Using Native Image on Windows
On Windows, Native Image requires Visual Studio Code and Microsoft Visual C++(MSVC).
On Windows, Native Image requires Visual Studio and Microsoft Visual C++(MSVC).
You can use Visual Studio 2017 version 15.9 or later.
There are two installation options:
- Install the Visual Studio Code Build Tools with the Windows 10 SDK
- Install Visual Studio Code with the Windows 10 SDK
- Install the Visual Studio Build Tools with the Windows 10 SDK
- Install Visual Studio with the Windows 10 SDK

The last prerequisite is the proper [Developer Command Prompt](https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019#developer_command_prompt_shortcuts) for your version of [Visual Studio](https://visualstudio.microsoft.com/vs/).
On Windows the `native-image` tool only works when it is executed from the **x64 Native Tools Command Prompt**.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static Exception getVerificationResult(Provider p) {
/* End code block copied from original method. */
/*
* If the verification result is not found in the verificationResults map JDK proceeds to
* verify it. That requires accesing the code base which we don't support. The substitution
* verify it. That requires accessing the code base which we don't support. The substitution
* for getCodeBase() would be enough to take care of this too, but substituting
* getVerificationResult() allows for a better error message.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@

@AutomaticallyRegisteredFeature
public class JNIRegistrationManagementExt extends JNIRegistrationUtil implements InternalFeature {

private static final String OPERATING_SYSTEM_IMPL = "com.sun.management.internal.OperatingSystemImpl";
private NativeLibraries nativeLibraries;

@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
nativeLibraries = ((BeforeAnalysisAccessImpl) access).getNativeLibraries();

rerunClassInit(access, "com.sun.management.internal.OperatingSystemImpl");
rerunClassInit(access, OPERATING_SYSTEM_IMPL);

access.registerReachabilityHandler(this::linkManagementExt, clazz(access, "com.sun.management.internal.OperatingSystemImpl"));
access.registerReachabilityHandler(this::linkManagementExt, clazz(access, OPERATING_SYSTEM_IMPL));
PlatformNativeLibrarySupport.singleton().addBuiltinPkgNativePrefix("com_sun_management_internal_OperatingSystemImpl");
}

Expand All @@ -77,7 +79,8 @@ private void linkManagementExt(@SuppressWarnings("unused") DuringAnalysisAccess

@Override
public void afterAnalysis(AfterAnalysisAccess access) {
if (NativeLibrarySupport.singleton().isPreregisteredBuiltinLibrary("awt_headless")) {
boolean managementExtNeeded = access.isReachable(clazz(access, OPERATING_SYSTEM_IMPL));
if (managementExtNeeded && NativeLibrarySupport.singleton().isPreregisteredBuiltinLibrary("awt_headless")) {
/*
* Ensure that `management_ext` comes before `awt_headless` on the linker command line.
* This is necessary to prevent linker errors such as JDK-8264047.
Expand Down