<commit_before>package org.osjava.signals.natives;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import org.osjava.signals.Dispatcher;
import org.osjava.signals.SignalListener;
import org.osjava.signals.SignalListener.SignalListener1;
import org.osjava.signals.SignalListener.SignalListener2;
import org.osjava.signals.SignalListener.SignalListener3;
import org.osjava.signals.SignalListener.SignalListener4;
import org.osjava.signals.SignalListener.SignalListener5;
import org.osjava.signals.Slot;
import org.osjava.signals.impl.DispatcherImpl;
import org.osjava.signals.impl.NativeSignalImpl;

public class NativeAPIAdapterSignal<L extends SignalListener, T> extends NativeSignalImpl<L, T> {

	private Method _invokeMethod;

	private String _listenerName;

	private Class<?> _adapterClass;

	private NativeAPIAdapterDelegate _delegate;

	private List<Method> _delegateMethods;

	private Object _proxy;

	public NativeAPIAdapterSignal(List<Slot<L>> bindings) {
		super(bindings);
	}

	protected void createProxy(final String adapterName, final String listenerName,
			final Class<?>[] parameterTypes, final NativeAPIAdapterDelegate delegate,
			final List<String> delegateMethodNames) {
		assert adapterName != null : "Adapter name can not be null";
		assert listenerName != null : "Listener name can not be null";
		assert parameterTypes != null : "Parameter types can not be null";
		assert delegate != null : "Delegate can not be null";
		assert delegateMethodNames != null : "Delegate method name can not be null";

		_delegate = delegate;
		_listenerName = listenerName;

		ClassLoader classLoader = ClassLoader.getSystemClassLoader();

		try {
			_adapterClass = classLoader.loadClass(adapterName);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}

		_delegateMethods = new ArrayList<Method>();
		for (final String delegateMethodName : delegateMethodNames) {
			try {
				final Method delegateMethod =
						_delegate.getClass().getMethod(delegateMethodName, parameterTypes);
				_delegateMethods.add(delegateMethod);
			} catch (SecurityException e) {<commit_msg>using a local class loader<commit_after>package org.osjava.signals.natives;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import org.osjava.signals.Dispatcher;
import org.osjava.signals.SignalListener;
import org.osjava.signals.SignalListener.SignalListener1;
import org.osjava.signals.SignalListener.SignalListener2;
import org.osjava.signals.SignalListener.SignalListener3;
import org.osjava.signals.SignalListener.SignalListener4;
import org.osjava.signals.SignalListener.SignalListener5;
import org.osjava.signals.Slot;
import org.osjava.signals.impl.DispatcherImpl;
import org.osjava.signals.impl.NativeSignalImpl;

public class NativeAPIAdapterSignal<L extends SignalListener, T> extends NativeSignalImpl<L, T> {

	private Method _invokeMethod;

	private String _listenerName;

	private Class<?> _adapterClass;

	private NativeAPIAdapterDelegate _delegate;

	private List<Method> _delegateMethods;

	private Object _proxy;

	public NativeAPIAdapterSignal(List<Slot<L>> bindings) {
		super(bindings);
	}

	protected void createProxy(final String adapterName, final String listenerName,
			final Class<?>[] parameterTypes, final NativeAPIAdapterDelegate delegate,
			final List<String> delegateMethodNames) {
		assert adapterName != null : "Adapter name can not be null";
		assert listenerName != null : "Listener name can not be null";
		assert parameterTypes != null : "Parameter types can not be null";
		assert delegate != null : "Delegate can not be null";
		assert delegateMethodNames != null : "Delegate method name can not be null";

		_delegate = delegate;
		_listenerName = listenerName;

		ClassLoader classLoader = NativeAPIAdapterSignal.class.getClassLoader();

		try {
			_adapterClass = classLoader.loadClass(adapterName);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}

		_delegateMethods = new ArrayList<Method>();
		for (final String delegateMethodName : delegateMethodNames) {
			try {
				final Method delegateMethod =
						_delegate.getClass().getMethod(delegateMethodName, parameterTypes);
				_delegateMethods.add(delegateMethod);
			} catch (SecurityException e) {
{'fraction_non_alphanumeric': 0.08780592528982396, 'fraction_numerical': 0.0021468441391155, 'mean_word_length': 5.81140350877193, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '533747', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1269, 'n_words': 330}