BNF Grammar - RetroGuard Documentation
Here is a BNF grammar (Backus-Naur Form) for the RetroGuard script file format.
<script> ::= <script_line>*
<script_line> ::= [<comment> | <exclusion> | <nowarn>] "\n"
<exclusion> ::= (<option_enable> | <attribute_exc> | <class_exc> | <method_exc> | <field_exc>) [<comment>]
<nowarn> ::= ".nowarn" <class_spec_wc> [<comment>]
<comment> ::= "#" <character>*
<character> ::= "\040"-"\176"
<option_enable> ::= ".option" ("Application" | "Applet" | "Serializable" | "RMI" | "MapClassString" | "DigestMD5" | "DigestSHA" | "RuntimeAnnotations" | "Annotations" | "Enumeration" | "Generic" | "LineNumberDebug" | "Trim" | "Repackage")
<attribute_exc> ::= ".attribute" ("SourceFile" | "LocalVariableTable" | "LineNumberTable" | "Deprecated" | "Signature" | "LocalVariableTypeTable" | "EnclosingMethod" | "RuntimeInvisibleAnnotations" | "RuntimeInvisibleParameterAnnotations" | "RuntimeVisibleAnnotations" | "RuntimeVisibleParameterAnnotations" | "AnnotationDefault")
<class_exc> ::= (".class" | "!class") [(";" <class_access_flag>)*] <class_spec_wc> [("public" | "protected" | "pub_prot_only") ["method" | "field"]] [<extends_clause>]
<method_exc> ::= (".method" | "!method") [(";" <method_access_flag>)*] <method_field_spec> <method_descriptor> ["and_class"] [<extends_clause>]
<field_exc> ::= (".field" | "!field") [(";" <field_access_flag>)*] <method_field_spec> <java_type> ["and_class"] [<extends_clause>]
<extends_clause> ::= "extends" <class_spec>
<class_access_flag> ::= ["!"]("public" | "final" | "interface" | "abstract" | "annotation" | "enum")
<method_access_flag> ::= ["!"]("public" | "private" | "protected" | "static" | "final" | "synchronized" | "bridge" | "varargs" | "native" | "abstract" | "strict")
<field_access_flag> ::= ["!"]("public" | "private" | "protected" | "static" | "final" | "volatile" | "transient" | "enum")
<method_field_spec> ::= <class_spec_wc>"/"<java_identifier>
<method_descriptor> ::= "("<java_type>*")"<java_type>
<java_type> ::= ("["<java_type>) | "B" | "C" | "D" | "F" | "I" | "J" | "S" | "V" | "Z" | ("L"<class_spec>";")
<class_spec> ::= ((<java_identifier>"/")*)((<java_identifier>"$")*)<java_identifier>
<class_spec_wc> ::= <class_spec> | (((<java_identifier>"/")*)("*" | "**"))
<java_identifier> ::= <java_letter><java_letter_or_digit>*
<java_letter> is a Unicode character for which java.lang.Character.isJavaIdentifierStart() is true
<java_letter_or_digit> is a Unicode character for which java.lang.Character.isJavaIdentifierPart() is true
Notes:
- Script grammar changes (backwards compatible with prior scripts) introduced in RetroGuard-v2.0.1 are:
- '.option' entries 'Application', 'Applet', 'Serializable', 'RMI', 'MapClassString', 'DigestMD5', 'DigestSHA';
- package-recursive wildcard '**';
- inclusion commands '!class' and '!method' and '!field';
- 'and_class' modifier to '.method', '!method', '.field', '!field';
- 'extends' modifier to '.class', '!class', '.method', '!method', '.field', '!field';
- access modifiers (for example, '.field;private;!final;!static') for commands '.class', '!class', '.method', '!method', '.field', '!field'.
- In RetroGuard-v2.0.1 and later, the default behavior is to include no
message digests in the output jar manifest. Message digests can be included
with the '.option DigestSHA' and '.option DigestMD5' commands. Prior to this
(RetroGuard-v1.1.16 and earlier) the default was to create both MD5 and SHA-1
digests in the output jar manifest for all classes and resource files.
- Interfaces are not treated separately from classes. The '.class' token can
also refer to an interface.
- The Java virtual machine syntax is used for specifying types. These types
are:
'B' = byte
'C' = char
'D' = double
'F' = float
'I' = int
'J' = long
'S' = short
'V' = void
'Z' = boolean
'LCOM/widgetco/MyClass;' = the type of class MyClass in package COM.widgetco
'[B' = a 1-dimensional array of bytes
'[[Ljava/lang/String;' = a 2-dimensional array of Strings
For a full description of this syntax, see
The Java(TM) Virtual Machine Specification (2nd Edition)
by Yellin and Lindholm.
- Fully qualified class, method and field identifiers are used. So, for a
class 'MyClass' with method 'void aMethod(boolean isSet)' and field
'float aField' in a package 'COM.widgetco', the script entries to reserve
these identifiers would be:
.class COM/widgetco/MyClass
.method COM/widgetco/MyClass/aMethod (Z)V
.field COM/widgetco/MyClass/aField F
|