<commit_before>package org.junit.runners.model;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;

import org.junit.internal.runners.model.ReflectiveCallable;

/**
 * Represents a method on a test class to be invoked at the appropriate point in
 * test execution. These methods are usually marked with an annotation (such as
 * {@code @Test}, {@code @Before}, {@code @After}, {@code @BeforeClass}, {@code
 * @AfterClass}, etc.)
 */
public class FrameworkMethod {
	private final Method fMethod;

	/**
	 * Returns a new {@code FrameworkMethod} for {@code method}
	 */
	public FrameworkMethod(Method method) {
		fMethod= method;
	}

	/**
	 * Returns the underlying Java method
	 */
	public Method getMethod() {
		return fMethod;
	}

	/**
	 * Returns the result of invoking this method on {@code target} with
	 * parameters {@code params}. {@link InvocationTargetException}s thrown are
	 * unwrapped, and their causes rethrown.
	 */
	public Object invokeExplosively(final Object target, final Object... params)
			throws Throwable {
		return new ReflectiveCallable() {
			@Override
			protected Object runReflectiveCall() throws Throwable {
				return fMethod.invoke(target, params);
			}
		}.run();
	}

	/**
	 * Returns the method's name
	 */
	public String getName() {
		return fMethod.getName();
	}

	/**
	 * Adds to {@code errors} if this method:
	 * <ul>
	 * <li>is not public, or
	 * <li>takes parameters, or
	 * <li>returns something other than void, or
	 * <li>is static (given {@code isStatic is false}), or
	 * <li>is not static (given {@code isStatic is true}).
	 */
	public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors) {
		validatePublicVoid(isStatic, errors);
		if (fMethod.getParameterTypes().length != 0)
			errors.add(new Exception("Method " + fMethod.getName()
					+ " should have no parameters"));
	}

	public void validatePublicVoid(boolean isStatic, List<Throwable> errors) {
		if (Modifier.isStatic(fMethod.getModifiers()) != isStatic) {
			String state= isStatic ? "should" : "should not";
			errors.add(new Exception("Method " + fMethod.getName() + "() "
					+ state + " be static"));
		}
		if (!Modifier.isPublic(fMethod.getDeclaringClass().getModifiers()))
			errors.add(new Exception("Class "
					+ fMethod.getDeclaringClass().getName()
					+ " should be public"));
		if (!Modifier.isPublic(fMethod.getModifiers()))
			errors.add(new Exception("Method " + fMethod.getName()
					+ " should be public"));
		if (fMethod.getReturnType() != Void.TYPE)
			errors.add(new Exception("Method " + fMethod.getName()
					+ " should be void"));
	}
<commit_msg>Javadoc on FrameworkMethod augmented<commit_after>package org.junit.runners.model;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;

import org.junit.internal.runners.model.ReflectiveCallable;

/**
 * Represents a method on a test class to be invoked at the appropriate point in
 * test execution. These methods are usually marked with an annotation (such as
 * {@code @Test}, {@code @Before}, {@code @After}, {@code @BeforeClass}, {@code
 * @AfterClass}, etc.)
 */
public class FrameworkMethod {
	private final Method fMethod;

	/**
	 * Returns a new {@code FrameworkMethod} for {@code method}
	 */
	public FrameworkMethod(Method method) {
		fMethod= method;
	}

	/**
	 * Returns the underlying Java method
	 */
	public Method getMethod() {
		return fMethod;
	}

	/**
	 * Returns the result of invoking this method on {@code target} with
	 * parameters {@code params}. {@link InvocationTargetException}s thrown are
	 * unwrapped, and their causes rethrown.
	 */
	public Object invokeExplosively(final Object target, final Object... params)
			throws Throwable {
		return new ReflectiveCallable() {
			@Override
			protected Object runReflectiveCall() throws Throwable {
				return fMethod.invoke(target, params);
			}
		}.run();
	}

	/**
	 * Returns the method's name
	 */
	public String getName() {
		return fMethod.getName();
	}

	/**
	 * Adds to {@code errors} if this method:
	 * <ul>
	 * <li>is not public, or
	 * <li>takes parameters, or
	 * <li>returns something other than void, or
	 * <li>is static (given {@code isStatic is false}), or
	 * <li>is not static (given {@code isStatic is true}).
	 */
	public void validatePublicVoidNoArg(boolean isStatic, List<Throwable> errors) {
		validatePublicVoid(isStatic, errors);
		if (fMethod.getParameterTypes().length != 0)
			errors.add(new Exception("Method " + fMethod.getName()
					+ " should have no parameters"));
	}


	/**
	 * Adds to {@code errors} if this method:
	 * <ul>
	 * <li>is not public, or
	 * <li>returns something other than void, or
	 * <li>is static (given {@code isStatic is false}), or
	 * <li>is not static (given {@code isStatic is true}).
	 */
	public void validatePublicVoid(boolean isStatic, List<Throwable> errors) {
		if (Modifier.isStatic(fMethod.getModifiers()) != isStatic) {
			String state= isStatic ? "should" : "should not";
			errors.add(new Exception("Method " + fMethod.getName() + "() "
					+ state + " be static"));
		}
		if (!Modifier.isPublic(fMethod.getDeclaringClass().getModifiers()))
			errors.add(new Exception("Class "
					+ fMethod.getDeclaringClass().getName()
					+ " should be public"));
		if (!Modifier.isPublic(fMethod.getModifiers()))
			errors.add(new Exception("Method " + fMethod.getName()
					+ " should be public"));
		if (fMethod.getReturnType() != Void.TYPE)
			errors.add(new Exception("Method " + fMethod.getName()
					+ " should be void"));
	}

{'fraction_non_alphanumeric': 0.13362369337979094, 'fraction_numerical': 0.0003484320557491289, 'mean_word_length': 4.040386303775241, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2889546', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1691, 'n_words': 513}