components/junit/patches/java8.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Tue, 16 Jun 2015 08:01:42 -0700
branchs11-update
changeset 4487 ec7d06d6b64e
parent 4212 7fdccaa4b284
permissions -rw-r--r--
15822919 SUNBT7204858 Upgrade UnixODBC to 2.3.1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4212
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     1
This is the community's fix for using Java 8.
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     2
Community bug:
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     3
https://github.com/junit-team/junit/issues/749
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     4
Community code:
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     5
https://github.com/stefanbirkner/junit/commit/69de4c23996fe320e8345f273e2e35e529f0fdf3
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     6
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     7
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     8
--- junit-r4.11/src/main/java/org/junit/internal/MethodSorter.java.orig	Thu Oct  9 11:09:18 2014
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     9
+++ junit-r4.11/src/main/java/org/junit/internal/MethodSorter.java	Thu Oct  9 11:14:09 2014
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    10
@@ -1,8 +1,10 @@
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    11
 package org.junit.internal;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    12
 
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    13
 import java.lang.reflect.Method;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    14
-import java.util.Arrays;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    15
+import java.util.ArrayList;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    16
+import java.util.Collections;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    17
 import java.util.Comparator;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    18
+import java.util.List;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    19
 
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    20
 import org.junit.FixMethodOrder;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    21
 
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    22
@@ -52,11 +54,16 @@
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    23
         Comparator<Method> comparator = getSorter(clazz.getAnnotation(FixMethodOrder.class));
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    24
 
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    25
         Method[] methods = clazz.getDeclaredMethods();
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    26
+        List<Method> x = new ArrayList<Method>();
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    27
+        for (Method method : methods)
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    28
+            if (!method.isBridge() && !method.isSynthetic())
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    29
+                x.add(method);
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    30
+
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    31
         if (comparator != null) {
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    32
-            Arrays.sort(methods, comparator);
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    33
+            Collections.sort(x, comparator);
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    34
         }
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    35
 
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    36
-        return methods;
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    37
+        return x.toArray(new Method[x.size()]);
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    38
     }
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    39
 
7fdccaa4b284 19789496 junit does not build with java 8
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    40
     private MethodSorter() {