Package org.sonar.java.bytecode.loader
Class SquidClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- org.sonar.java.bytecode.loader.SquidClassLoader
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class SquidClassLoader extends ClassLoader implements Closeable
Class loader, which is able to load classes from a list of JAR files and directories.
-
-
Constructor Summary
Constructors Constructor Description SquidClassLoader(List<File> files)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this class loader, so that it can no longer be used to load new classes or resources.protected ClassfindClass(String name)URLfindResource(String name)protected Enumeration<URL>findResources(String name)byte[]getBytesForClass(String className)Read bytes representing class with name passed as an argument.-
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
Method Detail
-
findClass
protected Class findClass(String name) throws ClassNotFoundException
- Overrides:
findClassin classClassLoader- Throws:
ClassNotFoundException
-
findResource
public URL findResource(String name)
- Overrides:
findResourcein classClassLoader
-
findResources
protected Enumeration<URL> findResources(String name) throws IOException
- Overrides:
findResourcesin classClassLoader- Throws:
IOException
-
getBytesForClass
@CheckForNull public byte[] getBytesForClass(String className)
Read bytes representing class with name passed as an argument. Modify the class version in bytecode so ASM can read returned array without issues.- Parameters:
className- canonical name of the class (e.g. org.acme.Foo )- Returns:
- bytes or null if class is not found
-
close
public void close()
Closes this class loader, so that it can no longer be used to load new classes or resources. Any classes or resources that are already loaded, are still accessible. If class loader is already closed, then invoking this method has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-