I've read from the apt tool page that one can create AnnotationProcessors to generate new derived files (source files, class files, deployment descriptors, etc.). I am looking for example to do so.
My need is to encode all annotated strings at compile time, so that reading the class file does not allow reading the static strings:
Base code:
String message = (@Obfuscated "a string that should not be readable in class file");
Should be reworked as:
String message = new ObfuscatedString(new long[] {0x86DD4DBB5166C13DL, 0x4C79B1CDC313AE09L, 0x1A353051DAF6463BL}).toString();
Based on the static ObfuscatedString.obfuscate(String)
method of the TrueLicense framework, the processor can generate the code to replace the annotated string. Indeed, this method generates the string "new ObfuscatedString([numeric_code]).toString()".
At runtime the toString() method of ObfuscatedString is able to return the string encoded in the numeric code.
Any idea on how to write the process() method of the AnnotationProcessor to edit the annotated code?
Thanks in advance,