org.objectweb.asm.tree.IincInsnNode#org.objectweb.asm.tree.TypeInsnNode源码实例Demo

下面列出了org.objectweb.asm.tree.IincInsnNode#org.objectweb.asm.tree.TypeInsnNode 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: grappa   文件: ImplicitActionsConverter.java
private boolean isStoredIntoObjectArray(final InstructionGraphNode node)
{
    // is the single dependent an AASTORE instruction ?
    final AbstractInsnNode insn = node.getInstruction();
    if (insn.getOpcode() != AASTORE)
        return false;

    // Does this instruction store into an array of Object ?
    final List<InstructionGraphNode> dependents = getDependents(node);

    // an AASTORE instruction should have exactly one dependent
    Preconditions.checkState(dependents.size() == 1);

    final AbstractInsnNode newArrayInsn
        = dependents.get(0).getInstruction();
    // which should be a n ANEWARRAY instruction
    Preconditions.checkState(newArrayInsn.getOpcode() == ANEWARRAY);

    final String desc = ((TypeInsnNode) newArrayInsn).desc;
    return CodegenUtils.p(Object.class).equals(desc);
}
 
源代码2 项目: native-obfuscator   文件: TypeHandler.java
@Override
protected void process(MethodContext context, TypeInsnNode node) {
    props.put("desc", node.desc);

    int classId = context.getCachedClasses().getId(node.desc);
    context.output.append(String.format("if (!cclasses[%d] || env->IsSameObject(cclasses[%d], NULL)) { cclasses_mtx[%d].lock(); if (!cclasses[%d] || env->IsSameObject(cclasses[%d], NULL)) { if (jclass clazz = %s) { cclasses[%d] = (jclass) env->NewWeakGlobalRef(clazz); env->DeleteLocalRef(clazz); } } cclasses_mtx[%d].unlock(); %s } ",
            classId,
            classId,
            classId,
            classId,
            classId,
            MethodProcessor.getClassGetter(context, node.desc),
            classId,
            classId,
            trimmedTryCatchBlock));

    props.put("desc_ptr", context.getCachedClasses().getPointer(node.desc));
}
 
源代码3 项目: zelixkiller   文件: StackHelper.java
public InsnValue casting(TypeInsnNode tin, InsnValue value) {
	switch (tin.getOpcode()) {
	case Opcodes.CHECKCAST:
		return value;
	case Opcodes.INSTANCEOF:
		if (value.getValue() == null) {
			return InsnValue.intValue(0);
		}
		Class<?> clazz = value.getValue().getClass();
		try {
			Class<?> compared = Class.forName(Type.getType(tin.desc).getClassName());
			return InsnValue.intValue(clazz.isAssignableFrom(compared));
		} catch (ClassNotFoundException e) {
		}
		return InsnValue.intValue(0);
	}

	return null;
}
 
源代码4 项目: bazel   文件: LambdaClassFixer.java
private void removeLastAllocation() {
  AbstractInsnNode insn = instructions.getLast();
  while (insn != null && insn.getPrevious() != null) {
    AbstractInsnNode prev = insn.getPrevious();
    if (prev.getOpcode() == Opcodes.NEW
        && insn.getOpcode() == Opcodes.DUP
        && ((TypeInsnNode) prev).desc.equals(lambdaInfo.methodReference().getOwner())) {
      instructions.remove(prev);
      instructions.remove(insn);
      return;
    }
    insn = prev;
  }
  throw new IllegalStateException(
      "Couldn't find allocation to rewrite ::new reference " + lambdaInfo.methodReference());
}
 
源代码5 项目: grappa   文件: ConstructorGenerator.java
private static void createNewInstanceMethod(final ParserClassNode classNode)
{
    // TODO: replace with Code{Block,GenUtils}
    final String desc = "()L" + Type.getType(BaseParser.class)
        .getInternalName() + ';';
    final MethodNode method = new MethodNode(ACC_PUBLIC, "newInstance",
        desc, null, null);
    final InsnList instructions = method.instructions;

    instructions.add(new TypeInsnNode(NEW, classNode.name));
    instructions.add(new InsnNode(DUP));
    instructions.add(new MethodInsnNode(INVOKESPECIAL, classNode.name,
        "<init>", "()V", false));
    instructions.add(new InsnNode(ARETURN));

    classNode.methods.add(method);
}
 
源代码6 项目: pinpoint   文件: ASMMethodVariables.java
AbstractInsnNode findInitConstructorInstruction() {
    int nested = 0;
    for (AbstractInsnNode insnNode = this.methodNode.instructions.getFirst(); insnNode != null; insnNode = insnNode.getNext()) {
        if (insnNode instanceof TypeInsnNode) {
            if (insnNode.getOpcode() == Opcodes.NEW) {
                // new object().
                nested++;
            }
        } else if (insnNode instanceof MethodInsnNode) {
            final MethodInsnNode methodInsnNode = (MethodInsnNode) insnNode;
            if (methodInsnNode.getOpcode() == Opcodes.INVOKESPECIAL && methodInsnNode.name.equals("<init>")) {
                if (--nested < 0) {
                    // find this() or super().
                    return insnNode.getNext();
                }
            }
        }
    }

    return null;
}
 
源代码7 项目: Diorite   文件: TransformerInjectTracker.java
private AbstractInsnNode skipCheckCastBackwards(AbstractInsnNode node)
{
    // skip possible (?) ALOAD 0 if not static
    if (! this.isStatic && (node instanceof VarInsnNode) && (node.getOpcode() == ALOAD) && (((VarInsnNode) node).var == 0))
    {
        node = node.getPrevious();
    }

    // skip possible check cast
    if ((node instanceof TypeInsnNode) && (node.getOpcode() == CHECKCAST))
    {
        node = node.getPrevious();
    }

    // skip possible (?) ALOAD 0 if not static
    if (! this.isStatic && (node instanceof VarInsnNode) && (node.getOpcode() == ALOAD) && (((VarInsnNode) node).var == 0))
    {
        node = node.getPrevious();
    }
    return node;
}
 
源代码8 项目: NOVA-Core   文件: InstructionComparator.java
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
	if (node1.getOpcode() != node2.getOpcode()) {
		return false;
	}

	switch (node2.getType()) {
		case VAR_INSN:
			return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2);
		case TYPE_INSN:
			return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2);
		case FIELD_INSN:
			return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2);
		case METHOD_INSN:
			return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2);
		case LDC_INSN:
			return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2);
		case IINC_INSN:
			return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2);
		case INT_INSN:
			return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2);
		default:
			return true;
	}
}
 
源代码9 项目: NOVA-Core   文件: InstructionComparator.java
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
	if (node1.getOpcode() != node2.getOpcode()) {
		return false;
	}

	switch (node2.getType()) {
		case VAR_INSN:
			return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2);
		case TYPE_INSN:
			return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2);
		case FIELD_INSN:
			return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2);
		case METHOD_INSN:
			return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2);
		case LDC_INSN:
			return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2);
		case IINC_INSN:
			return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2);
		case INT_INSN:
			return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2);
		default:
			return true;
	}
}
 
源代码10 项目: NOVA-Core   文件: InstructionComparator.java
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
	if (node1.getOpcode() != node2.getOpcode()) {
		return false;
	}

	switch (node2.getType()) {
		case VAR_INSN:
			return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2);
		case TYPE_INSN:
			return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2);
		case FIELD_INSN:
			return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2);
		case METHOD_INSN:
			return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2);
		case LDC_INSN:
			return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2);
		case IINC_INSN:
			return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2);
		case INT_INSN:
			return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2);
		default:
			return true;
	}
}
 
源代码11 项目: instrumentation   文件: Instrumentator.java
private void addGetMethodInvocation(InsnList il) {
    il.add(TreeInstructions.getPushInstruction(this.methodArguments.length));
    il.add(new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Class"));
    int parameterClassesIndex = getFistAvailablePosition();
    il.add(new VarInsnNode(Opcodes.ASTORE, parameterClassesIndex));
    this.mn.maxLocals++;
    for (int i = 0; i < this.methodArguments.length; i++) {
        il.add(new VarInsnNode(Opcodes.ALOAD, parameterClassesIndex));
        il.add(TreeInstructions.getPushInstruction(i));
        il.add(TreeInstructions.getClassReferenceInstruction(methodArguments[i], cn.version & 0xFFFF));
        il.add(new InsnNode(Opcodes.AASTORE));
    }
    il.add(TreeInstructions.getClassConstantReference(this.classType, cn.version & 0xFFFF));
    il.add(new LdcInsnNode(this.mn.name));
    il.add(new VarInsnNode(Opcodes.ALOAD, parameterClassesIndex));
    il.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
            "org/brutusin/instrumentation/utils/Helper", "getSource",
            "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/Object;", false));
}
 
源代码12 项目: coroutines   文件: GenericGenerators.java
/**
 * Calls a constructor with a set of arguments. After execution the stack should have an extra item pushed on it: the object that was
 * created by this constructor.
 * @param constructor constructor to call
 * @param args constructor argument instruction lists -- each instruction list must leave one item on the stack of the type expected
 * by the constructor
 * @return instructions to invoke a constructor
 * @throws NullPointerException if any argument is {@code null} or array contains {@code null}
 * @throws IllegalArgumentException if the length of {@code args} doesn't match the number of parameters in {@code constructor}
 */
public static InsnList construct(Constructor<?> constructor, InsnList ... args) {
    Validate.notNull(constructor);
    Validate.notNull(args);
    Validate.noNullElements(args);
    Validate.isTrue(constructor.getParameterCount() == args.length);
    
    
    InsnList ret = new InsnList();
    
    Type clsType = Type.getType(constructor.getDeclaringClass());
    Type methodType = Type.getType(constructor);
    
    ret.add(new TypeInsnNode(Opcodes.NEW, clsType.getInternalName()));
    ret.add(new InsnNode(Opcodes.DUP));
    for (InsnList arg : args) {
        ret.add(arg);
    }
    ret.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, clsType.getInternalName(), "<init>", methodType.getDescriptor(), false));
    
    return ret;
}
 
源代码13 项目: Mixin   文件: AccessorGeneratorObjectFactory.java
@Override
public MethodNode generate() {
    int returnSize = this.returnType.getSize();
    // size includes return size x2 since we immediately DUP the value to invoke the ctor on it
    int size = Bytecode.getArgsSize(this.argTypes) + (returnSize * 2);
    MethodNode method = this.createMethod(size, size);
    
    String className = this.info.getClassNode().name;
    method.instructions.add(new TypeInsnNode(Opcodes.NEW, className));
    method.instructions.add(new InsnNode(returnSize == 1 ? Opcodes.DUP : Opcodes.DUP2));
    Bytecode.loadArgs(this.argTypes, method.instructions, 0);
    method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, className, Constants.CTOR, this.targetMethod.desc, false));
    method.instructions.add(new InsnNode(Opcodes.ARETURN));

    return method;
}
 
源代码14 项目: bazel   文件: NioBufferRefConverterTest.java
@Test
public void methodOfNioBufferWithCovariantTypes_afterDesugar(
    @AsmNode(className = "NioBufferInvocations", memberName = "getByteBufferPosition", round = 1)
        MethodNode after) {
  ImmutableList<AbstractInsnNode> methodInvocations =
      Arrays.stream(after.instructions.toArray())
          .filter(insnNode -> insnNode.getType() == METHOD_INSN)
          .collect(toImmutableList());

  assertThat(methodInvocations).hasSize(1);
  MethodInsnNode methodInsnNode = (MethodInsnNode) Iterables.getOnlyElement(methodInvocations);

  assertThat(methodInsnNode.owner).isEqualTo("java/nio/ByteBuffer");
  assertThat(methodInsnNode.name).isEqualTo("position");
  assertThat(methodInsnNode.desc).isEqualTo("(I)Ljava/nio/Buffer;");

  TypeInsnNode typeInsnNode = (TypeInsnNode) methodInsnNode.getNext();
  assertThat(typeInsnNode.getOpcode()).isEqualTo(Opcodes.CHECKCAST);
  assertThat(typeInsnNode.desc).isEqualTo("java/nio/ByteBuffer");

  assertThat(typeInsnNode.getNext().getOpcode()).isEqualTo(Opcodes.ARETURN);
}
 
源代码15 项目: Bats   文件: ReplacingInterpreter.java
@Override
public BasicValue newOperation(final AbstractInsnNode insn) throws AnalyzerException {
  if (insn.getOpcode() == Opcodes.NEW) {
    final TypeInsnNode t = (TypeInsnNode) insn;

    // if this is for a holder class, we'll replace it
    final ValueHolderIden iden = HOLDERS.get(t.desc);
    if (iden != null) {
      return ReplacingBasicValue.create(Type.getObjectType(t.desc), iden, index++, valueList);
    }
  }

  return super.newOperation(insn);
}
 
源代码16 项目: Cafebabe   文件: OpcodeFormatting.java
public static String toString(AbstractInsnNode ain) {
	String s = getOpcodeText(ain.getOpcode());
	switch (ain.getType()) {
	case AbstractInsnNode.FIELD_INSN:
		FieldInsnNode fin = (FieldInsnNode) ain;
		return s + " " + fin.owner + "#" + fin.name + " " + fin.desc;
	case AbstractInsnNode.METHOD_INSN:
		MethodInsnNode min = (MethodInsnNode) ain;
		return s + " " + min.owner + "#" + min.name + min.desc;
	case AbstractInsnNode.VAR_INSN:
		VarInsnNode vin = (VarInsnNode) ain;
		return s + " " + vin.var;
	case AbstractInsnNode.TYPE_INSN:
		TypeInsnNode tin = (TypeInsnNode) ain;
		return s + " " + tin.desc;
	case AbstractInsnNode.MULTIANEWARRAY_INSN:
		MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain;
		return s + " " + mnin.dims + " " + mnin.desc;
	case AbstractInsnNode.JUMP_INSN:
		JumpInsnNode jin = (JumpInsnNode) ain;
		return s + " " + getIndex(jin.label);
	case AbstractInsnNode.LDC_INSN:
		LdcInsnNode ldc = (LdcInsnNode) ain;
		return s + " " + ldc.cst.toString();
	case AbstractInsnNode.INT_INSN:
		return s + " " + getIntValue(ain);
	case AbstractInsnNode.IINC_INSN:
		IincInsnNode iinc = (IincInsnNode) ain;
		return s + " " + iinc.var + " +" + iinc.incr;
	case AbstractInsnNode.FRAME:
		FrameNode fn = (FrameNode) ain;
		return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size();
	case AbstractInsnNode.LABEL:
		LabelNode ln = (LabelNode) ain;
		return s + " " + getIndex(ln);
	}
	return s;
}
 
源代码17 项目: GregTech   文件: ObfMapping.java
public AbstractInsnNode toInsn(int opcode) {
    if (isClass()) {
        return new TypeInsnNode(opcode, s_owner);
    } else if (isMethod()) {
        return new MethodInsnNode(opcode, s_owner, s_name, s_desc, opcode == Opcodes.INVOKEINTERFACE);
    } else {
        return new FieldInsnNode(opcode, s_owner, s_name, s_desc);
    }
}
 
源代码18 项目: maple-ir   文件: TypeInsnNodeSerializer.java
@Override
  public TypeInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
      int opcode = jsonObject.get("opcode").getAsInt();
      String desc  = jsonObject.get("desc").getAsString();
      return new TypeInsnNode(opcode, desc);
  }
 
源代码19 项目: maple-ir   文件: TypeInsnNodeSerializer.java
@Override
public JsonElement serialize(TypeInsnNode src, Type typeOfSrc, JsonSerializationContext context) {
	JsonObject object = new JsonObject();
    object.add("opcode", context.serialize(src.getOpcode()));
    object.add("desc", context.serialize(src.desc));
    return object;
}
 
源代码20 项目: maple-ir   文件: InstructionPattern.java
/**
 * Translate a single {@link AbstractInsnNode} to an {@link InstructionFilter}.
 * @param ain Instruction to convert.
 * @return A filter an an equivilent to the inputted instruction.
 */
public static InstructionFilter translate(AbstractInsnNode ain) {
	if (ain instanceof LdcInsnNode) {
		return new LdcInstructionFilter(((LdcInsnNode) ain).cst);
	} else if (ain instanceof TypeInsnNode) {
		return new TypeInstructionFilter(ain.getOpcode(), ((TypeInsnNode) ain).desc);
	} else if (ain instanceof FieldInsnNode) {
		return new FieldInstructionFilter(ain.getOpcode(), ((FieldInsnNode) ain).owner, ((FieldInsnNode) ain).name, ((FieldInsnNode) ain).desc);
	} else if (ain instanceof MethodInsnNode) {
		return new MethodInstructionFilter(ain.getOpcode(), ((MethodInsnNode) ain).owner, ((MethodInsnNode) ain).name, ((MethodInsnNode) ain).desc);
	} else if (ain instanceof VarInsnNode) {
		return new VarInstructionFilter(ain.getOpcode(), ((VarInsnNode) ain).var);
	} else if (ain instanceof InsnNode) {
		return new InsnInstructionFilter(ain.getOpcode());
	} else if (ain instanceof IincInsnNode) {
		return new IincInstructionFilter(((IincInsnNode) ain).incr, ((IincInsnNode) ain).var);
	} else if (ain instanceof JumpInsnNode) {
		return new JumpInstructionFilter(ain.getOpcode());
	} else if (ain instanceof LabelNode) {
		return InstructionFilter.ACCEPT_ALL; // TODO: Cache labels and check. // TODO: That's a fucking stupid idea.
	} else if (ain instanceof MultiANewArrayInsnNode) {
		return new MultiANewArrayInstructionFilter(((MultiANewArrayInsnNode) ain).desc, ((MultiANewArrayInsnNode) ain).dims);
	} else if(ain instanceof IntInsnNode) {
		return new IntInstructionFilter((IntInsnNode) ain);
	} else {
		return InstructionFilter.ACCEPT_ALL;
	}
}
 
源代码21 项目: maple-ir   文件: TypeInstructionFilter.java
@Override
public boolean accept(AbstractInsnNode t) {
	if (!(t instanceof TypeInsnNode))
		return false;
	TypeInsnNode tin = (TypeInsnNode) t;
	return opcodeFilter.accept(tin) && descFilter.accept(tin.desc);
}
 
源代码22 项目: zelixkiller   文件: CorrelationMapper.java
/**
 * Get's a member's class types from its description. Best for methods.
 * 
 * @param member
 * @param map
 * @return
 */
private static List<MappedClass> getTypesFromMember(MappedMember member, Map<String, MappedClass> map) {
	List<String> names = RegexUtils.matchDescriptionClasses(member.getDesc());
	if (member.isMethod()) {
		for (AbstractInsnNode ain : member.getMethodNode().instructions.toArray()) {
			if (ain.getType() == AbstractInsnNode.METHOD_INSN) {
				MethodInsnNode min = (MethodInsnNode) ain;
				names.addAll(RegexUtils.matchDescriptionClasses(min.desc));
				names.add(min.owner);
			} else if (ain.getType() == AbstractInsnNode.FIELD_INSN) {
				FieldInsnNode fin = (FieldInsnNode) ain;
				names.addAll(RegexUtils.matchDescriptionClasses(fin.desc));
				names.add(fin.owner);
			} else if (ain.getType() == AbstractInsnNode.TYPE_INSN) {
				TypeInsnNode tin = (TypeInsnNode) ain;
				names.addAll(RegexUtils.matchDescriptionClasses(tin.desc));
			} else if (ain.getType() == AbstractInsnNode.LDC_INSN) {
				LdcInsnNode ldc = (LdcInsnNode) ain;
				if (ldc.cst instanceof Type) {
					Type t = (Type) ldc.cst;
					names.add(t.getClassName().replace(".", "/"));
				}
			}
		}
	}
	if (names.size() == 0) {
		return null;
	}
	List<MappedClass> classes = new ArrayList<MappedClass>();
	for (String name : names) {
		if (!map.containsKey(name)) {
			continue;
		}
		classes.add(map.get(name));
	}
	return classes;
}
 
源代码23 项目: zelixkiller   文件: OpUtils.java
public static String toString(AbstractInsnNode ain) {
	String s = getOpcodeText(ain.getOpcode());
	switch (ain.getType()) {
	case AbstractInsnNode.FIELD_INSN:
		FieldInsnNode fin = (FieldInsnNode) ain;
		return s + " " + fin.owner + "#" + fin.name + " " + fin.desc;
	case AbstractInsnNode.METHOD_INSN:
		MethodInsnNode min = (MethodInsnNode) ain;
		return s + " " + min.owner + "#" + min.name + min.desc;
	case AbstractInsnNode.VAR_INSN:
		VarInsnNode vin = (VarInsnNode) ain;
		return s + " " + vin.var;
	case AbstractInsnNode.TYPE_INSN:
		TypeInsnNode tin = (TypeInsnNode) ain;
		return s + " " + tin.desc;
	case AbstractInsnNode.JUMP_INSN:
		JumpInsnNode jin = (JumpInsnNode) ain;
		return s + " " + getIndex(jin.label);
	case AbstractInsnNode.LDC_INSN:
		LdcInsnNode ldc = (LdcInsnNode) ain;
		return s + " " + ldc.cst.toString();
	case AbstractInsnNode.INT_INSN:
		return s + " " + getIntValue(ain);
	case AbstractInsnNode.IINC_INSN:
		IincInsnNode iinc = (IincInsnNode) ain;
		return s + " " + iinc.var + " +" + iinc.incr;
	case AbstractInsnNode.FRAME:
		FrameNode fn = (FrameNode) ain;
		return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size();
	case AbstractInsnNode.LABEL:
		LabelNode ln = (LabelNode) ain;
		return s + " " + getIndex(ln);
	}
	return s;
}
 
源代码24 项目: nuls-v2   文件: Checkcast.java
public static void checkcast(Frame frame) {
    TypeInsnNode typeInsnNode = frame.typeInsnNode();
    String desc = typeInsnNode.desc;
    VariableType variableType = VariableType.valueOf(desc);
    ObjectRef objectRef = frame.operandStack.popRef();

    if (objectRef == null || Instanceof.instanceof_(objectRef, variableType, frame)) {
        frame.operandStack.pushRef(objectRef);
    } else {
        frame.throwClassCastException();
    }

    //Log.opcode(frame.getCurrentOpCode(), objectRef, desc);
}
 
源代码25 项目: nuls-v2   文件: Instanceof.java
public static void instanceof_(Frame frame) {
    TypeInsnNode typeInsnNode = frame.typeInsnNode();
    VariableType variableType = VariableType.valueOf(typeInsnNode.desc);
    ObjectRef objectRef = frame.operandStack.popRef();
    boolean result = instanceof_(objectRef, variableType, frame);
    frame.operandStack.pushInt(result ? 1 : 0);

    //Log.result(frame.getCurrentOpCode(), result, objectRef, variableType);
}
 
源代码26 项目: radon   文件: AntiDebug.java
private InsnList generateCheck() {
    LabelNode notDebugLabel = new LabelNode();
    InsnList insnList = new InsnList();
    insnList.add(createIsDebugList());
    insnList.add(new JumpInsnNode(IFEQ, notDebugLabel));

    if (RandomUtils.getRandomBoolean()) {
        if (getMessage() != null) {
            insnList.add(new FieldInsnNode(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"));
            insnList.add(new LdcInsnNode(getMessage()));
            insnList.add(new MethodInsnNode(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false));
        }
        if (RandomUtils.getRandomBoolean()) {
            insnList.add(new LdcInsnNode(RandomUtils.getRandomInt()));
            insnList.add(new MethodInsnNode(INVOKESTATIC, "java/lang/System", "exit", "(I)V", false));
        } else {
            insnList.add(new MethodInsnNode(INVOKESTATIC, "java/lang/Runtime", "getRuntime", "()Ljava/lang/Runtime;", false));
            insnList.add(new LdcInsnNode(RandomUtils.getRandomInt()));
            insnList.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/Runtime", "halt", "(I)V", false));
        }
    } else {
        String message = getMessage();
        if (message == null)
            message = randomString();

        insnList.add(new TypeInsnNode(NEW, "java/lang/RuntimeException"));
        insnList.add(new InsnNode(DUP));
        insnList.add(new LdcInsnNode(message));
        insnList.add(new MethodInsnNode(INVOKESPECIAL, "java/lang/RuntimeException", "<init>", "(Ljava/lang/String;)V", false));
        insnList.add(new InsnNode(ATHROW));
    }
    insnList.add(notDebugLabel);
    return insnList;
}
 
源代码27 项目: radon   文件: Expiration.java
private InsnList createExpirationInstructions() {
    InsnList insns = new InsnList();
    LabelNode injectedLabel = new LabelNode(new Label());

    insns.add(new TypeInsnNode(NEW, "java/util/Date"));
    insns.add(new InsnNode(DUP));
    insns.add(new MethodInsnNode(INVOKESPECIAL, "java/util/Date", "<init>", "()V", false));
    insns.add(new TypeInsnNode(NEW, "java/util/Date"));
    insns.add(new InsnNode(DUP));
    insns.add(new LdcInsnNode(getExpires()));
    insns.add(new MethodInsnNode(INVOKESPECIAL, "java/util/Date", "<init>", "(J)V", false));
    insns.add(new MethodInsnNode(INVOKEVIRTUAL, "java/util/Date", "after", "(Ljava/util/Date;)Z", false));
    insns.add(new JumpInsnNode(IFEQ, injectedLabel));
    insns.add(new TypeInsnNode(NEW, "java/lang/Throwable"));
    insns.add(new InsnNode(DUP));
    insns.add(new LdcInsnNode(getMessage()));
    if (isInjectJOptionPaneEnabled()) {
        insns.add(new InsnNode(DUP));
        insns.add(new InsnNode(ACONST_NULL));
        insns.add(new InsnNode(SWAP));
        insns.add(new MethodInsnNode(INVOKESTATIC, "javax/swing/JOptionPane", "showMessageDialog",
                "(Ljava/awt/Component;Ljava/lang/Object;)V", false));
    }
    insns.add(new MethodInsnNode(INVOKESPECIAL, "java/lang/Throwable", "<init>", "(Ljava/lang/String;)V", false));
    insns.add(new InsnNode(ATHROW));
    insns.add(injectedLabel);

    return insns;
}
 
源代码28 项目: nuls   文件: Checkcast.java
public static void checkcast(Frame frame) {
    TypeInsnNode typeInsnNode = frame.typeInsnNode();
    String desc = typeInsnNode.desc;
    VariableType variableType = VariableType.valueOf(desc);
    ObjectRef objectRef = frame.operandStack.popRef();

    if (objectRef == null || Instanceof.instanceof_(objectRef, variableType, frame)) {
        frame.operandStack.pushRef(objectRef);
    } else {
        frame.throwClassCastException();
    }

    //Log.opcode(frame.getCurrentOpCode(), objectRef, desc);
}
 
源代码29 项目: nuls   文件: Instanceof.java
public static void instanceof_(Frame frame) {
    TypeInsnNode typeInsnNode = frame.typeInsnNode();
    VariableType variableType = VariableType.valueOf(typeInsnNode.desc);
    ObjectRef objectRef = frame.operandStack.popRef();
    boolean result = instanceof_(objectRef, variableType, frame);
    frame.operandStack.pushInt(result ? 1 : 0);

    //Log.result(frame.getCurrentOpCode(), result, objectRef, variableType);
}
 
源代码30 项目: ForgeHax   文件: ASMHelper.java
public static InsnList newInstance(String name, String desc, @Nullable InsnList args) {
  InsnList list = new InsnList();
  list.add(new TypeInsnNode(NEW, name));
  list.add(new InsnNode(DUP));
  if (args != null) {
    list.add(args);
  }
  list.add(new MethodInsnNode(INVOKESPECIAL, name, "<init>", desc, false));
  return list;
}