INRIA / INRIA/spoon

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

Open
#5,628 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
2k
Forks
392
Avg merge
11h 24m
Merged PRs (30d)
36

Description

### Describe the bug

I use the following code to get the signature of callees in method invocations.
```java
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)`.
```java
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

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

### Source code for your Spoon processing

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

### Actual output

```Java
parse()
```

### Expected output

```Java
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.