-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed incompatibility with JDK 8 build b121, fixes #3
There were multiple breaking changes at play: - The ClassFileTransformer.transform method now gets className=null as parameter for lambda classes. The class name must be parsed from bytecode. - The naming pattern of lambda implementation methods was changed from lambda$1 to lambda$invokingMethod$1 - The lambda class now calls private instance methods (i.e. lambda accesses the invoker's instance variables) using the invokespecial instruction, to avoid a subclass accidentally overriding the generated lambda implementation method. But using invokespecial to call methods of other classes is not allowed in bytecode (see the spec http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.invokespecial) and lambdas can get away with it only because JDK 8 relaxes the verification of lambda classes. Our workaround is to change the opcode to invokevirtual at the risk of calling a malicious subclass method.
- Loading branch information
Showing
7 changed files
with
79 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
retrolambda/src/main/java/net/orfjackal/retrolambda/LambdaNaming.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright © 2013-2014 Esko Luontola <www.orfjackal.net> | ||
// This software is released under the Apache License 2.0. | ||
// The license text is at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package net.orfjackal.retrolambda; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class LambdaNaming { | ||
|
||
public static final String LAMBDA_METAFACTORY = "java/lang/invoke/LambdaMetafactory"; | ||
public static final String MAGIC_LAMBDA_IMPL = "java/lang/invoke/MagicLambdaImpl"; | ||
public static final Pattern LAMBDA_CLASS = Pattern.compile("^.+\\$\\$Lambda\\$\\d+$"); | ||
public static final Pattern LAMBDA_IMPL_METHOD = Pattern.compile("^lambda\\$.*\\$\\d+$"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters