Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: How to correctly recognize the signature of invoked methods in lambda expression? #5628

Open
uxhg opened this issue Jan 19, 2024 · 0 comments
Labels

Comments

@uxhg
Copy link

uxhg commented Jan 19, 2024

Describe the bug

I use the following code to get the signature of callees in method invocations.

for (CtInvocation element : elements) {
    String callee_sig = element.getExecutable().getSignature();
}

However for the lambda expression like this below, it returns a parse() instead of parse(java.nio.file.Path,java.nio.charset.Charset,org.apache.commons.csv.CSVFormat).

assertThrows(NullPointerException.class, () -> CSVParser.parse((Path) null, Charset.defaultCharset(), CSVFormat.DEFAULT));

I tried element.getExecutable().getParameters() and it returns an empty list.
Is this behaviour expected? What is the correct way to get this method signature?

Source code you are trying to analyze/transform

assertThrows(NullPointerException.class, () -> CSVParser.parse((Path) null, Charset.defaultCharset(), CSVFormat.DEFAULT));

Source code for your Spoon processing

for (CtInvocation element : elements) {
    String callee_sig = element.getExecutable().getSignature();
    System.out.println(callee_sig);
}

Actual output

parse()

Expected output

parse(java.nio.file.Path,java.nio.charset.Charset,org.apache.commons.csv.CSVFormat)

Spoon Version

10.4.2

JVM Version

openjdk version "11.0.22-ea" 2024-01-16 OpenJDK Runtime Environment (build 11.0.22-ea+6-post-Debian-1) OpenJDK 64-Bit Server VM (build 11.0.22-ea+6-post-Debian-1, mixed mode, sharing)

What operating system are you using?

Debian GNU/Linux trixie/sid x86_64

@uxhg uxhg added the bug label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant