Annotation Type Constant
-
@Target({}) @Retention(RUNTIME) public @interface ConstantAnnotation for specifying the injection point for anModifyConstantinjector. Leaving all values unset causes the injection point to match all constants with the same type as theModifyConstanthandler'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.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>classValueSpecify a type literal to matchdoubledoubleValueSpecify a double constant to matchConstant.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.floatfloatValueSpecify a float constant to matchintintValueSpecify an integer constant to match, includes byte and short values.booleanloglonglongValueSpecify a long constant to matchbooleannullValueCauses this injector to match ACONST_NULL (null object) literalsintordinalOrdinal offset.java.lang.StringsliceThis specifies the ID of the slice to use for this query.java.lang.StringstringValueSpecify a String constant to match
-
-
-
-
intValue
int intValue
Specify 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
-
-
-
ordinal
int ordinal
Ordinal 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
java.lang.String slice
This 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[] 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. 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:
- {}
-
-