@Retention(value=RUNTIME)
public @interface Constant
ModifyConstant
injector. Leaving all values unset causes the injection point to match all
constants with the same type as the ModifyConstant handler's return
type.
To match a specific constant, specify the appropriate value for the appropriate argument. Specifying values of different types will cause an error to be raised by the injector.
| Modifier and Type | Optional Element and Description |
|---|---|
java.lang.Class<?> |
classValue
Specify a type literal to match
|
double |
doubleValue
Specify a double constant to match
|
Constant.Condition[] |
expandZeroConditions
Whilst most constants can be located in the compiled method with relative
ease, there exists a special case when a zero is used in a
conditional expression.
|
float |
floatValue
Specify a float constant to match
|
int |
intValue
Specify an integer constant to match, includes byte and short values.
|
boolean |
log |
long |
longValue
Specify a long constant to match
|
boolean |
nullValue
Causes this injector to match ACONST_NULL (null object) literals
|
int |
ordinal
Ordinal offset.
|
java.lang.String |
slice
This specifies the ID of the slice to use for this query.
|
java.lang.String |
stringValue
Specify a String constant to match
|
public abstract boolean nullValue
public abstract int intValue
Special note for referencing 0 (zero) which forms part of
a comparison expression: See the expandZeroConditions() option
below.
public abstract float floatValue
public abstract long longValue
public abstract double doubleValue
public abstract java.lang.String stringValue
public abstract java.lang.Class<?> classValue
public abstract int ordinal
public abstract java.lang.String slice
For more details see the Slice.id()
public abstract Constant.Condition[] expandZeroConditions
if (x >= 0)
This special case occurs because java includes explicit instructions for this type of comparison, and thus the compiled code might look more like this:
if (x.isGreaterThanOrEqualToZero())
Of course if we know that the constant we are searching for is part of a comparison, then we can explicitly search for the isGreaterThanOrEqualToZero and convert it back to the original form in order to redirect it just like any other constant access.
To enable this behaviour, you may specify one or more values for this argument based on the type of expression you wish to expand. Since the Java compiler is wont to compile certain expressions as the inverse of their source-level counterparts (eg. compiling a do this if greater than structure to a ignore this if less than or equal structure); specifying a particular expression type implicitly includes the inverse expression as well.
It is worth noting that the effect on ordinals may be hard to predict, and thus care should be taken to ensure that the selected injection points match the expected locations.
Specifying this option has the following effects: