<commit_before>/* 
 * ################################################################
 * 
 * ProActive: The Java(TM) library for Parallel, Distributed, 
 *            Concurrent computing with Security and Mobility
 * 
 * Copyright (C) 1997-2006 INRIA/University of Nice-Sophia Antipolis
 * Contact: <EMAIL>
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *  
 * 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser 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
 *  
 *  Initial developer(s):               The ProActive Team
 *                        http://www.inria.fr/oasis/ProActive/contacts.html
 *  Contributor(s): 
 * 
 * ################################################################
 */ 
package org.objectweb.proactive.core.mop;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Hashtable;

import org.apache.log4j.Logger;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;


public class MOPClassLoader extends URLClassLoader {
    static Logger logger = ProActiveLogger.getLogger(Loggers.MOP);

    // retreives the optionnal byteCodeManipulator JVM arg
    // javassist is used by default
    public static String BYTE_CODE_MANIPULATOR = (System.getProperty(
            "byteCodeManipulator") != null)
        ? System.getProperty("byteCodeManipulator") : "javassist";
    protected static Hashtable classDataCache = new Hashtable();
    protected static MOPClassLoader mopCl = null;

    /**
     * Return the unique MOPClassLoader for the current JVM
     * Create it if it does not exist
     */
    public static synchronized MOPClassLoader getMOPClassLoader() {
        if (MOPClassLoader.mopCl == null) {
            MOPClassLoader.mopCl = MOPClassLoader.createMOPClassLoader();
        }
        return MOPClassLoader.mopCl;
    }

    public MOPClassLoader() {
        super(new URL[] {  });
    }

    /**
     * Get the bytecode of a stub given its name. If the stub can not be found
     * the cache, the MOPClassLoader tries to generate it.
     * @param classname The name of the stub class
     * @return An array representing the bytecode of the stub, null if the
     *  stub could not be found or created
     */
    public byte[] getClassData(String classname) {
        byte[] cb = null;
        cb = (byte[]) classDataCache.get(classname);
        if (cb == null) {
        	if (logger.isDebugEnabled()) {
        		logger.debug(
                	"MOPClassLoader: class not found, trying to generate it");
        	}
            try {
                this.loadClass(classname);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            cb = (byte[]) classDataCache.get(classname);<commit_msg>log name of class to generate in MOPClassLoader message<commit_after>/* 
 * ################################################################
 * 
 * ProActive: The Java(TM) library for Parallel, Distributed, 
 *            Concurrent computing with Security and Mobility
 * 
 * Copyright (C) 1997-2006 INRIA/University of Nice-Sophia Antipolis
 * Contact: <EMAIL>
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *  
 * 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser 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
 *  
 *  Initial developer(s):               The ProActive Team
 *                        http://www.inria.fr/oasis/ProActive/contacts.html
 *  Contributor(s): 
 * 
 * ################################################################
 */ 
package org.objectweb.proactive.core.mop;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Hashtable;

import org.apache.log4j.Logger;
import org.objectweb.proactive.core.util.log.Loggers;
import org.objectweb.proactive.core.util.log.ProActiveLogger;


public class MOPClassLoader extends URLClassLoader {
    static Logger logger = ProActiveLogger.getLogger(Loggers.MOP);

    // retreives the optionnal byteCodeManipulator JVM arg
    // javassist is used by default
    public static String BYTE_CODE_MANIPULATOR = (System.getProperty(
            "byteCodeManipulator") != null)
        ? System.getProperty("byteCodeManipulator") : "javassist";
    protected static Hashtable classDataCache = new Hashtable();
    protected static MOPClassLoader mopCl = null;

    /**
     * Return the unique MOPClassLoader for the current JVM
     * Create it if it does not exist
     */
    public static synchronized MOPClassLoader getMOPClassLoader() {
        if (MOPClassLoader.mopCl == null) {
            MOPClassLoader.mopCl = MOPClassLoader.createMOPClassLoader();
        }
        return MOPClassLoader.mopCl;
    }

    public MOPClassLoader() {
        super(new URL[] {  });
    }

    /**
     * Get the bytecode of a stub given its name. If the stub can not be found
     * the cache, the MOPClassLoader tries to generate it.
     * @param classname The name of the stub class
     * @return An array representing the bytecode of the stub, null if the
     *  stub could not be found or created
     */
    public byte[] getClassData(String classname) {
        byte[] cb = null;
        cb = (byte[]) classDataCache.get(classname);
        if (cb == null) {
        	if (logger.isDebugEnabled()) {
        		logger.debug(
                	"MOPClassLoader: class " + classname + " not found, trying to generate it");
        	}
            try {
                this.loadClass(classname);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            cb = (byte[]) classDataCache.get(classname);
{'fraction_non_alphanumeric': 0.11650766117374964, 'fraction_numerical': 0.007227522405319456, 'mean_word_length': 2.909039548022599, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5523996', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1843, 'n_words': 640}