<commit_before>package lucee.runtime.osgi;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleReference;

import lucee.commons.io.IOUtil;
import lucee.commons.io.SystemUtil;
import lucee.commons.io.log.Log;
import lucee.commons.lang.StringUtil;
import lucee.loader.engine.CFMLEngineFactory;
import lucee.runtime.config.Config;
import lucee.runtime.config.ConfigPro;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.text.xml.XMLUtil;

public class EnvClassLoader extends URLClassLoader {

	private static float FROM_SYSTEM = 1;
	private static float FROM_BOOTDELEGATION = 2;
	private static float FROM_CALLER = 3;

	private static SoftReference<String> EMPTY = new SoftReference<String>(null);
	private static Map<SoftReference<String>, SoftReference<String>> notFound = new java.util.concurrent.ConcurrentHashMap<>();

	private Config config;
	private Map<String, SoftReference<Object[]>> callerCache = new ConcurrentHashMap<String, SoftReference<Object[]>>();
	private Log trace;

	private static final short CLASS = 1;
	private static final short URL = 2;
	private static final short STREAM = 3;

	private static ThreadLocal<Set<String>> checking = new ThreadLocal<Set<String>>() {
		@Override
		protected Set<String> initialValue() {
			return new HashSet<>();
		}
	};

	private static ThreadLocal<Boolean> inside = new ThreadLocal<Boolean>() {
		@Override
		protected Boolean initialValue() {
			return Boolean.FALSE;
		}
	};

	private static final EnvClassLoader NULL_INSTANCE = new EnvClassLoader(null);

	public static EnvClassLoader getInstance(ConfigPro config) {
		config = (ConfigPro) ThreadLocalPageContext.get(config);
		if (config != null) return (EnvClassLoader) config.getClassLoaderEnv();

		return NULL_INSTANCE;
	}

	public EnvClassLoader(ConfigPro config) {
		super(new URL[0], config != null ? config.getClassLoaderCore() : new lucee.commons.lang.ClassLoaderHelper().getClass().getClassLoader());
		this.config = config;
		this.trace = log(Log.LEVEL_TRACE);
	}

	@Override
	public Class<?> loadClass(String name) throws ClassNotFoundException {
		return loadClass(name, false);
	}

	@Override
	public URL getResource(String name) {
		if (trace == null) {
			return (java.net.URL) load(name, URL, true, null, true);
		}
		double start = SystemUtil.millis();
		try {<commit_msg>invalid method call<commit_after>package lucee.runtime.osgi;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleReference;

import lucee.commons.io.IOUtil;
import lucee.commons.io.SystemUtil;
import lucee.commons.io.log.Log;
import lucee.commons.lang.StringUtil;
import lucee.loader.engine.CFMLEngineFactory;
import lucee.runtime.config.Config;
import lucee.runtime.config.ConfigPro;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.text.xml.XMLUtil;

public class EnvClassLoader extends URLClassLoader {

	private static float FROM_SYSTEM = 1;
	private static float FROM_BOOTDELEGATION = 2;
	private static float FROM_CALLER = 3;

	private static SoftReference<String> EMPTY = new SoftReference<String>(null);
	private static Map<SoftReference<String>, SoftReference<String>> notFound = new java.util.concurrent.ConcurrentHashMap<>();

	private Config config;
	private Map<String, SoftReference<Object[]>> callerCache = new ConcurrentHashMap<String, SoftReference<Object[]>>();
	private Log trace;

	private static final short CLASS = 1;
	private static final short URL = 2;
	private static final short STREAM = 3;

	private static ThreadLocal<Set<String>> checking = new ThreadLocal<Set<String>>() {
		@Override
		protected Set<String> initialValue() {
			return new HashSet<>();
		}
	};

	private static ThreadLocal<Boolean> inside = new ThreadLocal<Boolean>() {
		@Override
		protected Boolean initialValue() {
			return Boolean.FALSE;
		}
	};

	private static final EnvClassLoader NULL_INSTANCE = new EnvClassLoader(null);

	public static EnvClassLoader getInstance(ConfigPro config) {
		config = (ConfigPro) ThreadLocalPageContext.getConfig(config);
		if (config != null) return (EnvClassLoader) config.getClassLoaderEnv();

		return NULL_INSTANCE;
	}

	public EnvClassLoader(ConfigPro config) {
		super(new URL[0], config != null ? config.getClassLoaderCore() : new lucee.commons.lang.ClassLoaderHelper().getClass().getClassLoader());
		this.config = config;
		this.trace = log(Log.LEVEL_TRACE);
	}

	@Override
	public Class<?> loadClass(String name) throws ClassNotFoundException {
		return loadClass(name, false);
	}

	@Override
	public URL getResource(String name) {
		if (trace == null) {
			return (java.net.URL) load(name, URL, true, null, true);
		}
		double start = SystemUtil.millis();
		try {
{'fraction_non_alphanumeric': 0.10847701149425287, 'fraction_numerical': 0.002514367816091954, 'mean_word_length': 5.606168446026097, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6268986', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1679, 'n_words': 420}