Java Code Examples for org.objectweb.asm.Opcodes#NEWARRAY
The following examples show how to use
org.objectweb.asm.Opcodes#NEWARRAY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckMethodAdapter.java From Concurnas with MIT License | 6 votes |
@Override public void visitIntInsn(final int opcode, final int operand) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); checkOpcodeMethod(opcode, Method.VISIT_INT_INSN); switch (opcode) { case Opcodes.BIPUSH: checkSignedByte(operand, "Invalid operand"); break; case Opcodes.SIPUSH: checkSignedShort(operand, "Invalid operand"); break; case Opcodes.NEWARRAY: if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) { throw new IllegalArgumentException( "Invalid operand (must be an array type code T_...): " + operand); } break; default: throw new AssertionError(); } super.visitIntInsn(opcode, operand); ++insnCount; }
Example 2
Source File: AllocationMethodAdapter.java From allocation-instrumenter with Apache License 2.0 | 6 votes |
/** * newarray shows up as an instruction taking an int operand (the primitive element type of the * array) so we hook it here. */ @Override public void visitIntInsn(int opcode, int operand) { if (opcode == Opcodes.NEWARRAY) { // instack: ... count // outstack: ... aref if (operand >= 4 && operand <= 11) { super.visitInsn(Opcodes.DUP); // -> stack: ... count count super.visitIntInsn(opcode, operand); // -> stack: ... count aref invokeRecordAllocation(primitiveTypeNames[operand]); // -> stack: ... aref } else { logger.severe( "NEWARRAY called with an invalid operand " + operand + ". Not instrumenting this allocation!"); super.visitIntInsn(opcode, operand); } } else { super.visitIntInsn(opcode, operand); } }
Example 3
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public void visitIntInsn(final int opcode, final int operand) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); checkOpcodeMethod(opcode, Method.VISIT_INT_INSN); switch (opcode) { case Opcodes.BIPUSH: checkSignedByte(operand, "Invalid operand"); break; case Opcodes.SIPUSH: checkSignedShort(operand, "Invalid operand"); break; case Opcodes.NEWARRAY: if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) { throw new IllegalArgumentException( "Invalid operand (must be an array type code T_...): " + operand); } break; default: throw new AssertionError(); } super.visitIntInsn(opcode, operand); ++insnCount; }
Example 4
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public void visitIntInsn(final int opcode, final int operand) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); checkOpcodeMethod(opcode, Method.VISIT_INT_INSN); switch (opcode) { case Opcodes.BIPUSH: checkSignedByte(operand, "Invalid operand"); break; case Opcodes.SIPUSH: checkSignedShort(operand, "Invalid operand"); break; case Opcodes.NEWARRAY: if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) { throw new IllegalArgumentException( "Invalid operand (must be an array type code T_...): " + operand); } break; default: throw new AssertionError(); } super.visitIntInsn(opcode, operand); ++insnCount; }
Example 5
Source File: IntHandler.java From native-obfuscator with GNU General Public License v3.0 | 5 votes |
@Override protected void process(MethodContext context, IntInsnNode node) { props.put("operand", String.valueOf(node.operand)); if (node.getOpcode() == Opcodes.NEWARRAY) { instructionName += "_" + node.operand; } }
Example 6
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static int getIntegerFromInsn(AbstractInsnNode insn) { int opcode = insn.getOpcode(); if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) { return opcode - 3; } else if (insn instanceof IntInsnNode && insn.getOpcode() != Opcodes.NEWARRAY) { return ((IntInsnNode) insn).operand; } else if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof Integer) { return (Integer) ((LdcInsnNode) insn).cst; } throw new RadonException("Unexpected instruction"); }
Example 7
Source File: IntInsnParser.java From Recaf with MIT License | 5 votes |
@Override public IntInsnAST visit(int lineNo, String line) throws ASTParseException { try { String[] trim = line.trim().split("\\s+"); if (trim.length < 2) throw new ASTParseException(lineNo, "Not enough paramters"); int start = line.indexOf(trim[0]); // op OpcodeParser opParser = new OpcodeParser(); opParser.setOffset(line.indexOf(trim[0])); OpcodeAST op = opParser.visit(lineNo, trim[0]); // TODO: For NEWARRAY, using types instead of magic number values would be intuitive String valueStr = trim[1]; int valueStrStart = line.indexOf(valueStr); NumberAST num = null; if (op.getOpcode() == Opcodes.NEWARRAY) { // Type to value DescParser descParser = new DescParser(); descParser.setOffset(line.indexOf(valueStr)); DescAST desc = descParser.visit(lineNo, valueStr); if (!TypeUtil.isPrimitiveDesc(desc.getDesc())) { throw new ASTParseException(lineNo, "Expected primitive descriptor for NEWARRAY"); } num = new NumberAST(lineNo, valueStrStart, TypeUtil.typeToNewArrayArg(Type.getType(desc.getDesc()))); } else { // Value IntParser numParser = new IntParser(); numParser.setOffset(valueStrStart); num = numParser.visit(lineNo, valueStr); } return new IntInsnAST(lineNo, start, op, num); } catch(Exception ex) { throw new ASTParseException(ex, lineNo, "Bad format for int instruction"); } }
Example 8
Source File: IntInsnAST.java From Recaf with MIT License | 5 votes |
@Override public String print() { if (getOpcode().getOpcode() == Opcodes.NEWARRAY) { return getOpcode().print() + " " + TypeUtil.newArrayArgToType(value.getIntValue()).getDescriptor(); } else { return getOpcode().print() + " " + value.print(); } }
Example 9
Source File: AllocateInstrument.java From dacapobench with Apache License 2.0 | 5 votes |
public void visitIntInsn(int opcode, int operand) { if (firstInstruction) addInc(); super.visitIntInsn(opcode, operand); if (opcode == Opcodes.NEWARRAY) { int siteId = getNextSiteId(); addLog(true, siteId); } }
Example 10
Source File: JVMImpl.java From serianalyzer with GNU General Public License v3.0 | 5 votes |
/** * @param opcode * @param operand * @param s */ static void handleJVMIntInsn ( int opcode, int operand, JVMStackState s ) { switch ( opcode ) { case Opcodes.BIPUSH: s.push(new BasicConstant(Type.BYTE_TYPE, operand)); break; case Opcodes.SIPUSH: s.push(new BasicConstant(Type.SHORT_TYPE, operand)); break; case Opcodes.NEWARRAY: s.pop(); s.push(new BasicVariable(makeBasicArrayType(operand), "array", false)); //$NON-NLS-1$ } }
Example 11
Source File: NewArrayStep.java From deobfuscator with Apache License 2.0 | 5 votes |
@Override public AbstractInsnNode tryMatch(InstructionMatcher matcher, AbstractInsnNode now) { if (now.getOpcode() == Opcodes.NEWARRAY && now instanceof IntInsnNode) { if (this.sorts.contains(((IntInsnNode) now).operand)) { return now.getNext(); } } return null; }
Example 12
Source File: MethodVisitorBuilder.java From testability-explorer with Apache License 2.0 | 5 votes |
public void visitIntInsn(int opcode, int operand) { switch (opcode) { case Opcodes.NEWARRAY : newArray(operand, toType(operand)); break; case Opcodes.BIPUSH : loadConstant(operand, JavaType.INT); break; case Opcodes.SIPUSH : loadConstant(operand, JavaType.INT); break; default : throw new UnsupportedOperationException("Unexpected opcode: " + opcode); } }
Example 13
Source File: BytecodeTypeInference.java From bazel with Apache License 2.0 | 4 votes |
@Override public void visitIntInsn(int opcode, int operand) { switch (opcode) { case Opcodes.BIPUSH: case Opcodes.SIPUSH: push(InferredType.INT); break; case Opcodes.NEWARRAY: pop(); switch (operand) { case Opcodes.T_BOOLEAN: pushDescriptor("[Z"); break; case Opcodes.T_CHAR: pushDescriptor("[C"); break; case Opcodes.T_FLOAT: pushDescriptor("[F"); break; case Opcodes.T_DOUBLE: pushDescriptor("[D"); break; case Opcodes.T_BYTE: pushDescriptor("[B"); break; case Opcodes.T_SHORT: pushDescriptor("[S"); break; case Opcodes.T_INT: pushDescriptor("[I"); break; case Opcodes.T_LONG: pushDescriptor("[J"); break; default: throw new RuntimeException("Unhandled operand value: " + operand); } break; default: throw new RuntimeException("Unhandled opcode " + opcode); } super.visitIntInsn(opcode, operand); }
Example 14
Source File: VarOp.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
@Override public void appendInstruction(StringBuilder b) { b.append(" "); switch(opcode) { case Opcodes.ILOAD: b.append("(*SP).type = CN1_TYPE_INT; /* ILOAD */ \n" + " (*SP).data.i = ilocals_"); b.append(var); b.append("_; \n SP++;\n"); return; case Opcodes.LLOAD: b.append("BC_LLOAD("); break; case Opcodes.FLOAD: b.append("BC_FLOAD("); break; case Opcodes.DLOAD: b.append("BC_DLOAD("); break; case Opcodes.ALOAD: b.append("BC_ALOAD("); break; case Opcodes.ISTORE: b.append("BC_ISTORE("); break; case Opcodes.LSTORE: b.append("BC_LSTORE("); break; case Opcodes.FSTORE: b.append("BC_FSTORE("); break; case Opcodes.DSTORE: b.append("BC_DSTORE("); break; case Opcodes.ASTORE: b.append("BC_ASTORE("); break; case Opcodes.RET: b.append("/* RET TODO */"); //b.append("goto label_"); //b.append(var); //b.append("; /* RET */\n"); return; case Opcodes.SIPUSH: case Opcodes.BIPUSH: b.append("PUSH_INT("); break; case Opcodes.NEWARRAY: switch(var) { case 4: // boolean b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_BOOLEAN, sizeof(JAVA_ARRAY_BOOLEAN), 1));\n"); break; case 5: // char b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_CHAR, sizeof(JAVA_ARRAY_CHAR), 1));\n"); break; case 6: // float b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_FLOAT, sizeof(JAVA_ARRAY_FLOAT), 1));\n"); break; case 7: // double b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_DOUBLE, sizeof(JAVA_ARRAY_DOUBLE), 1));\n"); break; case 8: // byte b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_BYTE, sizeof(JAVA_ARRAY_BYTE), 1));\n"); break; case 9: // short b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_SHORT, sizeof(JAVA_ARRAY_SHORT), 1));\n"); break; case 10: // int b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_INT, sizeof(JAVA_ARRAY_INT), 1));\n"); break; case 11: // long b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_LONG, sizeof(JAVA_ARRAY_LONG), 1));\n"); break; } return; default: throw new RuntimeException("Missing opcode: " + opcode); } b.append(var); b.append(");\n"); }
Example 15
Source File: InstructionAdapter.java From JReFrameworker with MIT License | 4 votes |
@Override public void visitIntInsn(final int opcode, final int operand) { 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); break; case Opcodes.T_DOUBLE: newarray(Type.DOUBLE_TYPE); break; default: throw new IllegalArgumentException(); } break; default: throw new IllegalArgumentException(); } }
Example 16
Source File: InstructionAdapter.java From JReFrameworker with MIT License | 4 votes |
@Override public void visitIntInsn(final int opcode, final int operand) { 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); break; case Opcodes.T_DOUBLE: newarray(Type.DOUBLE_TYPE); break; default: throw new IllegalArgumentException(); } break; default: throw new IllegalArgumentException(); } }
Example 17
Source File: InstructionAdapter.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
@Override public void visitIntInsn(final int opcode, final int operand) { 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); break; case Opcodes.T_DOUBLE: newarray(Type.DOUBLE_TYPE); break; default: throw new IllegalArgumentException(); } break; default: throw new IllegalArgumentException(); } }
Example 18
Source File: InstructionAdapter.java From Concurnas with MIT License | 4 votes |
@Override public void visitIntInsn(final int opcode, final int operand) { 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); break; case Opcodes.T_DOUBLE: newarray(Type.DOUBLE_TYPE); break; default: throw new IllegalArgumentException(); } break; default: throw new IllegalArgumentException(); } }