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

Different behavior for different jdk versions #3240

Closed
MartinWitt opened this issue Feb 10, 2020 · 1 comment
Closed

Different behavior for different jdk versions #3240

MartinWitt opened this issue Feb 10, 2020 · 1 comment

Comments

@MartinWitt
Copy link
Collaborator

During the pr #3200 i found this "interesting" behavior.
` @test
public void showBug() {
Launcher spoon = new Launcher();
spoon.addInputResource("src/test/resources/deprecated/input");
CtModel model = spoon.buildModel();
Collection<CtExecutable<?>> list = new HashSet<>();

	model.getElements(new TypeFilter<>(CtInvocation.class))
	.forEach(v -> list.add(v.getExecutable().getExecutableDeclaration()));
	list.removeIf(v -> Objects.isNull(v));
	//Filter methods that are not in the code
	list.removeIf(v -> !v.getPosition().isValidPosition());
	//in jdk 8 size 3
	//in jdk 11 size 4

	/* jdk8 List
	[// should be deleted because only ref in Foo.test3()
	@java.lang.Deprecated
	public void test3() {
	  test3();
	}, // ref in Foo.test1()
	@java.lang.Deprecated
	public boolean test2() {
	  return true;
	}, // ref in Bar.test
	@java.lang.Deprecated
	public void test5() {
	}]
	*/
	/*jdk11 List
	[// should be deleted because only ref in Foo.test3()
	@java.lang.Deprecated
	public void test3() {
	    test3();
	}, // ref in Bar.foo()
	@java.lang.Deprecated
	public void test4() {
	}, // ref in Foo.test1()
	@java.lang.Deprecated
	public boolean test2() {
	    return true;
	}, // ref in Bar.test
	@java.lang.Deprecated
	 */
	assertEquals(4, list.size());
}` 

Maybe somebody wants to debug this issue. If not it's here if somebody finds this behavior during their work and knows that this is an open problem.

@monperrus
Copy link
Collaborator

Thanks a lot for documenting this.

This is not the first time we see behavioral differences across Java versions:

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

No branches or pull requests

2 participants