yGuard icon indicating copy to clipboard operation
yGuard copied to clipboard

Improve record obfuscation

Open thomasbehr opened this issue 3 years ago • 0 comments

When compiling a record, the java compiler inserts bootstrap methods that handle equals/hashCode/toString. These bootstrap methods are passed a descriptor string identifying the record's components by name. yGuard replaces that descriptor string for the bootstrap method invocation with a remapped descriptor string. The value of the old descriptor string is kept in the constant pool to prevent breaking string literals in code that have the same value as the descriptor, e.g. suppose

record MyRecord(int value) {
  String getName() {
   return "value";
  }
}

However, for most cases the descriptor string will be unique and should be removed to ensure all traces of the original component names are gone. This requires counting the references to string literals in code blocks.

thomasbehr avatar Mar 01 '22 17:03 thomasbehr