This is an embarrassing mistake. I designed and implemented DexPatcher in a couple of days, and I had never really used Java annotations before.
Because in Java you cannot rename a constructor, if you want to invoke the original constructor from a replacement constructor, you need to add a tag parameter to overload it instead. DexPatcher 1.0.0 recognizes a tag parameter by detecting the specific hardcoded type 'lanchon.dexpatcher.annotation.DexTag', which is bundled in the annotations Jar, and must be included in final executable.
This idiom is typically used to patch a constructor:
I used a tag type instead of a parameter annotation because I thought that parameter annotations were a Java 1.8 feature, when in fact they are supported in Java 1.7. The downside to this is that an app can easily detect that it has been patched by DexPatcher by checking for this tag type.
To avoid this problem, the tagging mechanism should be changed to a parameter annotation applicable to any type (including primitive types). A suggested name for the annotation is 'DexTagParameter'. Alternatively, the existing 'DexIgnore' annotation could be overloaded for this use.
It might be better if the 'DexTag' name goes unused to guarantee compile time errors in old code. But most code would reference 'DexTag.TAG' anyway, and if not the resulting patch would fail to apply, so this is not hard requirement.
This is an embarrassing mistake. I designed and implemented DexPatcher in a couple of days, and I had never really used Java annotations before.
Because in Java you cannot rename a constructor, if you want to invoke the original constructor from a replacement constructor, you need to add a tag parameter to overload it instead. DexPatcher 1.0.0 recognizes a tag parameter by detecting the specific hardcoded type 'lanchon.dexpatcher.annotation.DexTag', which is bundled in the annotations Jar, and must be included in final executable.
This idiom is typically used to patch a constructor:
I used a tag type instead of a parameter annotation because I thought that parameter annotations were a Java 1.8 feature, when in fact they are supported in Java 1.7. The downside to this is that an app can easily detect that it has been patched by DexPatcher by checking for this tag type.
To avoid this problem, the tagging mechanism should be changed to a parameter annotation applicable to any type (including primitive types). A suggested name for the annotation is 'DexTagParameter'. Alternatively, the existing 'DexIgnore' annotation could be overloaded for this use.
The end result would look like this:
It might be better if the 'DexTag' name goes unused to guarantee compile time errors in old code. But most code would reference 'DexTag.TAG' anyway, and if not the resulting patch would fail to apply, so this is not hard requirement.