use of org.lanternpowered.launch.transformer.Exclusion in project LanternServer by LanternPowered.
the class LanternClassLoader method findClass.
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
// The class loading failed before
if (this.invalidClasses.contains(name)) {
throw new ClassNotFoundException(name);
}
if (this.cachedClasses.containsKey(name)) {
return this.cachedClasses.get(name);
}
final String fileName = name.replace('.', '/').concat(".class");
// Try the server classes
URL url = findResource(fileName);
if (url == null) {
// Try library classes
url = this.libraryClassLoader.findResource(fileName);
if (url == null) {
this.invalidClasses.add(name);
throw new ClassNotFoundException(name);
}
// Just load the library class
return defineClass(name, url, false);
}
if (this.transformers.isEmpty()) {
// Don't bother if there are no transformers
return defineClass(name, url, false);
}
// Check if the class should be ignored by any kind of transformer
for (Exclusion exclusion : this.transformerExclusions) {
if (exclusion.isApplicable(name)) {
// Just load the class in this case
return defineClass(name, url, false);
}
}
return defineClass(name, url, true);
}
use of org.lanternpowered.launch.transformer.Exclusion in project LanternServer by LanternPowered.
the class LanternClassLoader method addTransformerExclusions.
/**
* Adds the {@link Exclusion}s. All the excluded classes
* will be skipped by the {@link ClassTransformer}s.
*
* @param exclusions The exclusions
*/
public void addTransformerExclusions(Iterable<Exclusion> exclusions) {
requireNonNull(exclusions, "exclusions");
final List<Exclusion> exclusionList = new ArrayList<>();
for (Exclusion exclusion : exclusions) {
requireNonNull(exclusion, "exclusion");
exclusionList.add(exclusion);
}
this.transformerExclusions.addAll(exclusionList);
}
Aggregations