Skip to content

Commit 4b9549e

Browse files
committed
Documentation for default methods and static methods on interfaces
Closes #31
1 parent b0cd437 commit 4b9549e

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

README.md

+27-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ Retrolambda: Use Lambdas on Java 7
66

77
Just as there was [Retroweaver](http://retroweaver.sourceforge.net/) et al.
88
for running Java 5 code with generics on Java 1.4, **Retrolambda** lets you
9-
run Java 8 code with lambda expressions and method references on Java 7 or
10-
lower. It does this by transforming your Java 8 compiled bytecode so that
11-
it can run on a Java 7 runtime. After the transformation they are just a
12-
bunch of normal .class files, without any additional runtime dependencies.
13-
[Read more details](#backported-language-features).
9+
run Java 8 code with **lambda expressions** and **method references** on
10+
Java 7 or lower. It does this by transforming your Java 8 compiled bytecode
11+
so that it can run on a Java 7 runtime. After the transformation they are
12+
just a bunch of normal .class files, without any additional runtime
13+
dependencies. [Read more details](#backported-language-features).
14+
15+
There is also [limited support](#known-limitations) for backporting
16+
**default methods** and **static methods on interfaces**. This feature is
17+
disabled by default.
1418

1519
Adventurous developers may use Retrolambda to backport lambda expressions
1620
even to Java 6 or Java 5. And if you reach Java 5, there are [other
@@ -101,9 +105,10 @@ Optional system properties:
101105
Default value is 51 (i.e. Java 7)
102106
103107
retrolambda.defaultMethods
104-
Whether to backport default and static methods on interfaces.
108+
Whether to backport default methods and static methods on interfaces.
105109
LIMITATIONS: All backported interfaces and all classes which implement
106-
them must be backported together with one execution of Retrolambda.
110+
them or call their static methods must be backported together,
111+
with one execution of Retrolambda.
107112
Disabled by default. Enable by setting to "true"
108113
109114
retrolambda.outputDir
@@ -156,13 +161,27 @@ expressions and they are backported in the same way.
156161
If you would like the suppressed exceptions to be logged instead of
157162
swallowed, please create a feature request and we'll make it configurable.
158163

164+
*Optionally also:*
165+
166+
**Default methods** are backported by moving the default methods to a
167+
companion class (interface name + "$") as static methods, and by adding the
168+
necessary method implementations to all classes which implement that
169+
interface.
170+
171+
**Static methods on interfaces** are backported by moving the static
172+
methods to a companion class (interface name + "$"), and by changing all
173+
methods calls to call the new method location.
174+
159175

160176
Known Limitations
161177
-----------------
162178

163179
Does not backport Java 8 APIs.
164180

165-
Does not backport Java 8 language features other than lambda expressions.
181+
Backporting default methods and static methods on interfaces requires all
182+
backported interfaces and all classes which implement them or call their
183+
static methods to be backported together, with one execution of
184+
Retrolambda.
166185

167186
May break if a future JDK 8 build stops generating a new class for each
168187
`invokedynamic` call. Retrolambda works so that it captures the bytecode

retrolambda-maven-plugin/src/main/java/net/orfjackal/retrolambda/maven/ProcessClassesMojo.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ abstract class ProcessClassesMojo extends AbstractMojo {
6767
public String target;
6868

6969
/**
70-
* Whether to backport default and static methods on interfaces.
70+
* Whether to backport default methods and static methods on interfaces.
7171
* LIMITATIONS: All backported interfaces and all classes which implement
72-
* them must be backported together with one execution of Retrolambda.
72+
* them or call their static methods must be backported together,
73+
* with one execution of Retrolambda.
7374
*
7475
* @since 2.0.0
7576
*/

retrolambda/src/main/java/net/orfjackal/retrolambda/Config.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public String getJavaVersion() {
7979

8080
static {
8181
optionalParameterHelp(DEFAULT_METHODS,
82-
"Whether to backport default and static methods on interfaces.",
82+
"Whether to backport default methods and static methods on interfaces.",
8383
"LIMITATIONS: All backported interfaces and all classes which implement",
84-
"them must be backported together with one execution of Retrolambda.",
84+
"them or call their static methods must be backported together,",
85+
"with one execution of Retrolambda.",
8586
"Disabled by default. Enable by setting to \"true\"");
8687

8788
}

0 commit comments

Comments
 (0)