Example usage for org.objectweb.asm.commons InstructionAdapter OBJECT_TYPE

List of usage examples for org.objectweb.asm.commons InstructionAdapter OBJECT_TYPE

Introduction

In this page you can find the example usage for org.objectweb.asm.commons InstructionAdapter OBJECT_TYPE.

Prototype

Type OBJECT_TYPE

To view the source code for org.objectweb.asm.commons InstructionAdapter OBJECT_TYPE.

Click Source Link

Document

The type of the java.lang.Object class.

Usage

From source file:com.github.jasmo.obfuscate.ScrambleStrings.java

License:Open Source License

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());//from  w  w w  . java  2 s . co  m
    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);
    }
}