WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@nitram84
Copy link
Contributor

The latest git version of jadx decompiles this class (compiled with openjdk8)

public class AbstractItem {

	public void doSomething(Container c, Item i) {
		c.add(i);
	}

	public static class Container {

		public <T extends AbstractItem> int add(T t) {
			return 0;
		}

		public void add(AbstractItem... item) {
		}
	}

	public static class Item extends AbstractItem {
	}
}

to

public class AbstractItem {

	public void doSomething(Container c, Item i) {
		c.add((Container)i); // <-- invalid cast
	}

	public static class Container {

		public <T extends AbstractItem> int add(T t) {
			return 0;
		}

		public void add(AbstractItem... item) {
		}
	}

	public static class Item extends AbstractItem {
	}
}

It seems the arg offsets were not respected in TypeUtils.getTypeVarMappingForInvoke(). After adding the arg offset the cast was gone.

Copy link
Owner

@skylot skylot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super! Thank you 👍

@skylot skylot merged commit 7ea478e into skylot:master Nov 11, 2025
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants