Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dispatcher for creation of instrumented lambda expressions.
- Loading branch information
Showing
7 changed files
with
132 additions
and
47 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
27 changes: 27 additions & 0 deletions
27
byte-buddy-dep/src/main/java/net/bytebuddy/agent/builder/LambdaFactory.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,27 @@ | ||
package net.bytebuddy.agent.builder; | ||
|
||
import java.lang.instrument.ClassFileTransformer; | ||
import java.lang.invoke.LambdaConversionException; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public class LambdaFactory { | ||
|
||
public static final Map<ClassFileTransformer, Class<?>> CLASS_FILE_TRANSFORMERS = Collections.synchronizedMap(new LinkedHashMap<ClassFileTransformer, Class<?>>()); | ||
|
||
public static byte[] make(Object caller, | ||
String invokedName, | ||
Object invokedType, | ||
Object samMethodType, | ||
Object implMethod) throws LambdaConversionException { | ||
try { | ||
return (byte[]) CLASS_FILE_TRANSFORMERS.values().iterator().next() | ||
.getDeclaredMethod("make", Object.class, String.class, Object.class, Object.class, Object.class, Collection.class) | ||
.invoke(null, caller, invokedName, invokedType, samMethodType, implMethod, CLASS_FILE_TRANSFORMERS.keySet()); | ||
} catch (Exception exception) { | ||
throw new IllegalStateException(exception); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.