recordParams(method.getParameterTypes(), Modifier.isStatic(mod));
recordParams(method.getParameterTypes(), Modifier.isStatic(mod));
Javac jv = new Javac(cc); try { int nvars = jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); jv.recordParamNames(ca, nvars);
try { jv.recordLocalVariables(ca, index); jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); jv.setMaxLocals(ca.getMaxLocals());
Javac jv = new Javac(b, cc); try { jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); int var = jv.recordVariable(exceptionType, exceptionName);
Javac jv = new Javac(cc); try { int nvars = jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); jv.recordParamNames(ca, nvars);
try { jv.recordLocalVariables(ca, index); jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); jv.setMaxLocals(ca.getMaxLocals());
Javac jv = new Javac(b, cc); try { jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); int var = jv.recordVariable(exceptionType, exceptionName);
Javac jv = new Javac(b, cc); try { int nvars = jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); jv.recordParamNames(ca, nvars);
Javac jv = new Javac(b, cc); try { int nvars = jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); jv.recordParamNames(ca, nvars);
public static String getParameterClassArrayString(String arrayName, CtBehavior behavior)throws NotFoundException { CtClass[] params = behavior.getParameterTypes(); return getParameterClassArrayString(params, arrayName); }
private void buildParameterTypes(Element element, CtBehavior method) throws NotFoundException { CtClass[] params = method.getParameterTypes(); for (int k = 0; k < params.length; k++) { Element paramsElement = document.createElement("parameter"); addAttribute(paramsElement, "type", params[k].getName()); element.appendChild(paramsElement); } }
/** * Returns a list of the classes of the parameters to a given method. */ private List<Class<?>> getParameterClasses(CtBehavior method) { try { CtClass[] params = method.getParameterTypes(); List<Class<?>> result = new ArrayList<Class<?>>(params.length); for (CtClass paramClass : params) { result.add(getClass(paramClass)); } return result; } catch (NotFoundException e) { throw new RuntimeException(e); } }
public CtClass getElementType() throws NotFoundException { return getArgumentBehavior().getParameterTypes()[getArgumentNumber()]; }
/** * Checked exception suppressor for {@link CtBehavior#getParameterTypes()}. * </p> * This method converts {@link NotFoundException} to {@link CheckedExceptionSuppressorException}. * * @param ctBehavior * target {@link CtBehavior} * @return return value of {@link CtBehavior#getParameterTypes()} * @throws IllegalArgumentException * if <code>ctBehavior</code> is null * @throws CheckedExceptionSuppressorException * if NotFoundException is thrown */ public static CtClass[] getParameterTypes(CtBehavior ctBehavior) { if (ctBehavior == null) throw new IllegalArgumentException("ctBehavior is null."); try { return ctBehavior.getParameterTypes(); } catch (NotFoundException e) { // Mock test is impossible because CtMethod is final class. throw new CheckedExceptionSuppressorException(e.getMessage(), e); } }
protected void transformParameters( @Nonnull CtBehavior method ) throws ClassNotFoundException, NotFoundException, CannotCompileException { Object[][] parameterAnnotations = method.getParameterAnnotations(); for ( int i = 0, parameterAnnotationsLength = parameterAnnotations.length; i < parameterAnnotationsLength; i++ ) { if ( AnnotationUtils.hasAnnotation( parameterAnnotations[i], Nonnull.class ) ) { //Skip primitive parameters if ( method.getParameterTypes()[i].isPrimitive() ) { continue; } int parameterNumber = i + 1; String format = MessageFormat.format( getNonNullParamCode(), parameterNumber ); insertAssertedVerificationCodeBefore( method, format ); } } }
/** * Gets all the local variables of the given behavior, indexed by their index in the LocalVariableTable attribute. * @param behavior * @return the local variables of the given behavior, indexed by their index in the LocalVariableTable attribute. * @throws NotFoundException */ public static Map<Integer, LocalVariable> findVariables(CtBehavior behavior) throws NotFoundException { int nbParameters = behavior.getParameterTypes().length; boolean isStatic = Modifier.isStatic(behavior.getModifiers()); Map<Integer, LocalVariable> variables = new HashMap<Integer, LocalVariable>(); CodeAttribute codeAttribute = behavior.getMethodInfo().getCodeAttribute(); LocalVariableAttribute localVariableAttribute = (LocalVariableAttribute) codeAttribute.getAttribute("LocalVariableTable"); LOGGER.debug("search vars : " + localVariableAttribute + " > " + (localVariableAttribute != null ? localVariableAttribute.tableLength() : 0)); if(localVariableAttribute != null) { for(int i = 0; i < localVariableAttribute.tableLength(); i++) { boolean isParameter = isStatic ? i < nbParameters : (i > 0 && i <= nbParameters); LocalVariable localVariable = new LocalVariable(i, localVariableAttribute.variableName(i), LocalVariableType.parse(localVariableAttribute.signature(i)), isParameter, behavior); variables.put(i, localVariable); LOGGER.debug(String.format("findLocalVariables: foud var %s is '%s' (slot %s)", i, localVariable.name, localVariable.getSlot())); } } else LOGGER.debug("no local vars found"); return variables; }
private String[] getParameterNames(final CtBehavior behavior) throws NotFoundException { final MethodInfo methodInfo = behavior.getMethodInfo(); final ParameterAnnotationsAttribute attribute = (ParameterAnnotationsAttribute) methodInfo .getAttribute(ParameterAnnotationsAttribute.visibleTag); if (attribute == null) { return null; } final int numParameters = behavior.getParameterTypes().length; final String[] parameterNames = new String[numParameters]; final Annotation[][] annotationsArray = attribute.getAnnotations(); if (annotationsArray == null || annotationsArray.length != numParameters) { return null; } for (int i = 0; i < numParameters; ++i) { final String parameterName = getParameterName(annotationsArray[i]); if (parameterName == null) { return null; } parameterNames[i] = parameterName; } return parameterNames; }
private String[] getParameterNames(final CtBehavior behavior) throws NotFoundException { final MethodInfo methodInfo = behavior.getMethodInfo(); final ParameterAnnotationsAttribute attribute = (ParameterAnnotationsAttribute) methodInfo.getAttribute(ParameterAnnotationsAttribute.visibleTag); if (attribute == null) { return null; } final int numParameters = behavior.getParameterTypes().length; final String[] parameterNames = new String[numParameters]; final Annotation[][] annotationsArray = attribute.getAnnotations(); if (annotationsArray == null || annotationsArray.length != numParameters) { return null; } for (int i = 0; i < numParameters; ++i) { final String parameterName = getParameterName(annotationsArray[i]); if (parameterName == null) { return null; } parameterNames[i] = parameterName; } return parameterNames; }
private String[] getParameterNames(final CtBehavior behavior) throws NotFoundException { final MethodInfo methodInfo = behavior.getMethodInfo(); final ParameterAnnotationsAttribute attribute = (ParameterAnnotationsAttribute) methodInfo .getAttribute(ParameterAnnotationsAttribute.visibleTag); if (attribute == null) { return null; } final int numParameters = behavior.getParameterTypes().length; final String[] parameterNames = new String[numParameters]; final Annotation[][] annotationsArray = attribute.getAnnotations(); if (annotationsArray == null || annotationsArray.length != numParameters) { return null; } for (int i = 0; i < numParameters; ++i) { final String parameterName = getParameterName(annotationsArray[i]); if (parameterName == null) { return null; } parameterNames[i] = parameterName; } return parameterNames; }