Question: how to find lambda code at runtime using CFR?
See original GitHub issueHi,
first time user of this CFR library…
I have a problem where at runtime, I want to know the actual code of a lambda. An example:
Let’s say we have the following code:
private Worker worker = new Worker();
public void runLambda() {
myLibrary.doWork(() -> worker.doWork());
}
I’m interested in finding out this peace of code: worker.doWork()
at runtime (e.g. users will use my library, use some lambda’s, and I want to find out what lambda they passed to my library). Since the lambda they pass is Serializable, I already know the implMethodName
, e.g.: lambda$runLambda$81c80a4a$1
using SerializedLambda… but how to then get access to the actual method within the lambda?
I know it is possible using CFR (debugged through it quite a lot to find a hint on how to do this) but in my opinion, I did not find a good way to do so.
Thanks in advance, Ronald
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Custom AWS Lambda runtimes
You can implement an AWS Lambda runtime in any programming language. ... To get started with custom runtimes, see Tutorial – Publishing a...
Read more >Where can I find the source code for AWS Lambda's ...
You can find the full list in the AWS documentation: Defined runtime environment variables. Every Lambda has a environment variable called ...
Read more >AWS Lambda Interview Questions and Answers
In this article, I'll go over some of the most commonly asked questions that come up in interviews about AWS Lambda.
Read more >Deep Dive Into Lambda Layers and the Lambda Runtime API
To learn more, please visit: https://aws.amazon.com/ lambda / In November, AWS Lambda introduced Lambda Layers and the Lambda Runtime API.
Read more >Lambda triggered by SQS question · Discussion #400 - GitHub
In GO for example, I'm using the sqsEvent type, but could not find an equivalent for Rust. Could someone point me in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, you guys are correct…
The thing I need it for is as follows (only Java 8 and higher support is needed): In case of my first example: I want to catch the lambda, find the actual code inside (in this
worker.doWork()
), serialize it, send it to another physical machine where it then gets executed without the actual context (so, no use ofgetImplMethodName
as this only specifies the context, the surrounding class could even not be available) but with theWorker
class available.Not a trivial task, I know. But thanks to @Col-E , I have some new insights.
Thank you all for the excellent support!
Ok - first - this really isn’t a CFR thing 😉
CFR is entirely about NOT using reflection, or any other such thing, or relying on the vagiaries of a particular JVM implementation - it’s about static analysis of bytecode. I strongly agree with @Lanchon …
To state the obvious - a functional interface implementation may be a lambda, or it may be… any old thing. I assume you’ve already covered the non-lambda case.
I can’t stress enough that if you rely on this sort of thing in production code, you’re going to be basically buggered.