INRIA / INRIA/spoon

How to update existing class

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

Description

### Describe the bug

I just discovered this library and I'm trying to see if it's possible to do something that I require.

I have the following code:

```
@MyAnnotation
public class Book
{
private String name;
}
```

And I want this to get generated:
```
public class Book
{
private String name;

boolean isValid()
{
return name != null;
}
}
```

I'm already able to generate this code but the output file is created in a generated folder with the same name.

I changed the output folder to be the same as the generated code but it's replacing the existing class.

It's possible to just generate the file in memory and then compile it?

I don't want to generate a new file or change the source code of the existing one.

I can't use other libraries such as Byte-Buddy because I need this new file available during compilation.

Any help is welcome.

Thanks

### Spoon Version

10.2.0

### JVM Version

11

### What operating system are you using?

Windows 10

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.