From 91c8bbacc728ee9336f891a2e908307d3e434c32 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 16 Feb 2012 18:14:39 -0600 Subject: [PATCH] [Bleeding] Skip InvocationTargetException. Addresses BUKKIT-774 By: Wesley Wolfe --- .../serialization/ConfigurationSerialization.java | 11 +++++++++-- .../java/org/bukkit/plugin/java/JavaPluginLoader.java | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java b/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java index 3b2b67b903..6f6308801c 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java +++ b/paper-api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java @@ -1,6 +1,7 @@ package org.bukkit.configuration.serialization; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashMap; @@ -68,7 +69,10 @@ public class ConfigurationSerialization { return result; } } catch (Throwable ex) { - Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + clazz + " for deserialization", ex); + Logger.getLogger(ConfigurationSerialization.class.getName()).log( + Level.SEVERE, + "Could not call method '" + method.toString() + "' of " + clazz + " for deserialization", + ex instanceof InvocationTargetException ? ex.getCause() : ex); } return null; @@ -78,7 +82,10 @@ public class ConfigurationSerialization { try { return ctor.newInstance(args); } catch (Throwable ex) { - Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call constructor '" + ctor.toString() + "' of " + clazz + " for deserialization", ex); + Logger.getLogger(ConfigurationSerialization.class.getName()).log( + Level.SEVERE, + "Could not call constructor '" + ctor.toString() + "' of " + clazz + " for deserialization", + ex instanceof InvocationTargetException ? ex.getCause() : ex); } return null; diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index b11439b79e..b31457dd71 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -5,6 +5,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.util.ArrayList; @@ -143,6 +144,8 @@ public class JavaPluginLoader implements PluginLoader { result = constructor.newInstance(); result.initialize(this, server, description, dataFolder, file, loader); + } catch (InvocationTargetException ex) { + throw new InvalidPluginException(ex.getCause()); } catch (Throwable ex) { throw new InvalidPluginException(ex); } @@ -298,6 +301,8 @@ public class JavaPluginLoader implements PluginLoader { return; } method.invoke(listener, event); + } catch (InvocationTargetException ex) { + throw new EventException(ex.getCause()); } catch (Throwable t) { throw new EventException(t); }