Interface ClassProcessor
- All Known Implementing Classes:
AccessTransformerService,BaseSimpleProcessor,FMLMixinClassProcessor,MethodRedirector,NeoForgeDevDistCleaner,ReplaceFieldComparisonWithInstanceOf,ReplaceFieldWithGetterAccess,RuntimeEnumExtender,SimpleClassProcessor,SimpleFieldProcessor,SimpleMethodProcessor,SimpleProcessorsGroup
public interface ClassProcessor
Class processors provide an API for transforming classes as they are loaded. They take care to use correctly and
efficiently. The main pieces of a processor are
handlesClass(SelectionContext) and
processClass(TransformationContext), which allow processors to say whether they want to process a given
class and allow them to transform the class. Processors are named and should have sensible namespaces; ordering is
accomplished by specifying names that processors should run before or after if present.
For a simpler API, see SimpleClassProcessor, SimpleMethodProcessor, and SimpleFieldProcessor.
Class processors can be provided using the Java ServiceLoader mechanism. If you
require more control, you can also implement a ClassProcessorProvider.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordContext available in post-processing single-instance callbacksstatic enumstatic final recordThe context provided to class processors when they are linked with a bytecode source.static enumstatic final recordContext available when determining whether a processor wants to handle a classstatic final classContext available when processing a class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault voidWhere a class may be processed multiple times by the same processor (for example, if in addition to being loaded a later processor requests the state of the given class using aBytecodeProvider), an after-processing callback is guaranteed to run at most once per class, just before class load.Returns packages that this processor generates classes for, that do not already exist on the game layer.booleanReturns whether the processor wants to recieve the class.default voidlink(ClassProcessor.LinkContext context) Called once after a set of class processors has been linked together with a bytecode source.name()Returns a unique identifier for this processor.default ClassProcessor.OrderingHintReturns a hint for how this processor should be ordered relative to other processors.Each class that the processor has opted to recieve is passed to this method for processing.default Set<ProcessorName> Returns processors that this processor must run after.default Set<ProcessorName> Returns processors that this processor must run before.
-
Field Details
-
GENERATED_PACKAGE_MODULE
- See Also:
-
-
Method Details
-
name
ProcessorName name()Returns a unique identifier for this processor.- Returns:
- a unique identifier for this processor
-
runsBefore
Returns processors that this processor must run before.- Returns:
- processors that this processor must run before
-
runsAfter
Returns processors that this processor must run after. This should includeClassProcessorIds.COMPUTING_FRAMESif the processor returns a result requiring frame re-computation.- Returns:
- processors that this processor must run after
-
generatesPackages
Returns packages that this processor generates classes for, that do not already exist on the game layer. Generated packages in the game layer will be in the module "net.neoforged.fml.generated".- Returns:
- packages that this processor generates classes for, that do not already exist on the game layer
-
orderingHint
Returns a hint for how this processor should be ordered relative to other processors. Note that this is a comparatively weak hint;runsBefore()andrunsAfter()take precedence, and processors don't have "phases" of any sort.- Returns:
- a hint for how this processor should be ordered relative to other processors
-
handlesClass
Returns whether the processor wants to recieve the class.- Parameters:
context- the context of the class to consider- Returns:
- whether the processor wants to recieve the class
-
processClass
Each class that the processor has opted to recieve is passed to this method for processing.- Parameters:
context- the context of the class to process- Returns:
- the
ClassProcessor.ComputeFlagsindicating how the class should be rewritten.
-
afterProcessing
Where a class may be processed multiple times by the same processor (for example, if in addition to being loaded a later processor requests the state of the given class using aBytecodeProvider), an after-processing callback is guaranteed to run at most once per class, just before class load. A transformer will only see this context for classes it has processed.- Parameters:
context- the context of the class that was processed
-
link
Called once after a set of class processors has been linked together with a bytecode source. FML will not call transformation methods on this class processor, until it has been linked.FML only links providers once during startup.
-