Java Code Examples for org.objectweb.asm.Type#VOID_TYPE
The following examples show how to use
org.objectweb.asm.Type#VOID_TYPE .
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: GeneratorAdapter.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
/** * Generates the instructions to box the top stack value. This value is replaced by its boxed * equivalent on top of the stack. * * @param type the type of the top stack value. */ public void box(final Type type) { if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { return; } if (type == Type.VOID_TYPE) { push((String) null); } else { Type boxedType = getBoxedType(type); newInstance(boxedType); if (type.getSize() == 2) { // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o dupX2(); dupX2(); pop(); } else { // p -> po -> opo -> oop -> o dupX1(); swap(); } invokeConstructor(boxedType, new Method("<init>", Type.VOID_TYPE, new Type[] {type})); } }
Example 2
Source File: Remapper.java From Concurnas with MIT License | 6 votes |
/** * Returns the given method descriptor, with its argument and return type descriptors remapped * with {@link #mapDesc(String)}. * * @param methodDescriptor a method descriptor. * @return the given method descriptor, with its argument and return type descriptors remapped * with {@link #mapDesc(String)}. */ public String mapMethodDesc(final String methodDescriptor) { if ("()V".equals(methodDescriptor)) { return methodDescriptor; } StringBuilder stringBuilder = new StringBuilder("("); for (Type argumentType : Type.getArgumentTypes(methodDescriptor)) { stringBuilder.append(mapType(argumentType).getDescriptor()); } Type returnType = Type.getReturnType(methodDescriptor); if (returnType == Type.VOID_TYPE) { stringBuilder.append(")V"); } else { stringBuilder.append(')').append(mapType(returnType).getDescriptor()); } return stringBuilder.toString(); }
Example 3
Source File: JVMStackState.java From serianalyzer with GNU General Public License v3.0 | 6 votes |
/** * @param o1 * @param found * @return */ private static Type getType ( BaseType o1, Set<BaseType> found ) { if ( o1 == null ) { return Type.VOID_TYPE; } if ( found.contains(o1) ) { throw new IllegalArgumentException("Recursion"); //$NON-NLS-1$ } found.add(o1); if ( o1 instanceof SimpleType ) { return ( (SimpleType) o1 ).getType(); } else if ( o1 instanceof MultiAlternatives ) { return ( (MultiAlternatives) o1 ).getCommonType(); } else { return Type.VOID_TYPE; } }
Example 4
Source File: AsmDeltaSpikeProxyClassGenerator.java From deltaspike with Apache License 2.0 | 6 votes |
private static void defineDefaultConstructor(ClassWriter cw, Type proxyType, Type superType) { GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, new Method("<init>", Type.VOID_TYPE, new Type[]{ }), null, null, cw); mg.visitCode(); // invoke super constructor mg.loadThis(); mg.invokeConstructor(superType, Method.getMethod("void <init> ()")); mg.returnValue(); mg.endMethod(); mg.visitEnd(); }
Example 5
Source File: Redirection.java From Stark with Apache License 2.0 | 6 votes |
/** * Adds the instructions to do a generic redirection. * <p> * Note that the generated bytecode does not have a direct translation to code, but as an * example, the following code block gets inserted. * <code> * if ($starkChange != null) { * $starkChange.access$dispatch($name, new object[] { arg0, ... argsN }) * $anyCodeInsertedbyRestore * } * $originalMethodBody *</code> * @param mv the method visitor to add the instructions to. * @param change the local variable containing the alternate implementation. */ void redirect(GeneratorAdapter mv, int change) { // code to check if a new implementation of the current class is available. Label l0 = new Label(); mv.loadLocal(change); mv.visitJumpInsn(Opcodes.IFNULL, l0); doRedirect(mv, change); // Return if (type == Type.VOID_TYPE) { mv.pop(); } else { ByteCodeUtils.unbox(mv, type); } mv.returnValue(); // jump label for classes without any new implementation, just invoke the original // method implementation. mv.visitLabel(l0); }
Example 6
Source File: MultiAlternatives.java From serianalyzer with GNU General Public License v3.0 | 6 votes |
/** * * @return a common type for the alternatives */ public Type getCommonType () { Type common = null; for ( BaseType object : this.getAlternatives() ) { if ( object == null ) { return Type.VOID_TYPE; } Type t = null; if ( object instanceof SimpleType ) { t = ( (SimpleType) object ).getType(); } if ( t != null && ( common == null || common.equals(t) ) ) { common = t; continue; } return Type.VOID_TYPE; } return common; }
Example 7
Source File: ABICompilerMethodVisitor.java From AVM with MIT License | 5 votes |
private void checkArgumentsAndReturnType() { for (Type type : Type.getArgumentTypes(this.methodDescriptor)) { if(!ABIUtils.isAllowedType(type)) { throw new ABICompilerException( type.getClassName() + " is not an allowed parameter type", methodName); } } Type returnType = Type.getReturnType(methodDescriptor); if(!ABIUtils.isAllowedType(returnType) && returnType != Type.VOID_TYPE) { throw new ABICompilerException( returnType.getClassName() + " is not an allowed return type", methodName); } }
Example 8
Source File: SourceInterpreter.java From JReFrameworker with MIT License | 5 votes |
@Override public SourceValue newValue(final Type type) { if (type == Type.VOID_TYPE) { return null; } return new SourceValue(type == null ? 1 : type.getSize()); }
Example 9
Source File: HierarchyMethods.java From maple-ir with GNU General Public License v3.0 | 5 votes |
/** * Two types are congruent if they are primitive and the same, or if one is a subclass of another. * @param a type A * @param b type B * @return true if type A and B are congruent */ private boolean areTypesCongruent(Type a, Type b) { if (a.equals(b)) { return true; } boolean eArr = a.getSort() == Type.ARRAY; boolean aArr = b.getSort() == Type.ARRAY; if(eArr != aArr) { return false; } if(eArr) { a = a.getElementType(); b = b.getElementType(); } if(TypeUtils.isPrimitive(a) || TypeUtils.isPrimitive(b)) { return false; } if(a == Type.VOID_TYPE || b == Type.VOID_TYPE) { return false; } ClassNode cnA = app.findClassNode(a.getInternalName()); ClassNode cnB = app.findClassNode(b.getInternalName()); ClassTree tree = app.getClassTree(); return tree.getAllParents(cnB).contains(cnA) || tree.getAllParents(cnA).contains(cnB); }
Example 10
Source File: EmitUtils.java From cglib with Apache License 2.0 | 5 votes |
public static void load_class(CodeEmitter e, Type type) { if (TypeUtils.isPrimitive(type)) { if (type == Type.VOID_TYPE) { throw new IllegalArgumentException("cannot load void type"); } e.getstatic(TypeUtils.getBoxedType(type), "TYPE", Constants.TYPE_CLASS); } else { load_class_helper(e, type); } }
Example 11
Source File: MulticastDelegate.java From cglib with Apache License 2.0 | 5 votes |
private void emitProxy(ClassEmitter ce, final MethodInfo method) { int modifiers = Constants.ACC_PUBLIC; if ((method.getModifiers() & Constants.ACC_VARARGS) == Constants.ACC_VARARGS) { modifiers |= Constants.ACC_VARARGS; } final CodeEmitter e = EmitUtils.begin_method(ce, method, modifiers); Type returnType = method.getSignature().getReturnType(); final boolean returns = returnType != Type.VOID_TYPE; Local result = null; if (returns) { result = e.make_local(returnType); e.zero_or_null(returnType); e.store_local(result); } e.load_this(); e.super_getfield("targets", Constants.TYPE_OBJECT_ARRAY); final Local result2 = result; EmitUtils.process_array(e, Constants.TYPE_OBJECT_ARRAY, new ProcessArrayCallback() { public void processElement(Type type) { e.checkcast(Type.getType(iface)); e.load_args(); e.invoke(method); if (returns) { e.store_local(result2); } } }); if (returns) { e.load_local(result); } e.return_value(); e.end_method(); }
Example 12
Source File: ConstInterpreter.java From pro with GNU General Public License v3.0 | 5 votes |
@Override public ConstValue newValue(Type type) { if (type == Type.VOID_TYPE) { return null; } return type == null? ConstValue.ONE_SLOT: ConstValue.slotForSize(type.getSize()); }
Example 13
Source File: SourceInterpreter.java From Concurnas with MIT License | 5 votes |
@Override public SourceValue newValue(final Type type) { if (type == Type.VOID_TYPE) { return null; } return new SourceValue(type == null ? 1 : type.getSize()); }
Example 14
Source File: ExpressionArraySet.java From datakernel with Apache License 2.0 | 5 votes |
@Override public Type load(Context ctx) { GeneratorAdapter g = ctx.getGeneratorAdapter(); Type arrayType = array.load(ctx); position.load(ctx); newElement.load(ctx); g.arrayStore(getType(arrayType.getDescriptor().substring(1))); return Type.VOID_TYPE; }
Example 15
Source File: GeneratorAdapter.java From Concurnas with MIT License | 5 votes |
/** * Generates the instructions to box the top stack value using Java 5's valueOf() method. This * value is replaced by its boxed equivalent on top of the stack. * * @param type the type of the top stack value. */ public void valueOf(final Type type) { if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { return; } if (type == Type.VOID_TYPE) { push((String) null); } else { Type boxedType = getBoxedType(type); invokeStatic(boxedType, new Method("valueOf", boxedType, new Type[] {type})); } }
Example 16
Source File: AdviceAdapter.java From Concurnas with MIT License | 5 votes |
private void doVisitMethodInsn(final int opcode, final String descriptor) { if (isConstructor && !superClassConstructorCalled) { for (Type argumentType : Type.getArgumentTypes(descriptor)) { popValue(); if (argumentType.getSize() == 2) { popValue(); } } switch (opcode) { case INVOKEINTERFACE: case INVOKEVIRTUAL: popValue(); break; case INVOKESPECIAL: Object value = popValue(); if (value == UNINITIALIZED_THIS && !superClassConstructorCalled) { superClassConstructorCalled = true; onMethodEnter(); } break; default: break; } Type returnType = Type.getReturnType(descriptor); if (returnType != Type.VOID_TYPE) { pushValue(OTHER); if (returnType.getSize() == 2) { pushValue(OTHER); } } } }
Example 17
Source File: SourceInterpreter.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
@Override public SourceValue newValue(final Type type) { if (type == Type.VOID_TYPE) { return null; } return new SourceValue(type == null ? 1 : type.getSize()); }
Example 18
Source File: SourceInterpreter.java From JReFrameworker with MIT License | 5 votes |
@Override public SourceValue newValue(final Type type) { if (type == Type.VOID_TYPE) { return null; } return new SourceValue(type == null ? 1 : type.getSize()); }
Example 19
Source File: StackInfo.java From copper-engine with Apache License 2.0 | 4 votes |
public void pushStack(Type t) { if (t != Type.VOID_TYPE) stack.add(t); }
Example 20
Source File: SerianalyzerMethodVisitor.java From serianalyzer with GNU General Public License v3.0 | 4 votes |
/** * {@inheritDoc} * * @see org.objectweb.asm.MethodVisitor#visitInvokeDynamicInsn(java.lang.String, java.lang.String, * org.objectweb.asm.Handle, java.lang.Object[]) */ @Override public void visitInvokeDynamicInsn ( String name, String desc, Handle bsm, Object... bsmArgs ) { if ( bsm.getTag() == Opcodes.H_INVOKESTATIC && ( bsm.getName().equals("metafactory") || //$NON-NLS-1$ bsm.getName().equals("altMetafactory") ) //$NON-NLS-1$ && bsm.getOwner().equals("java/lang/invoke/LambdaMetafactory") && bsmArgs.length >= 2 ) { //$NON-NLS-1$ Handle h = (Handle) bsmArgs[ 1 ]; Type[] handleArgs = Type.getArgumentTypes(h.getDesc()); Type[] formalArgs = Type.getArgumentTypes(desc); List<BaseType> args = this.stack.pop(formalArgs.length); boolean tainted = checkTainted(formalArgs, args); String className = Type.getObjectType(h.getOwner()).getClassName(); boolean isStatic = h.getTag() == Opcodes.H_INVOKESTATIC; MethodReference r = new MethodReference(className, false, h.getName(), isStatic, h.getDesc()); this.foundRefs.add(r); if ( tainted ) { if ( !Arrays.equals(handleArgs, formalArgs) ) { if ( this.log.isDebugEnabled() ) { this.log.debug("Mismatch between formal args and handle args in " + this.ref + " " + name); //$NON-NLS-1$ //$NON-NLS-2$ this.log.debug("Handle arguments are " + Arrays.toString(handleArgs)); //$NON-NLS-1$ this.log.debug("Formal arguments are " + Arrays.toString(formalArgs)); //$NON-NLS-1$ this.log.debug("BSM arguments are " + Arrays.toString(bsmArgs)); //$NON-NLS-1$ } this.parent.getAnalyzer().getState().getBench().unhandledLambda(); r.setArgumentTypes(setupTainting(r, Opcodes.INVOKEDYNAMIC, Collections.EMPTY_LIST, null, r, handleArgs)); } else { r.setArgumentTypes(setupTainting(r, Opcodes.INVOKEDYNAMIC, args, null, r, handleArgs)); } this.parent.getAnalyzer().getState().getBench().taintedCall(); if ( this.log.isDebugEnabled() ) { this.log.debug(String.format( "In %s need to check lambda %s %s::%s %s (%s): %s", //$NON-NLS-1$ this.ref, bsm.getTag(), bsm.getOwner(), bsm.getName(), desc, bsm.getDesc(), Arrays.toString(bsmArgs))); this.log.debug(String.format("In %s need to check lambda %s::%s (%s)", this.ref, h.getOwner(), h.getName(), h.getDesc())); //$NON-NLS-1$ this.log.debug("Arguments " + args); //$NON-NLS-1$ } boolean unsafeCall = this.parent.getAnalyzer().checkMethodCall(r, Collections.singleton(this.ref), true, false); if ( !unsafeCall ) { this.log.debug("Call is safe"); //$NON-NLS-1$ } this.foundCall = true; } else { this.parent.getAnalyzer().getState().traceCalls(r, Collections.singleton(this.ref)); this.parent.getAnalyzer().getState().getBench().untaintedCall(); } Type returnType = Type.getReturnType(desc); if ( returnType != Type.VOID_TYPE ) { this.stack.push(new BasicVariable(returnType, "return " + r, tainted)); //$NON-NLS-1$ } } else { this.log.warn("Unsupported dynamic call in " + this.ref); //$NON-NLS-1$ this.log.warn(String.format( "In %s need to check lambda %s %s::%s %s (%s): %s", //$NON-NLS-1$ this.ref, bsm.getTag(), bsm.getOwner(), bsm.getName(), desc, bsm.getDesc(), Arrays.toString(bsmArgs))); } super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs); }