Java Code Examples for org.objectweb.asm.Opcodes#INSTANCEOF
The following examples show how to use
org.objectweb.asm.Opcodes#INSTANCEOF .
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: InstructionAdapter.java From Concurnas with MIT License | 6 votes |
@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(); } }
Example 2
Source File: StackHelper.java From zelixkiller with GNU General Public License v3.0 | 6 votes |
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; }
Example 3
Source File: InstructionAdapter.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
@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(); } }
Example 4
Source File: InstructionAdapter.java From JReFrameworker with MIT License | 6 votes |
@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(); } }
Example 5
Source File: InstructionAdapter.java From JReFrameworker with MIT License | 6 votes |
@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(); } }
Example 6
Source File: BytecodeTypeInference.java From bazel with Apache License 2.0 | 6 votes |
@Override public void visitTypeInsn(int opcode, String type) { String descriptor = convertToDescriptor(type); switch (opcode) { case Opcodes.NEW: // This should be UNINITIALIZED(label). Okay for type inference. pushDescriptor(descriptor); break; case Opcodes.ANEWARRAY: pop(); pushDescriptor('[' + descriptor); break; case Opcodes.CHECKCAST: pop(); pushDescriptor(descriptor); break; case Opcodes.INSTANCEOF: pop(); push(InferredType.INT); break; default: throw new RuntimeException("Unhandled opcode " + opcode); } super.visitTypeInsn(opcode, type); }
Example 7
Source File: JVMImpl.java From serianalyzer with GNU General Public License v3.0 | 5 votes |
/** * @param opcode * @param type * @param s */ static void handleJVMTypeInsn ( int opcode, String type, JVMStackState s ) { BaseType o; switch ( opcode ) { case Opcodes.NEW: s.push(new ObjectReferenceConstant(false, Type.getObjectType(type), type.replace('/', '.'))); break; case Opcodes.ANEWARRAY: s.pop(); if ( type.charAt(0) == '[' ) { s.push(new BasicVariable(Type.getObjectType("[" + type), "array", false)); //$NON-NLS-1$//$NON-NLS-2$ } else { s.push(new BasicVariable(Type.getObjectType("[L" + type + ";"), "array", false)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } break; case Opcodes.CHECKCAST: if ( log.isDebugEnabled() ) { log.debug("Checkcast " + type); //$NON-NLS-1$ } o = s.pop(); if ( o != null ) { o.addAlternativeType(Type.getObjectType(type)); s.push(o); } else { s.clear(); } break; case Opcodes.INSTANCEOF: o = s.pop(); if ( o != null ) { o.addAlternativeType(Type.getObjectType(type)); } s.push(new BasicConstant(Type.BOOLEAN_TYPE, "typeof " + o + " = " + type, ! ( o != null ) || o.isTainted())); //$NON-NLS-1$ //$NON-NLS-2$ break; } }
Example 8
Source File: ModifyConstantInjector.java From Mixin with MIT License | 5 votes |
private void injectTypeConstantModifier(Target target, TypeInsnNode typeNode) { int opcode = typeNode.getOpcode(); if (opcode != Opcodes.INSTANCEOF) { throw new InvalidInjectionException(this.info, String.format("%s annotation does not support %s insn in %s in %s", this.annotationType, Bytecode.getOpcodeName(opcode), target, this)); } this.injectAtInstanceOf(target, typeNode); }
Example 9
Source File: InstanceofFrame.java From deobfuscator with Apache License 2.0 | 4 votes |
public InstanceofFrame(Frame check) { super(Opcodes.INSTANCEOF); this.check = check; this.check.children.add(this); }
Example 10
Source File: TypeInstruction.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
@Override public void appendInstruction(StringBuilder b, List<Instruction> l) { type = type.replace('.', '_').replace('/', '_').replace('$', '_'); b.append(" "); switch(opcode) { case Opcodes.NEW: b.append("PUSH_POINTER(__NEW_"); b.append(type); b.append("(threadStateData)); /* NEW */\n"); break; case Opcodes.ANEWARRAY: if(type.startsWith("[")) { int dim = 2; String t = type.substring(1); while(t.startsWith("[")) { t = t.substring(1); dim++; } b.append(" SP--;\n PUSH_POINTER(allocArray(threadStateData, (*SP).data.i, &class_array"); b.append(dim); b.append("__"); b.append(actualType); b.append(", sizeof(JAVA_OBJECT), "); b.append(dim); b.append("));\n SP[-1].data.o->__codenameOneParentClsReference = &class_array"); b.append(dim); b.append("__"); b.append(actualType); b.append("; /* ANEWARRAY multi */\n"); break; } b.append("SP--;\n PUSH_POINTER(__NEW_ARRAY_"); b.append(actualType); b.append("(threadStateData, SP[0].data.i));\n"); break; case Opcodes.CHECKCAST: b.append("BC_CHECKCAST("); b.append(type); b.append(");\n"); break; case Opcodes.INSTANCEOF: int pos = type.indexOf('['); if(pos > -1) { int count = 1; while(type.charAt(pos + 1) == '[') { count++; pos++; } b.append("BC_INSTANCEOF(cn1_array_"); b.append(count); b.append("_id_"); b.append(actualType); } else { b.append("BC_INSTANCEOF(cn1_class_id_"); b.append(actualType); } b.append(");\n"); break; } }
Example 11
Source File: RedirectInjector.java From Mixin with MIT License | 4 votes |
@Override protected void inject(Target target, InjectionNode node) { if (!this.preInject(node)) { return; } if (node.isReplaced()) { throw new UnsupportedOperationException("Redirector target failure for " + this.info); } if (node.getCurrentTarget() instanceof MethodInsnNode) { this.checkTargetForNode(target, node, RestrictTargetLevel.ALLOW_ALL); this.injectAtInvoke(target, node); return; } if (node.getCurrentTarget() instanceof FieldInsnNode) { this.checkTargetForNode(target, node, RestrictTargetLevel.ALLOW_ALL); this.injectAtFieldAccess(target, node); return; } if (node.getCurrentTarget() instanceof TypeInsnNode) { int opcode = node.getCurrentTarget().getOpcode(); if (opcode == Opcodes.NEW) { if (!this.isStatic && target.isStatic) { throw new InvalidInjectionException(this.info, String.format( "non-static callback method %s has a static target which is not supported", this)); } this.injectAtConstructor(target, node); return; } else if (opcode == Opcodes.INSTANCEOF) { this.checkTargetModifiers(target, false); this.injectAtInstanceOf(target, node); return; } } throw new InvalidInjectionException(this.info, String.format("%s annotation on is targetting an invalid insn in %s in %s", this.annotationType, target, this)); }