Annotation 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAvailable options for theexpandZeroConditions()setting. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?> Specify a type literal to matchdoubleSpecify a double constant to matchWhilst 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.floatSpecify a float constant to matchintSpecify an integer constant to match, includes byte and short values.booleanlongSpecify a long constant to matchbooleanCauses this injector to match ACONST_NULL (null object) literalsintOrdinal offset.This specifies the ID of the slice to use for this query.Specify a String constant to match
-
Element Details
-
nullValue
boolean nullValueCauses this injector to match ACONST_NULL (null object) literals- Returns:
- true to match null
- Default:
false
-
intValue
int intValueSpecify an integer constant to match, includes byte and short values.Special note for referencing 0 (zero) which forms part of a comparison expression: See the
expandZeroConditions()option below.- Returns:
- integer value to match
- Default:
0
-
floatValue
float floatValueSpecify a float constant to match- Returns:
- float value to match
- Default:
0.0f
-
longValue
long longValueSpecify a long constant to match- Returns:
- long value to match
- Default:
0L
-
doubleValue
double doubleValueSpecify a double constant to match- Returns:
- double value to match
- Default:
0.0
-
stringValue
String stringValueSpecify a String constant to match- Returns:
- string value to match
- Default:
""
-
classValue
Class<?> classValueSpecify a type literal to match- Returns:
- type literal to match
- Default:
java.lang.Object.class
-
ordinal
int ordinalOrdinal offset. Many InjectionPoints will return every opcode matching their criteria, specifying ordinal allows a particular opcode to be identified from the returned list. The default value of -1 does not alter the behaviour and returns all matching opcodes. Specifying a value of 0 or higher returns only the requested opcode (if one exists: for example specifying an ordinal of 4 when only 2 opcodes are matched by the InjectionPoint is not going to work particularly well!)- Returns:
- ordinal value for supported InjectionPoint types
- Default:
-1
-
slice
String sliceThis specifies the ID of the slice to use for this query.For more details see the
Slice.id()- Returns:
- the slice identifier, or empty string to use the default slice
- Default:
""
-
expandZeroConditions
Constant.Condition[] expandZeroConditionsWhilst 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. For example: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:
- Matching conditional opcodes in the target method are identified for injection candidacy.
- An intValue of 0 is implied and does not need to be explicitly defined.
- However, explicitly specifying an intValue of 0 will cause this selector to also match explicit 0 constants in the method body as well.
- Default:
{}
-
log
boolean log- Returns:
- true to enable verbose debug logging for this injection point
- Default:
false
-