<commit_before>
package be.ibridge.kettle.trans;

import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.ProtectionDomain;

public class KettleURLClassLoader extends URLClassLoader
{
    public KettleURLClassLoader(URL[] url, ClassLoader classLoader)
    {
        super(url, classLoader);
    }
    
    /*
            Cglib doe's not creates custom class loader (to access package methotds and classes ) it uses reflection to invoke "defineClass", 
            but you can call protected method in subclass without problems:
    */
    public Class loadClass(String name, ProtectionDomain protectionDomain) 
    {
        Class loaded = findLoadedClass(name);
        if (loaded == null)
        {
            // Get the jar, load the bytes from the jar file, construct class from scratch as in snippet below...

            /*
            
            loaded = super.findClass(name);
            
            URL url = super.findResource(newName);
            
            InputStream clis = getResourceAsStream(newName);
            
            */
           
            String newName = name.replace('.','/');
            InputStream is = super.getResourceAsStream(newName);
            byte[] driverBytes = toBytes( is );
            
            loaded = super.defineClass(name, driverBytes, 0, driverBytes.length, protectionDomain);

        }<commit_msg>Give the classloader a name and implement toString() to make it easier to debug this<commit_after>
package be.ibridge.kettle.trans;

import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.ProtectionDomain;

public class KettleURLClassLoader extends URLClassLoader
{
    private String name;
    
    public KettleURLClassLoader(URL[] url, ClassLoader classLoader)
    {
        super(url, classLoader);
    }
    
    public KettleURLClassLoader(URL[] url, ClassLoader classLoader, String name)
    {
        this(url, classLoader);
        this.name = name;
    }
    
    public String toString()
    {
        return super.toString()+" : "+name;
    }
    
    public void setName(String name)
    {
        this.name = name;
    }
    
    public String getName()
    {
        return name;
    }
    
    /*
        Cglib doe's not creates custom class loader (to access package methotds and classes ) it uses reflection to invoke "defineClass", 
        but you can call protected method in subclass without problems:
    */
    public Class loadClass(String name, ProtectionDomain protectionDomain) 
    {
        Class loaded = findLoadedClass(name);
        if (loaded == null)
        {
            // Get the jar, load the bytes from the jar file, construct class from scratch as in snippet below...

            /*
            
            loaded = super.findClass(name);
            
            URL url = super.findResource(newName);
            
            InputStream clis = getResourceAsStream(newName);
            
            */
           
            String newName = name.replace('.','/');
            InputStream is = super.getResourceAsStream(newName);
            byte[] driverBytes = toBytes( is );
            
            loaded = super.defineClass(name, driverBytes, 0, driverBytes.length, protectionDomain);

        }
{'fraction_non_alphanumeric': 0.0818978543366576, 'fraction_numerical': 0.0006044122091266244, 'mean_word_length': 2.067655236329935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7387155', 'n_tokens_mistral': 861, 'n_tokens_neox': 833, 'n_words': 257}