File: 01-java7-compatibility.patch

package info (click to toggle)
libxstream-java 1.4.9-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,816 kB
  • ctags: 9,108
  • sloc: java: 48,081; xml: 2,233; sh: 28; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Description: Replaces the call to Method.isDefault() by a reflexive call to compile with Java 7
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- a/xstream/src/java/com/thoughtworks/xstream/mapper/LambdaMapper.java
+++ b/xstream/src/java/com/thoughtworks/xstream/mapper/LambdaMapper.java
@@ -42,7 +42,7 @@
                     for (int i = 0; replacement == null && i < interfaces.length; i++) {
                         final Class<?> iface = interfaces[i];
                         for (final Method method : iface.getMethods()) {
-                            if (!method.isDefault() && !Modifier.isStatic(method.getModifiers())) {
+                            if (!isDefault(method) && !Modifier.isStatic(method.getModifiers())) {
                                 replacement = iface;
                                 break;
                             }
@@ -57,4 +57,12 @@
         }
         return super.serializedClass(replacement == null ? type : replacement);
     }
+
+    private boolean isDefault(Method m) {
+        try {
+            return (Boolean) Method.class.getMethod("isDefault").invoke(m);
+        } catch (Exception e) {
+            return false;
+        }
+    }
 }