Exclusion Rules
Exclusion rules specify which classes, methods, or fields should NOT be obfuscated. While Bozar generally handles standard reflection automatically, exclusions are essential for dynamic reflection (where names are constructed at runtime), serialization, and certain frameworks.
Syntax Overview
Enter one rule per line using the following prefixes:
class:- Matches classesmethod:- Matches methodsfield:- Matches fields!- Inverts the rule (include instead of exclude)#- Comments
Class Exclusions
Use class: followed by the class name pattern.
Exact Match
class: com.example.Main
class: com.example.api.UserServiceWildcard Patterns
| Pattern | Matches | Example |
|---|---|---|
* | Any single package level | class: com.example.* |
** | Any number of package levels | class: com.example.** |
? | Any single character | class: com.example.User? |
! | Invert rule (include) | !class: com.example.Internal |
Inverting Rules
You can use the exclamation mark ! to invert a rule. This is useful when you want to exclude a package but keep a specific class within it obfuscated (or vice-versa, depending on your default strategy).
# Exclude everything in com.example
class: com.example.**
# But keep com.example.SecretClass obfuscated (force include)
!class: com.example.SecretClassExamples
# All classes in com.example package (not subpackages)
class: com.example.*
# All classes in com.example and all subpackages
class: com.example.**
# All classes ending with "Controller"
class: **.*ControllerMethod and Field Exclusions
Use method: or field: to exclude class members.
# Exclude methods starting with 'get'
method: get*
# Exclude specific field
field: serialVersionUID
# Exclude methods with specific signature (advanced)
method: process(Ljava/lang/String;)VCommon Framework Exclusions
Serialization
Classes that are serialized (e.g., to JSON or binary) usually need their names and fields preserved.
class: com.example.dto.**
class: com.example.model.**Maven Plugin Configuration
When using the Maven Plugin, exclusions are configured directly in XML — no prefix syntax needed:
<exclusions>
<classes>
<class>com.example.dto.**</class>
<class>com.example.model.**</class>
</classes>
<methods>
<method>get*()</method>
<method>set*()</method>
</methods>
<fields>
<field>serialVersionUID</field>
<field>SECRET_*</field>
</fields>
</exclusions>Each section is optional — include only what you need. The same wildcard patterns (*, **, ?, !) apply.