Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.05 KB

shadow-anonymous.md

File metadata and controls

43 lines (27 loc) · 1.05 KB

@Shadow, anonymous class

<- Return

Allows accessing a 'local variable' used in an anonymous class, which is actually just a final instance field.

Shadowing the field is done the same way as a normal field, however finding the exact name of the field might be a bit tricky.

IntelliJ Idea

  • Open the class file

bytecode_1

  • Put your cursor on a line inside the anonymous class

bytecode_2

  • Click on View -> Show Bytecode

bytecode_3

  • Find the name of the field you need by index

bytecode_4

Eclipse

TODO

@Dynamic Annotation

It might help IDE extensions such as Minecraft Development to know that the shadowed field is synthetic (compiler generated) to prevent unnecessary warnings. To do this, simply annotate the field with a @Dynamic annotation.

Example mixin:

@Mixin(target="path/to/Dummy$1")
public abstract class MixinDummy_1 {
	@Dynamic
	@Final
	@Shadow
	private Profiler field_21965;
}