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

Add method hierarchy propagation via MIO and Hypo #4123

Open
wants to merge 1 commit into
base: 25w07a
Choose a base branch
from

Conversation

NebelNidas
Copy link
Member

@NebelNidas NebelNidas commented Feb 17, 2025

Loosely based on modmuss50@c4b22c0.

This acts as a replacement for the now deprecated MapSpecializedMethodsTask, allowing us to remove Enigma from the build process in the future.

Hypo was chosen as the backend since Tiny Remapper doesn't expose the necessary bridge information yet, Enigma's handling is broken and Matcher is neither on Maven, nor does it index synthetic sources/targets.
Hypo on the other hand provides most of the required functionality out of the box and is battle-tested thanks to its extensive use in the PaperMC toolchain since 2021.

If you want to compare the old yarn-specialized-mappings-v2.tiny with the new yarn-propagated-v2.tiny, I recommend pasting the following snippet into MapSpecializedMethodsTask:

@Override
public void run() {
	super.run();

	try {
		Thread.sleep(10000);
	} catch (InterruptedException e) {
		throw new RuntimeException(e);
	}

	MemoryMappingTree tree = new MemoryMappingTree();

	try {
		MappingReader.read(getOutputPath(), tree);

		for (MappingTree.ClassMapping cls : tree.getClasses()) {
			if (cls.getSrcName().equals(cls.getDstName(0))) {
				cls.setDstName(null, 0);

				for (MappingTree.MethodMapping method : cls.getMethods()) {
					if (method.getSrcName().equals(method.getDstName(0))) {
						method.setDstName(null, 0);
					}
				}
			}
		}

		tree.accept(MappingWriter.create(getOutputPath(), MappingFormat.TINY_2_FILE), VisitOrder.createByName());
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}

This acts as a replacement for the now deprecated `MapSpecializedMethodsTask`, allowing us to remove Enigma from the build process in the future.
@NebelNidas NebelNidas requested a review from a team as a code owner February 17, 2025 01:43
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.

1 participant