INRIA / INRIA/spoon

[Bug]: DefaultJavaPrettyPrinter incorrectly print Annotation method

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

Description

### Describe the bug

```
@interface MyAnnotation{
int value();
}

public class array {
@MyAnnotation(value=50)
private float foo() {
int[] a ={3,4,5};
return 2;
}
}

```

The code above is the code to be analyzed. When printing the method foo with DefaultJavaPrettyPrinter, the following is produced. Obviously, in annotation part, "value" is missed.

```

@MyAnnotation(50)
private float foo() {
int[] a = new int[]{ 3, 4, 5 };
return 2;
}
```

### Source code you are trying to analyze/transform

_No response_

### Source code for your Spoon processing

_No response_

### Actual output

_No response_

### Expected output

_No response_

### Spoon Version

9.1.0

### JVM Version

11

### What operating system are you using?

ubuntu

Contributor guide

Open the contributing guide

Research direction

Start by locating DefaultJavaPrettyPrinter and reproducing the annotation-method example from the issue. Trace how @MyAnnotation(value=50) is printed, then verify that the generated output preserves the value= element rather than reducing it to @MyAnnotation(50).

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.