瀏覽代碼

Make LogUtils try some more ctors.

NoClassDefFoundError only takes a message (no source). Try
throwable-only and message-only ctors in addition to the
two-arg ctors.
pull/697/head
Chris Smith 7 年之前
父節點
當前提交
6c4b7ffc41
共有 1 個檔案被更改,包括 11 行新增1 行删除
  1. 11
    1
      src/main/java/com/dmdirc/util/LogUtils.java

+ 11
- 1
src/main/java/com/dmdirc/util/LogUtils.java 查看文件

@@ -133,7 +133,17 @@ public final class LogUtils {
133 133
             }
134 134
 
135 135
             if (throwable == null) {
136
-                throw new ReflectiveOperationException("Unable to find ctor of " + clazz);
136
+                try {
137
+                    // Or maybe just a throwable?
138
+                    throwable = clazz.getConstructor(Throwable.class).newInstance(getThrowable(proxy.getCause()));
139
+                } catch (NoSuchMethodException ex) {
140
+                    try {
141
+                        throwable = clazz.getConstructor(String.class).newInstance(proxy.getMessage());
142
+                    } catch (NoSuchMethodException ex2) {
143
+                        // *Shrug*
144
+                        throw new ReflectiveOperationException("Unable to find ctor of " + clazz);
145
+                    }
146
+                }
137 147
             }
138 148
         }
139 149
         throwable.setStackTrace(getStackTraceElements(proxy.getStackTraceElementProxyArray()));

Loading…
取消
儲存