mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-11 10:12:06 -07:00
SPIGOT-5548: Show error that hints towards plugins misusing reflection
By: md_5 <git@md-5.net>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.plugin.java;
|
package org.bukkit.plugin.java;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -9,8 +10,8 @@ import java.net.URL;
|
|||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.security.CodeSigner;
|
import java.security.CodeSigner;
|
||||||
import java.security.CodeSource;
|
import java.security.CodeSource;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -39,7 +40,7 @@ final class PluginClassLoader extends URLClassLoader {
|
|||||||
final JavaPlugin plugin;
|
final JavaPlugin plugin;
|
||||||
private JavaPlugin pluginInit;
|
private JavaPlugin pluginInit;
|
||||||
private IllegalStateException pluginState;
|
private IllegalStateException pluginState;
|
||||||
private final Set<String> seenIllegalAccess = new HashSet<>();
|
private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ClassLoader.registerAsParallelCapable();
|
ClassLoader.registerAsParallelCapable();
|
||||||
@@ -107,6 +108,7 @@ final class PluginClassLoader extends URLClassLoader {
|
|||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
JavaPlugin provider = ((PluginClassLoader) result.getClassLoader()).plugin;
|
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();
|
String providerName = provider.getName();
|
||||||
|
|
||||||
if (provider != plugin
|
if (provider != plugin
|
||||||
|
Reference in New Issue
Block a user