Codebase list libxstream-java / c194602 debian / patches / 01-java7-compatibility.patch
c194602

Tree @c194602 (Download .tar.gz)

01-java7-compatibility.patch @c194602raw · history · blame

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;
+        }
+    }
 }