mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 18:12:09 +01:00
Improve dependency tracker
By: md_5 <git@md-5.net>
This commit is contained in:
parent
99378a8c91
commit
d962970177
2 changed files with 8 additions and 11 deletions
|
@ -796,11 +796,11 @@ public final class SimplePluginManager implements PluginManager {
|
|||
return new HashSet<Permission>(permissions.values());
|
||||
}
|
||||
|
||||
public boolean isTransitiveDepend(@NotNull PluginDescriptionFile plugin, @NotNull Plugin depend) {
|
||||
public boolean isTransitiveDepend(@NotNull PluginDescriptionFile plugin, @NotNull PluginDescriptionFile depend) {
|
||||
Preconditions.checkArgument(plugin != null, "plugin");
|
||||
Preconditions.checkArgument(depend != null, "depend");
|
||||
|
||||
return Graphs.reachableNodes(dependencyGraph, plugin.getName()).contains(depend.getName());
|
||||
return dependencyGraph.nodes().contains(plugin.getName()) && Graphs.reachableNodes(dependencyGraph, plugin.getName()).contains(depend.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bukkit.plugin.java;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -108,20 +107,18 @@ final class PluginClassLoader extends URLClassLoader {
|
|||
result = loader.getClassByName(name);
|
||||
|
||||
if (result != null) {
|
||||
JavaPlugin provider = ((PluginClassLoader) result.getClassLoader()).plugin;
|
||||
Preconditions.checkState(provider != null, "Globally provided class %s has no plugin. Perhaps broken reflection is in use.", name);
|
||||
String providerName = provider.getName();
|
||||
PluginDescriptionFile provider = ((PluginClassLoader) result.getClassLoader()).description;
|
||||
|
||||
if (provider != plugin
|
||||
&& !seenIllegalAccess.contains(providerName)
|
||||
if (provider != description
|
||||
&& !seenIllegalAccess.contains(provider.getName())
|
||||
&& !((SimplePluginManager) loader.server.getPluginManager()).isTransitiveDepend(description, provider)) {
|
||||
|
||||
seenIllegalAccess.add(providerName);
|
||||
seenIllegalAccess.add(provider.getName());
|
||||
if (plugin != null) {
|
||||
plugin.getLogger().log(Level.WARNING, "Loaded class {0} from {1} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{name, provider.getDescription().getFullName()});
|
||||
plugin.getLogger().log(Level.WARNING, "Loaded class {0} from {1} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{name, provider.getFullName()});
|
||||
} else {
|
||||
// In case the bad access occurs on construction
|
||||
loader.server.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{description.getName(), name, provider.getDescription().getFullName()});
|
||||
loader.server.getLogger().log(Level.WARNING, "[{0}] Loaded class {1} from {2} which is not a depend, softdepend or loadbefore of this plugin.", new Object[]{description.getName(), name, provider.getFullName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue