Skip to content

CUpgrade

Lenni0451 edited this page Mar 17, 2024 · 1 revision

The CUpgrade annotation can be used to upgrade a class to a new version.
This only sets the class version, it does not change the class itself.

This is useful when injecting into a class compiled with an older version of Java with the transformer being compiled with a newer version of Java.
One example for this is the StringConcatFactory which was added in newer Java versions.
Java would complain when using it in a class compiled with an older version of Java.

The target version is automatically set to the version of the transformer.
This can be changed manually by setting the value parameter to the target version.
If the version of the target class is higher than the target version, this will do nothing.

Example

Using the transformer version:

@CUpgrade
@CTransformer(TestClass.class)
public class Transformer {

Using a custom version:

@CUpgrade(Opcodes.V17)
@CTransformer(TestClass.class)
public class Transformer {
Clone this wiki locally