switch (opcode) { case Opcodes.BIPUSH: iconst(operand); break; case Opcodes.SIPUSH: iconst(operand); break; case Opcodes.NEWARRAY: switch (operand) { case Opcodes.T_BOOLEAN: newarray(Type.BOOLEAN_TYPE); break; case Opcodes.T_CHAR: newarray(Type.CHAR_TYPE); break; case Opcodes.T_BYTE: newarray(Type.BYTE_TYPE); break; case Opcodes.T_SHORT: newarray(Type.SHORT_TYPE); break; case Opcodes.T_INT: newarray(Type.INT_TYPE); break; case Opcodes.T_FLOAT: newarray(Type.FLOAT_TYPE); break; case Opcodes.T_LONG: newarray(Type.LONG_TYPE);
@Override public void visitFieldInsn( final int opcode, final String owner, final String name, final String descriptor) { switch (opcode) { case Opcodes.GETSTATIC: getstatic(owner, name, descriptor); break; case Opcodes.PUTSTATIC: putstatic(owner, name, descriptor); break; case Opcodes.GETFIELD: getfield(owner, name, descriptor); break; case Opcodes.PUTFIELD: putfield(owner, name, descriptor); break; default: throw new IllegalArgumentException(); } }
@Override public void visitTypeInsn(final int opcode, final String type) { Type objectType = Type.getObjectType(type); switch (opcode) { case Opcodes.NEW: anew(objectType); break; case Opcodes.ANEWARRAY: newarray(objectType); break; case Opcodes.CHECKCAST: checkcast(objectType); break; case Opcodes.INSTANCEOF: instanceOf(objectType); break; default: throw new IllegalArgumentException(); } }
switch (opcode) { case Opcodes.NOP: nop(); break; case Opcodes.ACONST_NULL: aconst(null); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_4: case Opcodes.ICONST_5: iconst(opcode - Opcodes.ICONST_0); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: lconst((long) (opcode - Opcodes.LCONST_0)); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: fconst((float) (opcode - Opcodes.FCONST_0)); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: dconst((double) (opcode - Opcodes.DCONST_0)); break; case Opcodes.IALOAD: aload(Type.INT_TYPE); break;
iconst((Integer) value); } else if (value instanceof Byte) { iconst(((Byte) value).intValue()); } else if (value instanceof Character) { iconst(((Character) value).charValue()); } else if (value instanceof Short) { iconst(((Short) value).intValue()); } else if (value instanceof Boolean) { iconst(((Boolean) value).booleanValue() ? 1 : 0); } else if (value instanceof Float) { fconst((Float) value); } else if (value instanceof Long) { lconst((Long) value); } else if (value instanceof Double) { dconst((Double) value); } else if (value instanceof String) { aconst(value); } else if (value instanceof Type) { tconst((Type) value); } else if (value instanceof Handle) { hconst((Handle) value); } else if (value instanceof ConstantDynamic) { cconst((ConstantDynamic) value); } else { throw new IllegalArgumentException();
private void createStaticConstructor(ClassNode owner) throws UnsupportedEncodingException { MethodNode original = BytecodeHelper.getMethod(owner, "<clinit>", "()V"); MethodVisitor mv = owner.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); // generate instructions InstructionAdapter builder = new InstructionAdapter(mv); builder.iconst(stringList.size()); builder.newarray(Type.getType(String.class)); for (int i = 0; i < stringList.size(); i++) { builder.dup(); builder.iconst(i); builder.aconst(Base64.getEncoder().encodeToString(stringList.get(i).getBytes("UTF-8"))); builder.astore(InstructionAdapter.OBJECT_TYPE); } builder.putstatic(unscrambleClass.name, FIELD_NAME, "[Ljava/lang/String;"); // merge with original if it exists if (original != null) { // original should already end with RETURN owner.methods.remove(original); original.instructions.accept(builder); } else { builder.areturn(Type.VOID_TYPE); } }
switch (opcode) { case Opcodes.NOP: nop(); break; case Opcodes.ACONST_NULL: aconst(null); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_4: case Opcodes.ICONST_5: iconst(opcode - Opcodes.ICONST_0); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: lconst((long) (opcode - Opcodes.LCONST_0)); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: fconst((float) (opcode - Opcodes.FCONST_0)); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: dconst((double) (opcode - Opcodes.DCONST_0)); break; case Opcodes.IALOAD: aload(Type.INT_TYPE); break;
iconst((Integer) value); } else if (value instanceof Byte) { iconst(((Byte) value).intValue()); } else if (value instanceof Character) { iconst(((Character) value).charValue()); } else if (value instanceof Short) { iconst(((Short) value).intValue()); } else if (value instanceof Boolean) { iconst(((Boolean) value).booleanValue() ? 1 : 0); } else if (value instanceof Float) { fconst((Float) value); } else if (value instanceof Long) { lconst((Long) value); } else if (value instanceof Double) { dconst((Double) value); } else if (value instanceof String) { aconst(value); } else if (value instanceof Type) { tconst((Type) value); } else if (value instanceof Handle) { hconst((Handle) value); } else if (value instanceof ConstantDynamic) { cconst((ConstantDynamic) value); } else { throw new IllegalArgumentException();
@Override public void visitTypeInsn(final int opcode, final String type) { Type t = Type.getObjectType(type); switch (opcode) { case Opcodes.NEW: anew(t); break; case Opcodes.ANEWARRAY: newarray(t); break; case Opcodes.CHECKCAST: checkcast(t); break; case Opcodes.INSTANCEOF: instanceOf(t); break; default: throw new IllegalArgumentException(); } }
switch (opcode) { case Opcodes.NOP: nop(); break; case Opcodes.ACONST_NULL: aconst(null); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_4: case Opcodes.ICONST_5: iconst(opcode - Opcodes.ICONST_0); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: lconst((long) (opcode - Opcodes.LCONST_0)); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: fconst((float) (opcode - Opcodes.FCONST_0)); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: dconst((double) (opcode - Opcodes.DCONST_0)); break; case Opcodes.IALOAD: aload(Type.INT_TYPE); break;
if (cst instanceof Integer) { int val = ((Integer) cst).intValue(); iconst(val); } else if (cst instanceof Byte) { int val = ((Byte) cst).intValue(); iconst(val); } else if (cst instanceof Character) { int val = ((Character) cst).charValue(); iconst(val); } else if (cst instanceof Short) { int val = ((Short) cst).intValue(); iconst(val); } else if (cst instanceof Boolean) { int val = ((Boolean) cst).booleanValue() ? 1 : 0; iconst(val); } else if (cst instanceof Float) { float val = ((Float) cst).floatValue(); fconst(val); } else if (cst instanceof Long) { long val = ((Long) cst).longValue(); lconst(val); } else if (cst instanceof Double) { double val = ((Double) cst).doubleValue(); dconst(val); } else if (cst instanceof String) { aconst(cst); } else if (cst instanceof Type) { tconst((Type) cst); } else if (cst instanceof Handle) {
@Override public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) { switch (opcode) { case Opcodes.GETSTATIC: getstatic(owner, name, desc); break; case Opcodes.PUTSTATIC: putstatic(owner, name, desc); break; case Opcodes.GETFIELD: getfield(owner, name, desc); break; case Opcodes.PUTFIELD: putfield(owner, name, desc); break; default: throw new IllegalArgumentException(); } }
@Override public void visitTypeInsn(final int opcode, final String type) { Type objectType = Type.getObjectType(type); switch (opcode) { case Opcodes.NEW: anew(objectType); break; case Opcodes.ANEWARRAY: newarray(objectType); break; case Opcodes.CHECKCAST: checkcast(objectType); break; case Opcodes.INSTANCEOF: instanceOf(objectType); break; default: throw new IllegalArgumentException(); } }
switch (opcode) { case Opcodes.BIPUSH: iconst(operand); break; case Opcodes.SIPUSH: iconst(operand); break; case Opcodes.NEWARRAY: switch (operand) { case Opcodes.T_BOOLEAN: newarray(Type.BOOLEAN_TYPE); break; case Opcodes.T_CHAR: newarray(Type.CHAR_TYPE); break; case Opcodes.T_BYTE: newarray(Type.BYTE_TYPE); break; case Opcodes.T_SHORT: newarray(Type.SHORT_TYPE); break; case Opcodes.T_INT: newarray(Type.INT_TYPE); break; case Opcodes.T_FLOAT: newarray(Type.FLOAT_TYPE); break; case Opcodes.T_LONG: newarray(Type.LONG_TYPE);
switch (opcode) { case Opcodes.NOP: nop(); break; case Opcodes.ACONST_NULL: aconst(null); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_4: case Opcodes.ICONST_5: iconst(opcode - Opcodes.ICONST_0); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: lconst(opcode - Opcodes.LCONST_0); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: fconst(opcode - Opcodes.FCONST_0); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: dconst(opcode - Opcodes.DCONST_0); break; case Opcodes.IALOAD: aload(Type.INT_TYPE); break;
iconst((Integer) value); } else if (value instanceof Byte) { iconst(((Byte) value).intValue()); } else if (value instanceof Character) { iconst(((Character) value).charValue()); } else if (value instanceof Short) { iconst(((Short) value).intValue()); } else if (value instanceof Boolean) { iconst(((Boolean) value).booleanValue() ? 1 : 0); } else if (value instanceof Float) { fconst((Float) value); } else if (value instanceof Long) { lconst((Long) value); } else if (value instanceof Double) { dconst((Double) value); } else if (value instanceof String) { aconst(value); } else if (value instanceof Type) { tconst((Type) value); } else if (value instanceof Handle) { hconst((Handle) value); } else if (value instanceof ConstantDynamic) { cconst((ConstantDynamic) value); } else { throw new IllegalArgumentException();
@Override public void visitFieldInsn( final int opcode, final String owner, final String name, final String descriptor) { switch (opcode) { case Opcodes.GETSTATIC: getstatic(owner, name, descriptor); break; case Opcodes.PUTSTATIC: putstatic(owner, name, descriptor); break; case Opcodes.GETFIELD: getfield(owner, name, descriptor); break; case Opcodes.PUTFIELD: putfield(owner, name, descriptor); break; default: throw new IllegalArgumentException(); } }
@Override public void visitTypeInsn(final int opcode, final String type) { Type objectType = Type.getObjectType(type); switch (opcode) { case Opcodes.NEW: anew(objectType); break; case Opcodes.ANEWARRAY: newarray(objectType); break; case Opcodes.CHECKCAST: checkcast(objectType); break; case Opcodes.INSTANCEOF: instanceOf(objectType); break; default: throw new IllegalArgumentException(); } }
switch (opcode) { case Opcodes.BIPUSH: iconst(operand); break; case Opcodes.SIPUSH: iconst(operand); break; case Opcodes.NEWARRAY: switch (operand) { case Opcodes.T_BOOLEAN: newarray(Type.BOOLEAN_TYPE); break; case Opcodes.T_CHAR: newarray(Type.CHAR_TYPE); break; case Opcodes.T_BYTE: newarray(Type.BYTE_TYPE); break; case Opcodes.T_SHORT: newarray(Type.SHORT_TYPE); break; case Opcodes.T_INT: newarray(Type.INT_TYPE); break; case Opcodes.T_FLOAT: newarray(Type.FLOAT_TYPE); break; case Opcodes.T_LONG: newarray(Type.LONG_TYPE);
@Override public void visitFieldInsn( final int opcode, final String owner, final String name, final String descriptor) { switch (opcode) { case Opcodes.GETSTATIC: getstatic(owner, name, descriptor); break; case Opcodes.PUTSTATIC: putstatic(owner, name, descriptor); break; case Opcodes.GETFIELD: getfield(owner, name, descriptor); break; case Opcodes.PUTFIELD: putfield(owner, name, descriptor); break; default: throw new IllegalArgumentException(); } }