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

Infinite loop in buildModel #3903

Closed
gchaperon opened this issue May 3, 2021 · 2 comments · Fixed by #3905
Closed

Infinite loop in buildModel #3903

gchaperon opened this issue May 3, 2021 · 2 comments · Fixed by #3905
Labels

Comments

@gchaperon
Copy link
Contributor

Hi!
I am trying to process a file but the library gets stuck when trying to build the model.
The file that I am trying to process is this one

The code I am using is below:

import spoon.FluentLauncher;
import spoon.reflect.CtModel;

public class TestBuildModelStuck {
	public static void main(String[] args) {
		String path = "/path/to/myfile.java";
		CtModel model = new FluentLauncher().inputResource(path).buildModel();

	}
}

Using the debugger I managed to see that buildModel is stuck in an infinite loop here:


off never goes below zero

The part of my file it gets stuck on is T.Entry<K, V>, found in line 508 of my file.

I am failing to see why this is happening. Is that syntax not allowed or invalid?

@slarse
Copy link
Collaborator

slarse commented May 3, 2021

Hi @gchaperon,

That's perfectly valid Java. I haven't seen it written like that before, but T.Entry<K, V> erases just fine to Map.Entry, so there's no type problem.

I can also reproduce the bug. The problem is that JDT resolves T as a qualified type reference, but Spoon does not appear to handle the case where that's a type parameter reference. In other words, this is a bug!

@slarse slarse added the bug label May 3, 2021
@slarse
Copy link
Collaborator

slarse commented May 3, 2021

Here's a minimal piece of code that reproduces the bug:

Launcher.parseClass("public class Main<T extends java.util.Map<String, String>> { T.Entry<String, String> entry; }");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants