Skip to content

Commit

Permalink
[GR-44722] Make vendor version adjustable at build-time.
Browse files Browse the repository at this point in the history
PullRequest: graal/14269
  • Loading branch information
fniephaus committed Apr 4, 2023
2 parents c994e04 + 666f3de commit f7d9d2f
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 38 deletions.
6 changes: 3 additions & 3 deletions docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Below is the example output when building a native executable of the `HelloWorld
GraalVM Native Image: Generating 'helloworld' (executable)...
================================================================================
[1/8] Initializing... (3.3s @ 0.15GB)
Java version: 17.0.7+4, vendor: GraalVM Community
Java version: 17.0.7+4, vendor version: GraalVM CE 17.0.7+4.1
Graal compiler: optimization level: '2', target machine: 'x86-64-v3'
C compiler: gcc (linux, x86_64, 12.2.0)
Garbage collector: Serial GC (max heap size: 80% of RAM)
Expand Down Expand Up @@ -80,8 +80,8 @@ In this stage, the Native Image build process is set up and [`Features`](https:/
By default, Native Image generates *executables* but it can also generate [*native shared libraries*](InteropWithNativeCode.md) and [*static executables*](guides/build-static-and-mostly-static-executable.md).
#### <a name="glossary-java-info"></a>Java Version Info
The Java version and vendor of the Native Image process.
Both are also used for the `java.vm.version` and `java.vm.vendor` properties within the generated native binary.
The Java and vendor version of the Native Image process.
Both are also used for the `java.vm.version` and `java.vendor.version` properties within the generated native binary.
Please report version and vendor when you [file issues](https://github.com/oracle/graal/issues/new).
#### <a name="glossary-graal-compiler"></a>Graal Compiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"name",
"graalvm_version",
"java_version",
"vendor",
"vendor_version",
"graal_compiler",
"c_compiler",
"garbage_collector"
Expand All @@ -33,17 +33,17 @@
"graalvm_version": {
"type": "string",
"default": "",
"title": "The GraalVM Native Image version. Deprecated: Please use java_version and vendor instead."
"title": "The GraalVM Native Image version. Deprecated: Please use vendor_version or java_version instead."
},
"java_version": {
"type": "string",
"default": null,
"title": "The Java version of the Native Image build process. This value is also used for the 'java.vm.version' property within the generated image"
},
"vendor": {
"vendor_version": {
"type": "string",
"default": null,
"title": "The vendor of the VM of the generated image. This value is also used for the 'java.vm.vendor' property within the generated image"
"title": "The vendor version of the VM of the generated image. This value is also used for the 'java.vendor.version' property within the generated image"
},
"graal_compiler": {
"type": "object",
Expand Down Expand Up @@ -82,14 +82,14 @@
"examples": [
{
"name": "helloworld",
"graalvm_version": "GraalVM CE 17.0.7+4",
"graalvm_version": "GraalVM CE 17.0.7+4.1",
"graal_compiler": {
"pgo": false,
"march": "x86-64-v3",
"optimization_level": "0"
},
"java_version": "17.0.7+4",
"vendor": "GraalVM Community",
"vendor_version": "GraalVM CE 17.0.7+4.1",
"c_compiler": "gcc (linux, x86_64, 9.3.0)",
"garbage_collector": "Serial GC"
}
Expand Down Expand Up @@ -513,13 +513,13 @@
{
"general_info": {
"name": "helloworld",
"graalvm_version": "GraalVM CE 17.0.7+4",
"graalvm_version": "GraalVM CE 17.0.7+4.1",
"graal_compiler": {
"march": "x86-64-v3",
"optimization_level": "0"
},
"java_version": "17.0.7+4",
"vendor": "GraalVM Community",
"vendor_version": "GraalVM CE 17.0.7+4.1",
"c_compiler": "gcc (linux, x86_64, 9.3.0)",
"garbage_collector": "Serial GC"
},
Expand Down Expand Up @@ -582,13 +582,13 @@
{
"general_info": {
"name": "helloworld",
"graalvm_version": "GraalVM CE 17.0.7+4",
"graalvm_version": "GraalVM CE 17.0.7+4.1",
"graal_compiler": {
"march": "x86-64-v3",
"optimization_level": "0"
},
"java_version": "17.0.7+4",
"vendor": "GraalVM Community",
"vendor_version": "GraalVM CE 17.0.7+4.1",
"c_compiler": null,
"garbage_collector": "Serial GC"
},
Expand Down
2 changes: 1 addition & 1 deletion substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-44110) Native Image now targets `x86-64-v3` by default on AMD64 and supports a new `-march` option. Use `-march=compatibility` for best compatibility (previous default) or `-march=native` for best performance if the native executable is deployed on the same machine or on a machine with the same CPU features. To list all available machine types, use `-march=list`.
* (GR-43971) Add native-image option `-E<env-var-key>[=<env-var-value>]` and support environment variable capturing in bundles. Previously almost all environment variables were available in the builder. To temporarily revert back to the old behaviour, env setting `NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION=true` can be used. The old behaviour will be removed in a future release.
* (GR-43382) The build output now includes a section with recommendations that help you get the best out of Native Image.
* (GR-44722) The output of `native-image --version` and various Java properties (e.g. `java.vm.version`) have been aligned with the OpenJDK. To distinguish between GraalVM CE, Oracle GraalVM, and GraalVM distributions from other vendors, please refer to `java.vm.vendor`.
* (GR-44722) The output of `native-image --version` and various Java properties (e.g. `java.vm.version`) have been aligned with the OpenJDK. To distinguish between GraalVM CE, Oracle GraalVM, and GraalVM distributions from other vendors, please refer to `java.vm.vendor` or `java.vendor.version`.

## Version 22.3.0
* (GR-35721) Remove old build output style and the `-H:±BuildOutputUseNewStyle` option.
Expand Down
27 changes: 16 additions & 11 deletions substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
*/
package com.oracle.svm.core;

import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.ImageInfo;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.nativeimage.impl.ImageSingletonsSupport;

public final class VM {

Expand All @@ -36,28 +35,34 @@ public final class VM {
public final String vendor;
public final String vendorUrl;
public final String vendorVersion;
public final String supportURL;

@Platforms(Platform.HOSTED_ONLY.class)
public VM(String vmInfo) {
info = vmInfo;
supportURL = System.getProperty("org.graalvm.supporturl", "https://graalvm.org/native-image/error-report/");
version = stripJVMCISuffix(System.getProperty("java.runtime.version"));
version = getVersion();
vendor = System.getProperty("org.graalvm.vendor", "GraalVM Community");
vendorUrl = System.getProperty("org.graalvm.vendorurl", "https://www.graalvm.org/");
vendorVersion = System.getProperty("org.graalvm.vendorversion", "GraalVM CE");
vendorVersion = getVendorVersion();
}

@Platforms(Platform.HOSTED_ONLY.class)
public static VM getErrorReportingInstance() {
if (ImageSingletonsSupport.isInstalled() && ImageSingletons.contains(VM.class)) {
return ImageSingletons.lookup(VM.class);
public static String getSupportUrl() {
return System.getProperty("org.graalvm.supporturl", "https://graalvm.org/native-image/error-report/");
}

public static String getVendorVersion() {
if (ImageInfo.inImageRuntimeCode()) {
return System.getProperty("java.vendor.version");
} else {
// create a fall back instance
return new VM(System.getProperty("java.vm.info", ""));
return System.getProperty("org.graalvm.vendorversion", "GraalVM CE");
}
}

@Platforms(Platform.HOSTED_ONLY.class)
public static String getVersion() {
return stripJVMCISuffix(System.getProperty("java.runtime.version"));
}

@Platforms(Platform.HOSTED_ONLY.class)
private static String stripJVMCISuffix(String javaRuntimeVersion) {
int jvmciIndex = javaRuntimeVersion.indexOf("-jvmci");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.graalvm.compiler.options.OptionType;

import com.oracle.svm.core.VM;
import com.oracle.svm.core.option.OptionOrigin;
import com.oracle.svm.core.option.OptionUtils;
import com.oracle.svm.core.util.ExitStatus;
Expand Down Expand Up @@ -208,14 +209,15 @@ private void printVersion() {
}

String javaRuntimeName = System.getProperty("java.runtime.name");
String vendorVersion = System.getProperty("java.vendor.version");
nativeImage.showMessage("%s %s (%sbuild %s)", javaRuntimeName, vendorVersion, jdkDebugLevel, javaRuntimeVersion);
String vendorVersion = VM.getVendorVersion();
vendorVersion = vendorVersion.isEmpty() ? "" : " " + vendorVersion;
nativeImage.showMessage("%s%s (%sbuild %s)", javaRuntimeName, vendorVersion, jdkDebugLevel, javaRuntimeVersion);

/* Third line: VM information. */
String javaVMName = System.getProperty("java.vm.name");
String javaVMVersion = System.getProperty("java.vm.version");
String javaVMInfo = System.getProperty("java.vm.info");
nativeImage.showMessage("%s %s (%sbuild %s, %s)", javaVMName, vendorVersion, jdkDebugLevel, javaVMVersion, javaVMInfo);
nativeImage.showMessage("%s%s (%sbuild %s, %s)", javaVMName, vendorVersion, jdkDebugLevel, javaVMVersion, javaVMInfo);
}

private static void singleArgumentCheck(ArgumentQueue args, String arg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ public void printInitializeEnd() {
stagePrinter.end(getTimer(TimerCollection.Registry.CLASSLIST).getTotalTime() + getTimer(TimerCollection.Registry.SETUP).getTotalTime());
VM vm = ImageSingletons.lookup(VM.class);
recordJsonMetric(GeneralInfo.JAVA_VERSION, vm.version);
recordJsonMetric(GeneralInfo.VENDOR, vm.vendor);
recordJsonMetric(GeneralInfo.GRAALVM_VERSION, vm.vendorVersion + " " + vm.version); // deprecated
l().a(" ").doclink("Java version", "#glossary-java-info").a(": ").a(vm.version).a(", ").doclink("vendor", "#glossary-java-info").a(": ").a(vm.vendor).println();
recordJsonMetric(GeneralInfo.VENDOR_VERSION, vm.vendorVersion);
recordJsonMetric(GeneralInfo.GRAALVM_VERSION, vm.vendorVersion); // deprecated
l().a(" ").doclink("Java version", "#glossary-java-info").a(": ").a(vm.version).a(", ").doclink("vendor version", "#glossary-java-info").a(": ").a(vm.vendorVersion).println();
String optimizationLevel = SubstrateOptions.Optimize.getValue();
recordJsonMetric(GeneralInfo.GRAAL_COMPILER_OPTIMIZATION_LEVEL, optimizationLevel);
String march = CPUType.getSelectedOrDefaultMArch();
Expand Down Expand Up @@ -688,8 +688,8 @@ private void printErrorMessage(Optional<Throwable> optionalError, OptionValues p
l().link(NativeImageOptions.getErrorFilePath(parsedHostedOptions)).println();
l().println();
l().a("If you are unable to resolve this problem, please file an issue with the error report at:").println();
var supportURL = VM.getErrorReportingInstance().supportURL;
l().link(supportURL, supportURL).println();
var supportUrl = VM.getSupportUrl();
l().link(supportUrl, supportUrl).println();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void record(ProgressReporterJsonHelper helper, Object value) {
public enum GeneralInfo implements JsonMetric {
IMAGE_NAME("name", null),
JAVA_VERSION("java_version", null),
VENDOR("vendor", null),
VENDOR_VERSION("vendor_version", null),
GRAALVM_VERSION("graalvm_version", null),
GRAAL_COMPILER_OPTIMIZATION_LEVEL("optimization_level", "graal_compiler"),
GRAAL_COMPILER_MARCH("march", "graal_compiler"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ private static void configureReflection(BeforeAnalysisAccess access) {
RuntimeReflection.register(access.findClassByName("com.sun.jndi.url.rmi.rmiURLContextFactory"));
RuntimeReflection.register(access.findClassByName("sun.rmi.server.UnicastRef"));

RuntimeReflection.register(access.findClassByName("sun.rmi.server.UnicastRef").getMethods());

RuntimeReflection.register(access.findClassByName("com.sun.jndi.url.rmi.rmiURLContextFactory").getConstructors());
RuntimeReflection.register(access.findClassByName("sun.rmi.server.UnicastRef").getConstructors());
RuntimeReflection.register(access.findClassByName("sun.rmi.server.UnicastRef2").getConstructors());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private static void reportGraalVMSetup(PrintWriter pw) {
pw.println();
pw.println("| Name | Value |");
pw.println("| ---- | ----- |");
VM vm = VM.getErrorReportingInstance();
pw.printf("| Java version and vendor | `%s` (%s) |%n", vm.version, vm.vendor);
pw.printf("| Java version | `%s` |%n", VM.getVersion());
pw.printf("| Vendor version | `%s` |%n", VM.getVendorVersion());
pw.printf("| Runtime version | `%s` |%n", System.getProperty("java.runtime.version"));
if (ImageSingletonsSupport.isInstalled() && ImageSingletons.contains(CCompilerInvoker.class)) {
pw.printf("| C compiler | `%s` |%n", ImageSingletons.lookup(CCompilerInvoker.class).compilerInfo.getShortDescription());
Expand Down

0 comments on commit f7d9d2f

Please sign in to comment.