org.adoptopenjdk.jitwatch.util.ClassUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jitwatch-jarscan-maven-plugin Show documentation
Show all versions of jitwatch-jarscan-maven-plugin Show documentation
A Maven plugin that scans the project artifact and its dependencies for methods that cannot be inlined by the JIT
compiler. It uses the JarScan utility from the JITWatch project to do that.
See https://github.com/AdoptOpenJDK/jitwatch .
The newest version!
/*
* Copyright (c) 2013-2015 Chris Newland.
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/
package org.adoptopenjdk.jitwatch.util;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.*;
import org.adoptopenjdk.jitwatch.loader.DisposableURLClassLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public final class ClassUtil
{
private static DisposableURLClassLoader disposableClassLoader = new DisposableURLClassLoader(new ArrayList());
private static final Logger logger = LoggerFactory.getLogger(ClassUtil.class);
private ClassUtil()
{
}
public static void initialise(final List urls)
{
if (DEBUG_LOGGING_CLASSPATH)
{
for (URL url : urls)
{
logger.debug("Adding classpath to DisposableURLClassLoader {}", url);
}
}
disposableClassLoader = new DisposableURLClassLoader(urls);
}
public static Class> loadClassWithoutInitialising(String fqClassName) throws ClassNotFoundException
{
if (DEBUG_LOGGING_CLASSPATH)
{
logger.debug("loadClassWithoutInitialising '{}'", fqClassName);
}
return Class.forName(fqClassName, false, disposableClassLoader);
}
public static Class> loadClassWithoutInitialising(String fqClassName, ClassLoader classLoader) throws ClassNotFoundException
{
return Class.forName(fqClassName, false, classLoader);
}
}