private static void addCrossCompilationOptions(int compilerSdkVersion, List<? super String> options, CompileContext context, ModuleChunk chunk) {
    final JpsJavaCompilerConfiguration compilerConfiguration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(
      context.getProjectDescriptor().getProject()
    );

    @NotNull JpsModule module = chunk.representativeTarget().getModule();
    final LanguageLevel level = JpsJavaExtensionService.getInstance().getLanguageLevel(module);
    final int languageLevel = level != null ? level.feature() : 0;
    final int chunkSdkVersion = getChunkSdkVersion(chunk);

    int bytecodeTarget = getModuleBytecodeTarget(context, chunk, compilerConfiguration,
                                                 (level == LanguageLevel.JDK_X) ? chunkSdkVersion : languageLevel);

    if (shouldUseReleaseOption(compilerConfiguration, compilerSdkVersion, chunkSdkVersion, bytecodeTarget)) {
      options.add(RELEASE_OPTION);
      options.add(level == LanguageLevel.JDK_X ? complianceOption(chunkSdkVersion) : complianceOption(bytecodeTarget));
      return;
    }

    // using older -source, -target and -bootclasspath options
    if (languageLevel > 0 && !options.contains(SOURCE_OPTION)) {
      options.add(SOURCE_OPTION);
      options.add(level == LanguageLevel.JDK_X ? complianceOption(chunkSdkVersion) : complianceOption(languageLevel));
    }

    if (bytecodeTarget > 0) {
      if (chunkSdkVersion > 0 && compilerSdkVersion > chunkSdkVersion) {
        // if compiler is newer than module JDK
        if (compilerSdkVersion >= bytecodeTarget) {
          // if user-specified bytecode version can be determined and is supported by compiler
          if (bytecodeTarget > chunkSdkVersion) {
            // and user-specified bytecode target level is higher than the highest one supported by the target JDK,
            // force compiler to use highest-available bytecode target version that is supported by the chunk JDK.
            bytecodeTarget = chunkSdkVersion;
          }
        }
        // otherwise let compiler display compilation error about incorrectly set bytecode target version
      }
    }
    else {
      if (chunkSdkVersion > 0 && compilerSdkVersion > chunkSdkVersion) {
        // force lower bytecode target level to match the version of the chunk JDK
        bytecodeTarget = chunkSdkVersion;
      }
    }

    if (bytecodeTarget > 0) {
      options.add(TARGET_OPTION);
      options.add(complianceOption(bytecodeTarget));
    }
  }
private static void addCrossCompilationOptions(int compilerSdkVersion, List<? super String> options, CompileContext context, ModuleChunk chunk)