Nests

From Ornithe Wiki
Revision as of 16:00, 31 July 2025 by Space Walker (talk | contribs) (create Nests page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Nests are Ornithe's inner class patches. They are used to modify inner class attributes in Java class files.

See Nester for information on how these patches are applied.

Inner Class Attributes

Inner class attributes are necessary for interactions with inner classes to work as expected. This is especially noticeable with non-static inner classes, and anonymous classes in particular. These inner classes can access fields, methods, or variables from their outer class or method, as well as the other way around.

Obfuscators such as ProGuard may remove these class file attributes. This is generally not a problem, since these attributes do not affect the runtime behavior of a Java application. However, if you wish to de-obfuscate and decompile a jar file, you will get better results when the inner class attributes are present.

Relevance

Most Minecraft versions before 1.8.2 Pre-release 5 had the inner class attributes stripped from the jar. Nests were created in an effort to reconstruct what the original inner classes would have been in the source code.

File Specification

.nest files are UTF-8 encoded text files. Each line defines the relationship between a class and its outer class and, if applicable, outer method. A line has the following format.

<class name>	<outer class name>	<outer method name>	<outer method descriptor>	<inner name>	<access>
  • class name: the internal name of the class
  • outer class name: the internal name of the outer class.
  • outer method name: the name of the outer method (may be empty).
  • outer method descriptor: the descriptor describing the type of the outer method (may be empty).
  • inner name: the inner name of the class (may be empty).
  • access: the access flags for the inner class.

Notes

The inner name component does not directly correspond to the inner name as defined in the inner class attribute. Rather, it is used to construct a new internal name of the class. The actual inner name is parsed from this component.

For regular inner classes, the inner name component corresponds directly to the inner name as defined in the inner class attribute. If the component is all digits, the inner class is assumed to be anonymous, and the actual inner name null. If the component starts with digits and transitions to text, the inner class is assumed to be local, and the inner name the text part of the component.

For example:

  • Example - the class is assumed to be a regular inner class, with inner name Example.
  • 1 - the class is assumed to be an anonymous class, with inner name null.
  • 1Example - the class is assumed to be a local class, with inner name Example.