Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8183981

Use Resources from jdk.packager.jmod

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 9, 10
    • deploy

      All resources such as the native launcher and default icons are used from the current instance of jdk.packager. However, if the jdk.packager.jmod provided via the module path is where the resources are retrieved from, then a number of problems are solved and cross platform bundles could be generated (minus platform specific things such as rewriting the metadata of EXE files on Windows, or signing bundles on the Mac).

      If the version of Visual Studio that the Java Packager is built with changes then it is impossible to package that version of the JDK with an older version of the JDK's java packager. The msvcr120.dll needs to be future proofed similar to how the redistributable module list is available; as a text file that is copied from the version of the JDK that is being bundled.

      Rework the following code in WindowsAppImageBuilder.java;

      private final static String[] VS_VERS = {"100", "110", "120"};

          private void copyMSVCDLLs() throws IOException {
              String vsVer = null;

              // first copy the ones needed for the launcher
              for (String thisVer : VS_VERS) {
                  if (copyMSVCDLLs(thisVer)) {
                      vsVer = thisVer;
                      break;
                  }
              }
              if (vsVer == null) {
                  throw new RuntimeException("Not found MSVC dlls");
              }

              AtomicReference<IOException> ioe = new AtomicReference<>();
              final String finalVsVer = vsVer;
              try (Stream<Path> files = Files.list(runtimeDir.resolve("bin"))) {
                  files.filter(p -> Pattern.matches("msvc(r|p)\\d\\d\\d.dll", p.toFile().getName().toLowerCase()))
                       .filter(p -> !p.toString().toLowerCase().endsWith(finalVsVer + ".dll"))
                       .forEach(p -> {
                          try {
                              Files.copy(p, root.resolve((p.toFile().getName())));
                          } catch (IOException e) {
                              ioe.set(e);
                          }
                      });
              }

              IOException e = ioe.get();
              if (e != null) {
                  throw e;
              }
          }

          private boolean copyMSVCDLLs(String VS_VER) throws IOException {
              final InputStream REDIST_MSVCR_URL = WinResources.class.getResourceAsStream(
                      REDIST_MSVCR.replaceAll("VS_VER", VS_VER));
              final InputStream REDIST_MSVCP_URL = WinResources.class.getResourceAsStream(
                      REDIST_MSVCP.replaceAll("VS_VER", VS_VER));

              if (REDIST_MSVCR_URL != null && REDIST_MSVCP_URL != null) {
                  Files.copy(
                          REDIST_MSVCR_URL,
                          root.resolve(REDIST_MSVCR.replaceAll("VS_VER", VS_VER)));
                  Files.copy(
                          REDIST_MSVCP_URL,
                          root.resolve(REDIST_MSVCP.replaceAll("VS_VER", VS_VER)));
                  return true;
              }

              return false; // not found
          }

            Unassigned Unassigned
            cbensen Chris Bensen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: