Closed
Description
I am integrating this library into a Minecraft Bukkit plugin and it seems like TransportBuilder
is unable to find any transport providers despite the fact that two of them are listed in the service definitions inside the jar.
After some investigation, it looks like plugin class loader instance is needed for ServiceLoader
to correctly find provider classes...
This works:
@Override
public void onEnable() {
ServiceLoader<ITransportProvider> spiLoader = ServiceLoader.load(ITransportProvider.class, this.getClass().getClassLoader());
}
This doesn't:
@Override
public void onEnable() {
ServiceLoader<ITransportProvider> spiLoader = ServiceLoader.load(ITransportProvider.class);
}
Currently field TransportBuilder#PROVIDERS
is to be initialized with static life time. This leaves no way to properly initialize this field from a bukkit plugin even with reflection as attempting to reflect-assign this field causes lazy initialization and thus invoke getTransportProvider()
(which will call ServiceLoader without a correct class loader).
Metadata
Assignees
Labels
No labels
Activity