A MethodVisitor with convenient methods to generate code. For example, using this adapter, the class below public class Example { public static void main(String[] args) { System.out.println("Hello world!"); } } can be generated as follows: ClassWriter
| 81 | * @author Prashant Deva |
| 82 | */ |
| 83 | public class GeneratorAdapter extends LocalVariablesSorter { |
| 84 | |
| 85 | private static final String CLASS_DESCRIPTOR = "Ljava/lang/Class;"; |
| 86 | |
| 87 | private static final Type BYTE_TYPE = Type.getObjectType("java/lang/Byte"); |
| 88 | |
| 89 | private static final Type BOOLEAN_TYPE = Type.getObjectType("java/lang/Boolean"); |
| 90 | |
| 91 | private static final Type SHORT_TYPE = Type.getObjectType("java/lang/Short"); |
| 92 | |
| 93 | private static final Type CHARACTER_TYPE = Type.getObjectType("java/lang/Character"); |
| 94 | |
| 95 | private static final Type INTEGER_TYPE = Type.getObjectType("java/lang/Integer"); |
| 96 | |
| 97 | private static final Type FLOAT_TYPE = Type.getObjectType("java/lang/Float"); |
| 98 | |
| 99 | private static final Type LONG_TYPE = Type.getObjectType("java/lang/Long"); |
| 100 | |
| 101 | private static final Type DOUBLE_TYPE = Type.getObjectType("java/lang/Double"); |
| 102 | |
| 103 | private static final Type NUMBER_TYPE = Type.getObjectType("java/lang/Number"); |
| 104 | |
| 105 | private static final Type OBJECT_TYPE = Type.getObjectType("java/lang/Object"); |
| 106 | |
| 107 | private static final Method BOOLEAN_VALUE = Method.getMethod("boolean booleanValue()"); |
| 108 | |
| 109 | private static final Method CHAR_VALUE = Method.getMethod("char charValue()"); |
| 110 | |
| 111 | private static final Method INT_VALUE = Method.getMethod("int intValue()"); |
| 112 | |
| 113 | private static final Method FLOAT_VALUE = Method.getMethod("float floatValue()"); |
| 114 | |
| 115 | private static final Method LONG_VALUE = Method.getMethod("long longValue()"); |
| 116 | |
| 117 | private static final Method DOUBLE_VALUE = Method.getMethod("double doubleValue()"); |
| 118 | |
| 119 | /** Constant for the {@link #math} method. */ |
| 120 | public static final int ADD = Opcodes.IADD; |
| 121 | |
| 122 | /** Constant for the {@link #math} method. */ |
| 123 | public static final int SUB = Opcodes.ISUB; |
| 124 | |
| 125 | /** Constant for the {@link #math} method. */ |
| 126 | public static final int MUL = Opcodes.IMUL; |
| 127 | |
| 128 | /** Constant for the {@link #math} method. */ |
| 129 | public static final int DIV = Opcodes.IDIV; |
| 130 | |
| 131 | /** Constant for the {@link #math} method. */ |
| 132 | public static final int REM = Opcodes.IREM; |
| 133 | |
| 134 | /** Constant for the {@link #math} method. */ |
| 135 | public static final int NEG = Opcodes.INEG; |
| 136 | |
| 137 | /** Constant for the {@link #math} method. */ |
| 138 | public static final int SHL = Opcodes.ISHL; |
| 139 | |
| 140 | /** Constant for the {@link #math} method. */ |
nothing calls this directly
no test coverage detected