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

[Bug] Wrong package name when parsing class #4786

Open
treenwang opened this issue Jul 7, 2022 · 1 comment
Open

[Bug] Wrong package name when parsing class #4786

treenwang opened this issue Jul 7, 2022 · 1 comment
Labels

Comments

@treenwang
Copy link
Contributor

Describe the bug
When parsing a class which package is child of some classes which use inline qualified class name, those inline qualified classes' package name will be changed to the child package.

To Reproduce

Input:

String code2 = "package io.example.pack1.pack2;\n" +
		"    public class Example{\n" +
		"      void add(io.example.pack1.Class1<io.example.pack1.Class2> value){\n" +
		"      }\n" +
		"    }\n";
CtClass<?> class2 = Launcher.parseClass(code2);
System.out.println(class2.toStringWithImports());

Output:

package io.example.pack1.pack2;
public class Example {
    void add(Class1<Class2> value) {
    }
}

Expected:

package io.example.pack1.pack2;
import io.example.pack1.Class1;
import io.example.pack1.Class2;
public class Example {
    void add(Class1<Class2> value) {
    }
}

Test case pull request: #4782

Operating system, JDK and Spoon version used

  • OS: MacOS
  • JDK: Java 11
  • Spoon version: 10.1.1
@slarse
Copy link
Collaborator

slarse commented Jul 9, 2022

Curious. Thanks for the bug report!

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

No branches or pull requests

2 participants