@Override protected boolean instrument(Object target,
										   Recorder recorder,
										   InstrumentationFilter filter)
		throws NonInstrumentableTypeException {

		if (target instanceof PyObject) {
			disallowSelectiveFilter(filter);

			// Jython object.
			if (target instanceof PyInstance) {
				transform(recorder, (PyInstance)target);
			}
			else if (target instanceof PyFunction) {
				transform(recorder, (PyFunction)target);
			}
			else if (target instanceof PyMethod) {
				final PyMethod pyMethod = (PyMethod)target;

				// PyMethod is used for bound and unbound Python methods, and
				// bound Java methods.

				if (pyMethod.__func__ instanceof PyReflectedFunction) {

					// Its Java.

					// Its possible im_func might be an unbound Java method or a Java
					// constructor, but I can't find a way to trigger this. We always
					// receive a PyReflectedMethod or PyReflectedConstructor directly.
					// Here, we defensively cope with unbound methods, but not
					// constructors.
					transform(recorder,
						(PyReflectedFunction)pyMethod.__func__,
						pyMethod.__self__.__tojava__(Object.class));
				}
				else {
					transform(recorder, pyMethod);
				}
			}
			else if (target instanceof PyClass) {
				transform(recorder, (PyClass)target);
			}
			else if (target instanceof PyReflectedConstructor) {
				transform(recorder, (PyReflectedConstructor)target);
			}
			else if (target instanceof PyReflectedFunction) {
				transform(recorder, (PyReflectedFunction)target, null);
			}
			else {
				// Fail, rather than guess a generic approach.

				// We should never be called with a PyType, since it will be
				// converted to a PyClass or Java class by the implicit __tojava__()
				// calls as part of dispatching to the record() implementation.

				// Similarly PyObjectDerived will be converted to a Java class.

				throw new NonInstrumentableTypeException("Unknown PyObject:" +
					target.getClass());
			}
		}
		else if (target instanceof PyProxy) {
			disallowSelectiveFilter(filter);

			transform(recorder, (PyProxy)target);
		}
		else {
			// Let the Java instrumenter have a go.
			return false;
		}

		return true;
	}
Extract and instrument the underlying Java methods for instrumentation.

@param <T>
         Constructor<?> or Method
@param pyReflectedFunction
         The Jython object.
@return A list of Java methods or constructors.
@throws NonInstrumentableTypeException
          If the methods could not be extracted.
ngrinder-runtime/src/main/java/net/grinder/scriptengine/jython/instrumentation/dcr/AbstractJythonDCRInstrumenter.java