private static boolean isThrowsSqlException(CtMethod method) { try { for (CtClass clazz : method.getExceptionTypes()) { if (clazz.getSimpleName().equals("SQLException")) { return true; } } } catch (NotFoundException e) { // fall thru } return false; }
parameterTypes, m.getExceptionTypes(), "{ return super.invoke(" + lazyMethodReferenceInit + ", " + oneWay + ", " + methodId + ", $args); }", cc);
m.getParameterTypes(), m.getExceptionTypes(), body, ConstParameter.integer(identifier), clazz);
m.getParameterTypes(), m.getExceptionTypes(), body, ConstParameter.integer(identifier), clazz);
@Override public int getNumberOfSpecifiedExceptions() { try { return ctMethod.getExceptionTypes().length; } catch (NotFoundException e) { throw new RuntimeException(e); } }
@Override public int getNumberOfSpecifiedExceptions() { try { return ctMethod.getExceptionTypes().length; } catch (NotFoundException e) { throw new RuntimeException(e); } }
@Override public int getNumberOfSpecifiedExceptions() { try { return ctMethod.getExceptionTypes().length; } catch (NotFoundException e) { throw new RuntimeException(e); } }
private static boolean isThrowsSqlException(CtMethod method) { try { for (CtClass clazz : method.getExceptionTypes()) { if (clazz.getSimpleName().equals("SQLException")) { return true; } } } catch (NotFoundException e) { // fall thru } return false; }
private static boolean isThrowsSqlException(CtMethod method) { try { for (CtClass clazz : method.getExceptionTypes()) { if (clazz.getSimpleName().equals("SQLException")) { return true; } } } catch (NotFoundException e) { // fall thru } return false; }
@Override public ResolvedType getSpecifiedException(int index) { if (index < 0 || index >= getNumberOfSpecifiedExceptions()) { throw new IllegalArgumentException(String.format("No exception with index %d. Number of exceptions: %d", index, getNumberOfSpecifiedExceptions())); } try { return JavassistFactory.typeUsageFor(ctMethod.getExceptionTypes()[index], typeSolver); } catch (NotFoundException e) { throw new RuntimeException(e); } }
@Override public ResolvedType getSpecifiedException(int index) { if (index < 0 || index >= getNumberOfSpecifiedExceptions()) { throw new IllegalArgumentException(String.format("No exception with index %d. Number of exceptions: %d", index, getNumberOfSpecifiedExceptions())); } try { return JavassistFactory.typeUsageFor(ctMethod.getExceptionTypes()[index], typeSolver); } catch (NotFoundException e) { throw new RuntimeException(e); } } }
@Override public ResolvedType getSpecifiedException(int index) { if (index < 0 || index >= getNumberOfSpecifiedExceptions()) { throw new IllegalArgumentException(String.format("No exception with index %d. Number of exceptions: %d", index, getNumberOfSpecifiedExceptions())); } try { return JavassistFactory.typeUsageFor(ctMethod.getExceptionTypes()[index], typeSolver); } catch (NotFoundException e) { throw new RuntimeException(e); } } }
public CtMethod makeNewMethod(CtMethod ctMethod, CtClass returnCtClass, String methodName, CtClass[] paramTypes, String methodBody) throws CannotCompileException, NotFoundException { return CtNewMethod.make( ctMethod.getModifiers(), returnCtClass, methodName, paramTypes, ctMethod.getExceptionTypes(), methodBody, ctClass); }
private void addInvokeTargetMethod() throws CannotCompileException, NotFoundException { CtMethod template = INVOCATION_CT_TYPE.getDeclaredMethod(INVOKE_TARGET); boolean isVoid = targetMethod.getReturnType().equals(CtClass.voidType); String body = (isVoid) ? "{dispatch(); return null;}" : "{return ($w)dispatch();}"; CtMethod invokeTarget = CtNewMethod.make( template.getReturnType(), template.getName(), template.getParameterTypes(), template.getExceptionTypes(), body, jp); jp.addMethod(invokeTarget); }
private void addInvokeTargetMethod() throws CannotCompileException, NotFoundException { CtMethod template = READ_INVOCATION_CT_TYPE.getDeclaredMethod(INVOKE_TARGET); String body = (read) ? "{return ($w)dispatch();}" : "{dispatch(); return null;}" ; CtMethod invokeTarget = CtNewMethod.make( template.getReturnType(), template.getName(), template.getParameterTypes(), template.getExceptionTypes(), body, jp); jp.addMethod(invokeTarget); }
private void addInvokeTargetMethod() throws CannotCompileException, NotFoundException { CtMethod template = INVOCATION_CT_TYPE.getDeclaredMethod(INVOKE_TARGET); String body = "{return dispatch();}"; CtMethod invokeTarget = CtNewMethod.make( template.getReturnType(), template.getName(), template.getParameterTypes(), template.getExceptionTypes(), body, jp); jp.addMethod(invokeTarget); }
private void addInvokeTargetMethod() throws CannotCompileException, NotFoundException { CtMethod template = INVOCATION_CT_TYPE.getDeclaredMethod(INVOKE_TARGET); String body = "{return dispatch();}"; CtMethod invokeTarget = CtNewMethod.make( template.getReturnType(), template.getName(), template.getParameterTypes(), template.getExceptionTypes(), body, jp); jp.addMethod(invokeTarget); } }
private void addInvokeTargetMethod() throws CannotCompileException, NotFoundException { CtMethod template = INVOCATION_CT_TYPE.getDeclaredMethod(INVOKE_TARGET); String body = "{return dispatch();}"; CtMethod invokeTarget = CtNewMethod.make( template.getReturnType(), template.getName(), template.getParameterTypes(), template.getExceptionTypes(), body, jp); jp.addMethod(invokeTarget); } }
private CtMethod addMethodFromTemplate(CtClass template, String name, String body) throws Exception { CtMethod templateMethod = template.getDeclaredMethod(name); CtMethod method = CtNewMethod.make(templateMethod.getReturnType(), name, templateMethod.getParameterTypes(), templateMethod.getExceptionTypes(), body, proxy); method.setModifiers(templateMethod.getModifiers()); Instrumentor.addSyntheticAttribute(method); proxy.addMethod(method); hardcodedMethods.add(JavassistMethodHashing.methodHash(method)); return method; }
private CtMethod createCtMethod(CtClass declaringClass, CtMethod method) throws CannotCompileException, NotFoundException { return CtNewMethod.make(method.getModifiers() & ~Modifier.ABSTRACT, method.getReturnType(), method.getName(), method.getParameterTypes(), method.getExceptionTypes(), methodGenerator.createBody(method), declaringClass); }