/** * Creates a public abstract method. * * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * @param exceptions a list of the exception types * @param declaring the class to which the created method is added. * * @see CtMethod#CtMethod(CtClass,String,CtClass[],CtClass) */ public static CtMethod abstractMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws NotFoundException { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); cm.setExceptionTypes(exceptions); return cm; }
/** * Creates a public abstract method. * * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * @param exceptions a list of the exception types * @param declaring the class to which the created method is added. * * @see CtMethod#CtMethod(CtClass,String,CtClass[],CtClass) */ public static CtMethod abstractMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws NotFoundException { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); cm.setExceptionTypes(exceptions); return cm; }
= new CtMethod(returnType, mname, parameters, declaring); cm.setModifiers(modifiers); cm.setExceptionTypes(exceptions); cm.setBody(body); return cm;
= new CtMethod(returnType, mname, parameters, declaring); cm.setModifiers(modifiers); cm.setExceptionTypes(exceptions); cm.setBody(body); return cm;
public static CtMethod wrapped(CtClass returnType, String mname, CtClass[] parameterTypes, CtClass[] exceptionTypes, CtMethod body, ConstParameter constParam, CtClass declaring) throws CannotCompileException { CtMethod mt = new CtMethod(returnType, mname, parameterTypes, declaring); mt.setModifiers(body.getModifiers()); try { mt.setExceptionTypes(exceptionTypes); } catch (NotFoundException e) { throw new CannotCompileException(e); } Bytecode code = makeBody(declaring, declaring.getClassFile2(), body, parameterTypes, returnType, constParam); MethodInfo minfo = mt.getMethodInfo2(); minfo.setCodeAttribute(code.toCodeAttribute()); // a stack map has been already created. return mt; }
public static CtMethod wrapped(CtClass returnType, String mname, CtClass[] parameterTypes, CtClass[] exceptionTypes, CtMethod body, ConstParameter constParam, CtClass declaring) throws CannotCompileException { CtMethod mt = new CtMethod(returnType, mname, parameterTypes, declaring); mt.setModifiers(body.getModifiers()); try { mt.setExceptionTypes(exceptionTypes); } catch (NotFoundException e) { throw new CannotCompileException(e); } Bytecode code = makeBody(declaring, declaring.getClassFile2(), body, parameterTypes, returnType, constParam); MethodInfo minfo = mt.getMethodInfo2(); minfo.setCodeAttribute(code.toCodeAttribute()); // a stack map has been already created. return mt; }
method.setModifiers(mod | Modifier.ABSTRACT); method.setExceptionTypes(tlist); return method;
method.setModifiers(mod | Modifier.ABSTRACT); method.setExceptionTypes(tlist); return method;
/** * Creates a public abstract method. * * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * @param exceptions a list of the exception types * @param declaring the class to which the created method is added. * * @see CtMethod#CtMethod(CtClass,String,CtClass[],CtClass) */ public static CtMethod abstractMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws NotFoundException { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); cm.setExceptionTypes(exceptions); return cm; }
/** * Creates a public abstract method. * * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * @param exceptions a list of the exception types * @param declaring the class to which the created method is added. * * @see CtMethod#CtMethod(CtClass,String,CtClass[],CtClass) */ public static CtMethod abstractMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws NotFoundException { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); cm.setExceptionTypes(exceptions); return cm; }
/** * Creates a public abstract method. * * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * @param exceptions a list of the exception types * @param declaring the class to which the created method is added. * * @see CtMethod#CtMethod(CtClass,String,CtClass[],CtClass) */ public static CtMethod abstractMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws NotFoundException { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); cm.setExceptionTypes(exceptions); return cm; }
/** * Creates a public abstract method. * * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * @param exceptions a list of the exception types * @param declaring the class to which the created method is added. * * @see CtMethod#CtMethod(CtClass,String,CtClass[],CtClass) */ public static CtMethod abstractMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws NotFoundException { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); cm.setExceptionTypes(exceptions); return cm; }
/** * Creates a public abstract method. * * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * @param exceptions a list of the exception types * @param declaring the class to which the created method is added. * * @see CtMethod#CtMethod(CtClass,String,CtClass[],CtClass) */ public static CtMethod abstractMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws NotFoundException { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); cm.setExceptionTypes(exceptions); return cm; }
private void overrideReadObject(CtClass classToModify) throws NotFoundException, CannotCompileException { CtClass[] paramTypes = new CtClass[]{GwtClassPool.getCtClass(ObjectInputStream.class)}; CtMethod readObjectMethod = new CtMethod(CtClass.voidType, "readObject", paramTypes, classToModify); readObjectMethod.setModifiers(Modifier.PRIVATE); // add exception types CtClass classNotFoundException = GwtClassPool.getCtClass(ClassNotFoundException.class); CtClass ioException = GwtClassPool.getCtClass(IOException.class); readObjectMethod.setExceptionTypes(new CtClass[]{classNotFoundException, ioException}); // set body (call static readObject(Serializable, ObjectInputStream) readObjectMethod.setBody(callStaticReadObject()); classToModify.addMethod(readObjectMethod); } }
private void overrideReadObject(CtClass classToModify) throws NotFoundException, CannotCompileException { CtClass[] paramTypes = new CtClass[]{GwtClassPool.getCtClass(ObjectInputStream.class)}; CtMethod readObjectMethod = new CtMethod(CtClass.voidType, "readObject", paramTypes, classToModify); readObjectMethod.setModifiers(Modifier.PRIVATE); // add exception types CtClass classNotFoundException = GwtClassPool.getCtClass(ClassNotFoundException.class); CtClass ioException = GwtClassPool.getCtClass(IOException.class); readObjectMethod.setExceptionTypes(new CtClass[]{classNotFoundException, ioException}); // set body (call static readObject(Serializable, ObjectInputStream) readObjectMethod.setBody(callStaticReadObject()); classToModify.addMethod(readObjectMethod); } }
public MethodFab addMethod(int modifiers, MethodSignature ms, String body) { if (_methods.get(ms) != null) throw new ApplicationRuntimeException(EnhanceMessages.duplicateMethodInClass(ms, this)); if (body.indexOf("isWrapperFor") > 0 || body.indexOf("unwrap") > 0) return new MethodFabImpl(null, ms, null, "{ throw new UnsupportedOperationException(\"Method not implemented\"); }"); CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(modifiers); method.setBody(body); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod(ms, getCtClass(), ex), ex); } // Return a MethodFab so the caller can add catches. MethodFab result = new MethodFabImpl(getSource(), ms, method, body); _methods.put(ms, result); return result; }
public void addMethod(MethodSignature ms) { CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
public void addMethod(MethodSignature ms) { CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
public static CtMethod wrapped(CtClass returnType, String mname, CtClass[] parameterTypes, CtClass[] exceptionTypes, CtMethod body, ConstParameter constParam, CtClass declaring) throws CannotCompileException { CtMethod mt = new CtMethod(returnType, mname, parameterTypes, declaring); mt.setModifiers(body.getModifiers()); try { mt.setExceptionTypes(exceptionTypes); } catch (NotFoundException e) { throw new CannotCompileException(e); } Bytecode code = makeBody(declaring, declaring.getClassFile2(), body, parameterTypes, returnType, constParam); mt.getMethodInfo2().setCodeAttribute(code.toCodeAttribute()); return mt; }
public static CtMethod wrapped(CtClass returnType, String mname, CtClass[] parameterTypes, CtClass[] exceptionTypes, CtMethod body, ConstParameter constParam, CtClass declaring) throws CannotCompileException { CtMethod mt = new CtMethod(returnType, mname, parameterTypes, declaring); mt.setModifiers(body.getModifiers()); try { mt.setExceptionTypes(exceptionTypes); } catch (NotFoundException e) { throw new CannotCompileException(e); } Bytecode code = makeBody(declaring, declaring.getClassFile2(), body, parameterTypes, returnType, constParam); mt.getMethodInfo2().setCodeAttribute(code.toCodeAttribute()); return mt; }