Scan Multiple Classes Without Specifying Names
Leveraging SpASM's Automatic Scanning
SpASM's core strength is scanning all loaded game classes without requiring you to hardcode target class names. This enables pattern-based and behavior-based transformations across the entire codebase.
Scanning Strategy
1. Inspect class metadata in your transformer to identify target classes. Check class names, method signatures, annotations, or inheritance hierarchy to find classes matching your criteria.
2. Use bytecode inspection libraries (like ASM, which SpASM uses internally) to examine class structure before deciding whether to transform it.
3. Apply conditional transformations based on what you find. Only modify classes that match your pattern, leaving others untouched.
4. Transform based on behavior rather than names. For example, find all classes implementing a specific interface or containing methods with particular signatures.
5. Return unmodified bytecode for classes you don't need to change. This keeps the transformation efficient and prevents unnecessary modifications.
This approach is powerful for cross-cutting concerns like adding logging, intercepting calls, or injecting compatibility layers across many classes simultaneously without maintaining a hardcoded class list.