<commit_before>/*
 * ################################################################
 *
 * ProActive Parallel Suite(TM): The Java(TM) library for
 *    Parallel, Distributed, Multi-Core Computing for
 *    Enterprise Grids & Clouds
 *
 * Copyright (C) 1997-2012 INRIA/University of
 *                 Nice-Sophia Antipolis/ActiveEon
 * Contact: <EMAIL> or <EMAIL>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation; version 3 of
 * the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * If needed, contact us to obtain a release under GPL Version 2 or 3
 * or a different license than the AGPL.
 *
 *  Initial developer(s):               The ProActive Team
 *                        http://proactive.inria.fr/team_members.htm
 *  Contributor(s): ActiveEon Team - http://www.activeeon.com
 *
 * ################################################################
 * $$ACTIVEEON_CONTRIBUTOR$$
 */
package org.objectweb.proactive.core.mop;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.TreeMap;

import javassist.NotFoundException;

import org.apache.log4j.Logger;
import org.objectweb.proactive.Active;
import org.objectweb.proactive.api.PAFuture;
import org.objectweb.proactive.core.Constants;
import org.objectweb.proactive.core.body.ActiveBody;
import org.objectweb.proactive.core.body.MetaObjectFactory;
import org.objectweb.proactive.core.body.UniversalBody;
import org.objectweb.proactive.core.mop.proxy.PAProxy;
import org.objectweb.proactive.core.node.Node;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;


/**
 * A place where static methods go
 */
public abstract class MOP {

    /**
     * The name of the interface that characterizes all stub classes
     */
    protected static String STUB_OBJECT_INTERFACE_NAME = "org.objectweb.proactive.core.mop.StubObject";
    protected static Class<?> STUB_OBJECT_INTERFACE;
    static Logger logger = ProActiveLogger.getLogger(Loggers.MOP);

    /**
     * The root interface of all metabehaviors
     */

    //protected static String ROOT_INTERFACE_NAME = "org.objectweb.proactive.core.mop.Reflect";
    //protected static Class ROOT_INTERFACE;
    /**
     * Class array representing no parameters
     */
    protected static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];

    /**
     * Empty object array
     */
    public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];

    /**
     * Class<?> array representing (Constructor Call, Object[])
     */
    protected static Class<?>[] PROXY_CONSTRUCTOR_PARAMETERS_TYPES_ARRAY = new Class<?>[2];

    /**
     * A Hashtable to cache (reified class, stub class constructor) couples.
     */
    protected static java.util.Hashtable<GenericStubKey, Constructor<?>> stubTable = new java.util.Hashtable<GenericStubKey, Constructor<?>>();

    /**
     * A Hashtable to cache (proxy class, proxy class constructor) couples
     */
    protected static java.util.Hashtable<String, Constructor<?>> proxyTable = new java.util.Hashtable<String, Constructor<?>>();

    /**
     * A Hashtable to cache (Class<?> name, proxy class name) couples
     * this is meant for class-based reification
     */
    protected static java.util.Hashtable<String, Constructor<?>> secondProxyTable = new java.util.Hashtable<String, Constructor<?>>();
    protected static MOPClassLoader singleton = MOPClassLoader.getMOPClassLoader(); //MOPClassLoader.createMOPClassLoader();

    /**
     *        As this class is center to the API, its static initializer is
     *        a good place to initialize general stuff.
     */
    protected static HashMap<String, Class<?>> loadedClass = new HashMap<String, Class<?>>();

    static {
        PROXY_CONSTRUCTOR_PARAMETERS_TYPES_ARRAY = new Class<?>[] {
                org.objectweb.proactive.core.mop.ConstructorCall.class, EMPTY_OBJECT_ARRAY.getClass() };

        try {
            STUB_OBJECT_INTERFACE = forName(STUB_OBJECT_INTERFACE_NAME);
        } catch (ClassNotFoundException e) {
            throw new CannotFindClassException(STUB_OBJECT_INTERFACE_NAME);
        }

        //try {
        //  ROOT_INTERFACE = forName(ROOT_INTERFACE_NAME);
        //} catch (ClassNotFoundException e) {
        //  throw new CannotFindClassException(ROOT_INTERFACE_NAME);
        //}
    }<commit_msg>PROACTIVE-1333 Use concurrent map for caching.<commit_after>/*
 * ################################################################
 *
 * ProActive Parallel Suite(TM): The Java(TM) library for
 *    Parallel, Distributed, Multi-Core Computing for
 *    Enterprise Grids & Clouds
 *
 * Copyright (C) 1997-2012 INRIA/University of
 *                 Nice-Sophia Antipolis/ActiveEon
 * Contact: <EMAIL> or <EMAIL>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation; version 3 of
 * the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * If needed, contact us to obtain a release under GPL Version 2 or 3
 * or a different license than the AGPL.
 *
 *  Initial developer(s):               The ProActive Team
 *                        http://proactive.inria.fr/team_members.htm
 *  Contributor(s): ActiveEon Team - http://www.activeeon.com
 *
 * ################################################################
 * $$ACTIVEEON_CONTRIBUTOR$$
 */
package org.objectweb.proactive.core.mop;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
import java.util.TreeMap;

import javassist.NotFoundException;

import org.apache.log4j.Logger;
import org.objectweb.proactive.Active;
import org.objectweb.proactive.api.PAFuture;
import org.objectweb.proactive.core.Constants;
import org.objectweb.proactive.core.body.ActiveBody;
import org.objectweb.proactive.core.body.MetaObjectFactory;
import org.objectweb.proactive.core.body.UniversalBody;
import org.objectweb.proactive.core.mop.proxy.PAProxy;
import org.objectweb.proactive.core.node.Node;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;


/**
 * A place where static methods go
 */
public abstract class MOP {

    /**
     * The name of the interface that characterizes all stub classes
     */
    protected static String STUB_OBJECT_INTERFACE_NAME = "org.objectweb.proactive.core.mop.StubObject";
    protected static Class<?> STUB_OBJECT_INTERFACE;
    static Logger logger = ProActiveLogger.getLogger(Loggers.MOP);

    /**
     * The root interface of all metabehaviors
     */

    //protected static String ROOT_INTERFACE_NAME = "org.objectweb.proactive.core.mop.Reflect";
    //protected static Class ROOT_INTERFACE;
    /**
     * Class array representing no parameters
     */
    protected static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];

    /**
     * Empty object array
     */
    public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];

    /**
     * Class<?> array representing (Constructor Call, Object[])
     */
    protected static Class<?>[] PROXY_CONSTRUCTOR_PARAMETERS_TYPES_ARRAY = new Class<?>[2];

    /**
     * A Hashtable to cache (reified class, stub class constructor) couples.
     */
    protected static java.util.Hashtable<GenericStubKey, Constructor<?>> stubTable = new java.util.Hashtable<GenericStubKey, Constructor<?>>();

    /**
     * A Hashtable to cache (proxy class, proxy class constructor) couples
     */
    protected static java.util.Hashtable<String, Constructor<?>> proxyTable = new java.util.Hashtable<String, Constructor<?>>();

    /**
     * A Hashtable to cache (Class<?> name, proxy class name) couples
     * this is meant for class-based reification
     */
    protected static java.util.Hashtable<String, Constructor<?>> secondProxyTable = new java.util.Hashtable<String, Constructor<?>>();
    protected static MOPClassLoader singleton = MOPClassLoader.getMOPClassLoader(); //MOPClassLoader.createMOPClassLoader();

    /**
     *        As this class is center to the API, its static initializer is
     *        a good place to initialize general stuff.
     */
    protected static Map<String, Class<?>> loadedClass = Collections.synchronizedMap(new HashMap<String, Class<?>>());

    static {
        PROXY_CONSTRUCTOR_PARAMETERS_TYPES_ARRAY = new Class<?>[] {
                org.objectweb.proactive.core.mop.ConstructorCall.class, EMPTY_OBJECT_ARRAY.getClass() };

        try {
            STUB_OBJECT_INTERFACE = forName(STUB_OBJECT_INTERFACE_NAME);
        } catch (ClassNotFoundException e) {
            throw new CannotFindClassException(STUB_OBJECT_INTERFACE_NAME);
        }

        //try {
        //  ROOT_INTERFACE = forName(ROOT_INTERFACE_NAME);
        //} catch (ClassNotFoundException e) {
        //  throw new CannotFindClassException(ROOT_INTERFACE_NAME);
        //}
    }
{'fraction_non_alphanumeric': 0.12167264489333585, 'fraction_numerical': 0.00585236926562205, 'mean_word_length': 3.6005210594876247, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6204377', 'n_tokens_mistral': 3055, 'n_tokens_neox': 2976, 'n_words': 845}