Skip to content

Commit 63044b1

Browse files
Mikhael BogdanovSpace
Mikhael Bogdanov
authored and
Space
committed
Update -Xjvm-default description
(cherry picked from commit 40158d1)
1 parent e8e3c72 commit 63044b1

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt

+19-14
Original file line numberDiff line numberDiff line change
@@ -325,27 +325,32 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
325325
value = "-Xjvm-default",
326326
valueDescription = "{all|all-compatibility|disable|enable|compatibility}",
327327
description = """Emit JVM default methods for interface declarations with bodies.
328-
-Xjvm-default=all-compatibility Generate both a default method in the interface, and a compatibility accessor
329-
in the DefaultImpls class.
330-
In case of inheritance from a Kotlin interface compiled in the old scheme
331-
(DefaultImpls, no default methods), the compatibility accessor in DefaultImpls
332-
will delegate to the DefaultImpls method of the superinterface. Otherwise the
333-
compatibility accessor will invoke the default method on the interface, with
334-
standard JVM runtime resolution semantics.
335-
Note that if interface delegation is used, all interface methods are delegated.
336-
The only exception are methods annotated with the deprecated @JvmDefault annotation.
337-
-Xjvm-default=all Generate default methods for all interface declarations with bodies.
338-
Do not generate DefaultImpls classes at all.
328+
-Xjvm-default=all Generate JVM default methods for all interface declarations with bodies in module.
329+
Do not generate DefaultImpls stubs for such declarations (that is default behaviour of compiler in 'disable' mode).
330+
If interface inherits such methods from interface compiled in 'disable' scheme
331+
then implicit DefaultImpls stubs would be generated as there are no default method for it.
339332
BREAKS BINARY COMPATIBILITY if some client code relies on the presence of
340333
DefaultImpls classes. Also prohibits the produced binaries to be read by Kotlin
341334
compilers earlier than 1.4.
342335
Note that if interface delegation is used, all interface methods are delegated.
343336
The only exception are methods annotated with the deprecated @JvmDefault annotation.
344-
-Xjvm-default=disable Do not generate JVM default methods and prohibit @JvmDefault annotation usage.
345-
-Xjvm-default=enable Allow usages of @JvmDefault; only generate the default method
337+
-Xjvm-default=all-compatibility In addition to `all` mode generate compatibility stubs in the DefaultImpls classes.
338+
Compatibility stubs could be useful for library and runtime authors
339+
to keep backward binary compatibility for existing client compiled against previous library versions.
340+
New 'all' and 'all-compatibility' modes are changing library ABI surface that will be used by client after their recompilation.
341+
In that sense client might be incompatible with previous library versions that REQUIRE PROPER LIBRARY VERSIONING.
342+
In case of inheritance from a Kotlin interface compiled in the old scheme
343+
(DefaultImpls, no default methods), the implicit stubs in DefaultImpls
344+
will delegate to the DefaultImpls method of the superinterface.
345+
Otherwise the compatibility stubs in DefaultImpls would invoke the default method on the interface via special accessor in it,
346+
with standard JVM runtime resolution semantics.
347+
Perform additional compatibility checks for classes in case of implicit specialized override
348+
presence in 'disable' scheme (See KT-39603 for more details)
349+
-Xjvm-default=disable Default behaviour. Do not generate JVM default methods and prohibit @JvmDefault annotation usage.
350+
-Xjvm-default=enable Deprecated. Allow usages of @JvmDefault; only generate the default method
346351
for annotated method in the interface
347352
(annotating an existing method can break binary compatibility)
348-
-Xjvm-default=compatibility Allow usages of @JvmDefault; generate a compatibility accessor
353+
-Xjvm-default=compatibility Deprecated. Allow usages of @JvmDefault; generate a compatibility accessor
349354
in the 'DefaultImpls' class in addition to the default interface method"""
350355
)
351356
var jvmDefault: String by FreezableVar(JvmDefaultMode.DEFAULT.description)

compiler/testData/cli/jvm/extraHelp.out

+19-14
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,32 @@ where advanced options include:
5353
* warn (report a warning)
5454
-Xjvm-default={all|all-compatibility|disable|enable|compatibility}
5555
Emit JVM default methods for interface declarations with bodies.
56-
-Xjvm-default=all-compatibility Generate both a default method in the interface, and a compatibility accessor
57-
in the DefaultImpls class.
58-
In case of inheritance from a Kotlin interface compiled in the old scheme
59-
(DefaultImpls, no default methods), the compatibility accessor in DefaultImpls
60-
will delegate to the DefaultImpls method of the superinterface. Otherwise the
61-
compatibility accessor will invoke the default method on the interface, with
62-
standard JVM runtime resolution semantics.
63-
Note that if interface delegation is used, all interface methods are delegated.
64-
The only exception are methods annotated with the deprecated @JvmDefault annotation.
65-
-Xjvm-default=all Generate default methods for all interface declarations with bodies.
66-
Do not generate DefaultImpls classes at all.
56+
-Xjvm-default=all Generate JVM default methods for all interface declarations with bodies in module.
57+
Do not generate DefaultImpls stubs for such declarations (that is default behaviour of compiler in 'disable' mode).
58+
If interface inherits such methods from interface compiled in 'disable' scheme
59+
then implicit DefaultImpls stubs would be generated as there are no default method for it.
6760
BREAKS BINARY COMPATIBILITY if some client code relies on the presence of
6861
DefaultImpls classes. Also prohibits the produced binaries to be read by Kotlin
6962
compilers earlier than 1.4.
7063
Note that if interface delegation is used, all interface methods are delegated.
7164
The only exception are methods annotated with the deprecated @JvmDefault annotation.
72-
-Xjvm-default=disable Do not generate JVM default methods and prohibit @JvmDefault annotation usage.
73-
-Xjvm-default=enable Allow usages of @JvmDefault; only generate the default method
65+
-Xjvm-default=all-compatibility In addition to `all` mode generate compatibility stubs in the DefaultImpls classes.
66+
Compatibility stubs could be useful for library and runtime authors
67+
to keep backward binary compatibility for existing client compiled against previous library versions.
68+
New 'all' and 'all-compatibility' modes are changing library ABI surface that will be used by client after their recompilation.
69+
In that sense client might be incompatible with previous library versions that REQUIRE PROPER LIBRARY VERSIONING.
70+
In case of inheritance from a Kotlin interface compiled in the old scheme
71+
(DefaultImpls, no default methods), the implicit stubs in DefaultImpls
72+
will delegate to the DefaultImpls method of the superinterface.
73+
Otherwise the compatibility stubs in DefaultImpls would invoke the default method on the interface via special accessor in it,
74+
with standard JVM runtime resolution semantics.
75+
Perform additional compatibility checks for classes in case of implicit specialized override
76+
presence in 'disable' scheme (See KT-39603 for more details)
77+
-Xjvm-default=disable Default behaviour. Do not generate JVM default methods and prohibit @JvmDefault annotation usage.
78+
-Xjvm-default=enable Deprecated. Allow usages of @JvmDefault; only generate the default method
7479
for annotated method in the interface
7580
(annotating an existing method can break binary compatibility)
76-
-Xjvm-default=compatibility Allow usages of @JvmDefault; generate a compatibility accessor
81+
-Xjvm-default=compatibility Deprecated. Allow usages of @JvmDefault; generate a compatibility accessor
7782
in the 'DefaultImpls' class in addition to the default interface method
7883
-Xjvm-default-allow-non-default-inheritance
7984
Allow inheritance from 'all*' modes for 'disable' one

0 commit comments

Comments
 (0)