Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bug] Cannot create shadow class #4529

Closed
kl0u opened this issue Jan 17, 2022 · 9 comments
Closed

[Bug] Cannot create shadow class #4529

kl0u opened this issue Jan 17, 2022 · 9 comments

Comments

@kl0u
Copy link

kl0u commented Jan 17, 2022

Hi all,

With setNoClasspath(true) I am getting a:

09:23:34.703 [main] WARN  spoon.Launcher - cannot create shadow class: XXXXXXXXXXXXXXX
java.lang.StackOverflowError: null
at java.base/java.lang.Class.getSimpleName(Class.java:1550) ~[na:na]
at spoon.support.visitor.java.JavaReflectionTreeBuilder.visitTypeReference(JavaReflectionTreeBuilder.java:500) ~[spoon-core-10.0.0.jar:na]
at spoon.support.visitor.java.JavaReflectionVisitorImpl.visitAnnotation(JavaReflectionVisitorImpl.java:298) ~[spoon-core-10.0.0.jar:na]

Operating system, JDK and Spoon version used

  • OS: MacOS
  • Spoon version: 10.0.0
@SirYwell
Copy link
Collaborator

I believe this is already fixed with #4356. There was no snapshot or release since then sadly, so if you want to test if the issue is actually fixed, you'll need to install spoon into your local maven repository yourself.

(ping @monperrus, maybe it would be time for a new snapshot version at some point?)

@slarse
Copy link
Collaborator

slarse commented Jan 24, 2022

(ping @monperrus, maybe it would be time for a new snapshot version at some point?)

@SirYwell Snapshots are being deployed as they should to OW2 nexus. Only the beta deployments are broken, and we just haven't had the time to look into it.

@kl0u Could you try to see if the latest snapshot solves your problem? See the FAQ for how to use a snapshot.

@kl0u
Copy link
Author

kl0u commented Jan 31, 2022

Thanks a lot for the information. The issue seems to be fixed in the newest SNAPSHOT.

One more question, what is the recommended way to print a modified class but with the minimum set of changes? The sniper pretty printer seems to be a good candidate for this but it is having some issues like the #4332. Is there another way?

@MartinWitt
Copy link
Collaborator

The sniper printer is the go-to way for exactly this task. In projects like sorald https://github.com/SpoonLabs/sorald it is used at large scale with not many problems(to my knowledge). These bugs are more or less edge cases you hopefully don't encounter.
Out of the box, there is no other way in spoon integrated.

@kl0u
Copy link
Author

kl0u commented Feb 1, 2022

Thanks for the reply @MartinWitt . Unfortunately I bump into the issue I linked and I am wondering if there is even a quick fix that I can test even with a custom build. In any case, thanks a lot.

@kl0u
Copy link
Author

kl0u commented Feb 1, 2022

BTW I think that it would help a lot when debugging to print here the source code of the element that causes the problem (this and other) or its position in the code base. This would allow us to check what causes the problem and it will hopefully make your life easier as we will be able to create more useful and descriptive issues.

@slarse
Copy link
Collaborator

slarse commented Feb 2, 2022

The problem in #4332 is most likely that source positions from different files are compared. Last time I recall this happening was that a static import statement (e.g. import static org.blabla.SomeClass.someMethod) had a reference with a source position from the file where the method was declared. It could also be that the source fragments have been built incorrectly, for example that the nesting of fragments isn't quite right.

But, in any of these cases, I don't think printing the source code helps. It's a position problem.

@kl0u
Copy link
Author

kl0u commented Feb 5, 2022

I think I can close this issue as it is already resolved.

As for the proposal of printing the source code, the only thing I want to point out is that what is currently printed is not helping with debugging or filing a bug report because it is not easy to parse. Maybe a better option is to print the position so that the user can inspect the code himself/herself. In my case, I modified the Spoon source code to print the code fragment because that was the easiest way to figure out what was causing my problem.

Again thanks for the help :)

@kl0u
Copy link
Author

kl0u commented Feb 5, 2022

Resolved by #4356 as pointed out above.

@kl0u kl0u closed this as completed Feb 5, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants