Introduce '-Xskip-runtime-version-check' command line option

This commit is contained in:
Alexander Udalov
2016-12-13 11:21:29 +03:00
parent 6aaf2c7c4d
commit d0fa9bac75
6 changed files with 21 additions and 6 deletions
@@ -98,6 +98,9 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "Xskip-metadata-version-check", description = "Load classes with bad metadata version anyway (incl. pre-release classes)")
public boolean skipMetadataVersionCheck;
@Argument(value = "Xskip-runtime-version-check", description = "Allow Kotlin runtime libraries of incompatible versions in the classpath")
public boolean skipRuntimeVersionCheck;
@Argument(value = "Xdump-declarations-to", description = "Path to JSON file to dump Java to Kotlin declaration mappings")
@ValueDescription("<path>")
public String declarationsOutputPath;
@@ -113,7 +113,10 @@ object JvmRuntimeVersionsConsistencyChecker {
if (runtimeJarsInfo.hasAnyJarsToCheck) {
val languageVersion = languageVersionSettings?.let { MavenComparableVersion(it.languageVersion) } ?: CURRENT_COMPILER_VERSION
checkCompilerClasspathConsistency(messageCollector, languageVersion, runtimeJarsInfo)
if (checkCompilerClasspathConsistency(messageCollector, languageVersion, runtimeJarsInfo)) {
messageCollector.issue(null, "Some runtime JAR files in the classpath have an incompatible version. " +
"Remove them from the classpath or use '-Xskip-runtime-version-check' to suppress errors")
}
}
}
@@ -329,6 +329,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions)
configuration.put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize)
configuration.put(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, arguments.inheritMultifileParts)
configuration.put(JVMConfigurationKeys.SKIP_RUNTIME_VERSION_CHECK, arguments.skipRuntimeVersionCheck)
configuration.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
configuration.put(CLIConfigurationKeys.REPORT_PERF, arguments.reportPerf)
configuration.put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule)
@@ -155,11 +155,15 @@ class KotlinCoreEnvironment private constructor(
val initialRoots = configuration.getList(JVMConfigurationKeys.CONTENT_ROOTS).classpathRoots()
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
if (messageCollector != null) {
val languageVersionSettings = configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS)
val classpathJarRoots = initialRoots.mapNotNull { (file, type) -> if (type == JavaRoot.RootType.BINARY) file else null }
JvmRuntimeVersionsConsistencyChecker.checkCompilerClasspathConsistency(messageCollector, languageVersionSettings, classpathJarRoots)
if (!configuration.getBoolean(JVMConfigurationKeys.SKIP_RUNTIME_VERSION_CHECK)) {
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
if (messageCollector != null) {
JvmRuntimeVersionsConsistencyChecker.checkCompilerClasspathConsistency(
messageCollector,
configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS),
initialRoots.mapNotNull { (file, type) -> if (type == JavaRoot.RootType.BINARY) file else null }
)
}
}
// REPL and kapt2 update classpath dynamically
@@ -76,6 +76,9 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> CREATE_BUILT_INS_FROM_MODULE_DEPENDENCIES =
CompilerConfigurationKey.create("create built-ins from resources found in the module dependencies");
public static final CompilerConfigurationKey<Boolean> SKIP_RUNTIME_VERSION_CHECK =
CompilerConfigurationKey.create("do not perform checks on runtime versions consistency");
public static final CompilerConfigurationKey<JvmTarget> JVM_TARGET =
CompilerConfigurationKey.create("JVM bytecode target version");
+1
View File
@@ -7,6 +7,7 @@ where advanced options include:
-Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade
-Xallow-kotlin-package Allow compiling code in package 'kotlin'
-Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes)
-Xskip-runtime-version-check Allow Kotlin runtime libraries of incompatible versions in the classpath
-Xdump-declarations-to <path> Path to JSON file to dump Java to Kotlin declaration mappings
-Xsingle-module Combine modules for source files and binary dependencies into a single module
-Xadd-compiler-builtins Add definitions of built-in declarations to the compilation classpath (useful with -no-stdlib)