@Retention(value=CLASS)
@Target(value={METHOD,CONSTRUCTOR})
public @interface CModifyConstant
optional() is set to true.nullValue()).
This argument will be the original value of the constant.
@CModifyConstant(method = "print", stringValue = "test")
public String modifyConstant(String original) {
//Do something with the original value and return the new value
return original + "!";
}
If your target has to be chosen more precisely you can use a slice() to narrow down the search.CSlice,
GitHub Wiki| Modifier and Type | Required Element and Description |
|---|---|
java.lang.String[] |
method
The method name and descriptor to inject into.
This supports multiple targets and wildcards. e.g. |
| Modifier and Type | Optional Element and Description |
|---|---|
double |
doubleValue
Set the given double as the target.
The transformer method must return a double and can optionally take a double as the first argument. |
float |
floatValue
Set the given float as the target.
The transformer method must return a float and can optionally take a float as the first argument. |
int |
intValue
Set the given int as the target.
The transformer method must return an int and can optionally take an int as the first argument. |
long |
longValue
Set the given long as the target.
The transformer method must return a long and can optionally take a long as the first argument. |
boolean |
nullValue
Set
ACONST_NULL as the target.The transformer method must return any object and does not take any arguments. The return value type is not verified so make sure to return the correct type. |
boolean |
optional
Make this injection optional.
If the target is not found an exception will be thrown unless this is set to true. |
int |
ordinal
The ordinal of target constant.
|
CSlice |
slice
The slice to narrow down the search for the target.
|
java.lang.String |
stringValue
Set the given String as the target.
The transformer method must return a String and can optionally take a String as the first argument. |
java.lang.Class<?> |
typeValue
Set the given class as the target.
The transformer method must return a class and can optionally take a class as the first argument. |
public abstract java.lang.String[] method
print(Ljava/lang/String;)V or print*public abstract int ordinal
public abstract CSlice slice
public abstract boolean optional
true.public abstract boolean nullValue
ACONST_NULL as the target.public abstract int intValue
public abstract long longValue
public abstract float floatValue
public abstract double doubleValue