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

Create ubuntu_version_mapping.properties #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abarsov
Copy link

@abarsov abarsov commented Nov 19, 2018

Separate mapping from ubuntu builds to alpn-boot jars
See jetty/jetty.project#3100 and #22

@sbordet
Copy link
Member

sbordet commented Nov 19, 2018

@abarsov the format of the file should be:

<System.getProperty("java.version")>=<alpn-boot-version>

I doubt that calling System.getProperty("java.version") in the ubuntu JDK you get back "8u181-b13-0ubuntu0.16.04.1".

Where do you get that string "8u181-b13-0ubuntu0.16.04.1" from?

The goal of the file is that a Java program could download it, read its lines, and match the key of a line with some system property (or some other API call) that returns the Ubuntu specific version.

@abarsov
Copy link
Author

abarsov commented Nov 19, 2018

We can't use java.version

System.getProperty("java.version") is equal to 1.8.0_181 for ubuntu openjdk as well.

8u181-b13-1ubuntu0.16.04.1 is a version of package https://launchpad.net/ubuntu/xenial/amd64/openjdk-8-jdk-headless/8u181-b13-1ubuntu0.16.04.1

Though jvm option java.runtime.version can be used for distinguishing ubuntu openjdk builds

For instance, for package 8u181-b13-1ubuntu0.16.04.1,
System.getProperty("java.runtime.version") = 1.8.0_181-8u181-b13-1ubuntu0.16.04.1-b13
(this way package version from mapping is included into java.runtime.version as a substring).

Btw, there are several packages for other ubuntu versions released at the same date:
(see https://launchpad.net/ubuntu/+source/openjdk-8), but i have not tested them for compatibility with alpn-boot.

@sbordet
Copy link
Member

sbordet commented Nov 21, 2018

@abarsov I'm happy to have the Ubuntu file map java.runtime.version to ALPN boot versions for Ubuntu, but you need to be sure that A) the java.runtime.version is unique and B) that it is compatible with a ALPN boot version.

@abarsov
Copy link
Author

abarsov commented Nov 26, 2018

@sbordet

A)
java.runtime.version is unique within vendor jre updates and looks to be unique globally due to included token ubuntu and concise version of the package.

B) I have tested that

  • 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13 is compatible with alpn-boot-8.1.12.v20180117
  • 1.8.0_181-8u181-b13-1ubuntu0.16.04.1-b13 is compatible with alpn-boot-8.1.13.v20181017

Although there is no guarantee that further updates of package Ubuntu openjdk 8u181 (if any) will be be still compatible with alpn-boot-8.1.13.v20181017

To the moment I have come up with the following code resolving alpn-boot version for java:

notes:

  • Variable versionsMap contains mapping from version_mapping.properties (key is java.version, and value is alpn-boot version)
    final String javaVersion = System.getProperty("java.version");
    final String alpnBootVersion ;
    if ("1.8.0_181".equals(javaVersion)) {
      final String javaRuntimeVersion = System.getProperty("java.runtime.version");
      if (javaRuntimeVersion != null && javaRuntimeVersion.contains("ubuntu")) {
        if (javaRuntimeVersion.equals("1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13")) {
          alpnBootVersion = versionMap.get(javaVersion);
        } else if (javaRuntimeVersion.equals("1.8.0_181-8u181-b13-1ubuntu0.16.04.1-b13")) {
          alpnBootVersion = versionMap.get("1.8.0_191");
        } else {
          // Assuming that all further updates of Ubuntu openjdk package 8u181 still will be compatible with alpn-boot compiled against Oracle java 1.8.0_191.
          // That is no guarantee that this would happen, but there are good chances for.
          alpnBootVersion = versionMap.get("1.8.0_191");
        }
      } else if (javaRuntimeVersion != null && javaRuntimeVersion.contains("~deb")) {
        if (javaRuntimeVersion.equals("1.8.0_181-8u181-b13-1~deb9u1-b13")) {
          alpnBootVersion = versionMap.get(javaVersion);
        } else {
          // Maintainers of openjdk packages for Debian have back-ported changes made in Oracle 8u191 to their 8u181 releases, and published updated versions of 8u181 package as "1.8.0_181-8u181-b13-2~deb9u1-b13"
          // That package is incompatible with all versions of alpn-boot jar
          System.out.println(String.format("WARN: Incompatible openjdk package %s is detected. Skip adding alpn-boot jar to java bootstrap classpath...", javaRuntimeVersion));
          alpnBootVersion = null;
        }
      } else {
        alpnBootVersion = versionMap.get(javaVersion);
      }
    } else if (versionMap.containsKey(javaVersion)) {
      alpnBootVersion = versionMap.get(javaVersion);
    } else if (javaVersion.startsWith("1.8.")) {
      alpnBootVersion = getAlpnBootForLatestJre8();
    } else {
      alpnBootVersion = null;
    }

@abarsov
Copy link
Author

abarsov commented Nov 26, 2018

@sbordet
I am sorry,
but I have finally found broken compatibility in openjdk update 1.8.0_181-8u181-b13-1ubuntu0.16.04.1-b13.
So proposed mapping is incorrect, the only valid record is
8u181-b13-0ubuntu0.16.04.1=8.1.12.v20180117

Entry 8u181-b13-1ubuntu0.16.04.1=8.1.13.v20181017 is invalid.

This way the code that resolve appropriate alpn-boot mapping can be simplified to

    final String javaVersion = System.getProperty("java.version");
    final String alpnBootVersion ;
    if ("1.8.0_181".equals(javaVersion)) {
      final String javaRuntimeVersion = System.getProperty("java.runtime.version");
      if (javaRuntimeVersion != null && javaRuntimeVersion.contains("ubuntu")) {
        if (javaRuntimeVersion.equals("1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13")) {
          alpnBootVersion = versionMap.get(javaVersion);
        } else {
        // Maintainers of openjdk packages for Ubuntu have back-ported changes made in Oracle 8u191 to their 8u181 releases  and published updated versions of 8u181 package as "1.8.0_181-8u181-b13-1ubuntu0.16.04.1-b13")
        // That package is incompatible with all versions of alpn-boot jar
        System.out.println(String.format("WARN: Incompatible openjdk package %s is detected. Skip adding alpn-boot jar to java bootstrap classpath...", javaRuntimeVersion));
        alpnBootVersion = null;
       }
      } else if (javaRuntimeVersion != null && javaRuntimeVersion.contains("~deb")) {
        if (javaRuntimeVersion.equals("1.8.0_181-8u181-b13-1~deb9u1-b13")) {
          alpnBootVersion = versionMap.get(javaVersion);
        } else {
          // Maintainers of openjdk packages for Debian have back-ported changes made in Oracle 8u191 to their 8u181 releases, and published updated versions of 8u181 package as "1.8.0_181-8u181-b13-2~deb9u1-b13"
          // That package is incompatible with all versions of alpn-boot jar
          System.out.println(String.format("WARN: Incompatible openjdk package %s is detected. Skip adding alpn-boot jar to java bootstrap classpath...", javaRuntimeVersion));
          alpnBootVersion = null;
        }
      } else {
        alpnBootVersion = versionMap.get(javaVersion);
      }
    } else if (versionMap.containsKey(javaVersion)) {
      alpnBootVersion = versionMap.get(javaVersion);
    } else if (javaVersion.startsWith("1.8.")) {
      alpnBootVersion = getAlpnBootForLatestJre8();
    } else {
      alpnBootVersion = null;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants