public static void useStackJdkIfExists(Map<String, String> hostLevelParams, Configuration configuration) {
    // set defaults first
    hostLevelParams.put(JAVA_HOME, configuration.getJavaHome());
    hostLevelParams.put(JDK_NAME, configuration.getJDKName());
    hostLevelParams.put(JCE_NAME, configuration.getJCEName());
    hostLevelParams.put(JAVA_VERSION, String.valueOf(configuration.getJavaVersion()));
    if (StringUtils.isNotEmpty(configuration.getStackJavaHome())
      && !configuration.getStackJavaHome().equals(configuration.getJavaHome())) {
      hostLevelParams.put(JAVA_HOME, configuration.getStackJavaHome());
      if (StringUtils.isNotEmpty(configuration.getStackJavaVersion())) {
        hostLevelParams.put(JAVA_VERSION, configuration.getStackJavaVersion());
      }
      if (StringUtils.isNotEmpty(configuration.getStackJDKName())) {
        hostLevelParams.put(JDK_NAME, configuration.getStackJDKName());
      } else {
        hostLevelParams.put(JDK_NAME, null); // custom jdk for stack
      }
      if (StringUtils.isNotEmpty(configuration.getStackJCEName())) {
        hostLevelParams.put(JCE_NAME, configuration.getStackJCEName());
      } else {
        hostLevelParams.put(JCE_NAME, null); // custom jdk for stack
      }
    }
  }
Fill hots level parameters with Jdk details, override them with the stack JDK data, in case of stack JAVA_HOME exists
ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java