aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2017-01-25 11:43:10 +0000
committerPaul Duffin <paulduffin@google.com>2017-02-22 11:21:10 +0000
commit9599ee2623bb76c0c7f840ba8bfd92a6ecf74390 (patch)
tree873cd708d3c6fb36684c53bc506ff3940c3ec3f0
parent32dc498f7b8622c59d4b77117eb971ed0a553be5 (diff)
downloadhamcrest-9599ee2623bb76c0c7f840ba8bfd92a6ecf74390.tar.gz
Temporarily add void is(Class) to cause compile time errors
The is(Class) method was removed upstream between Hamcrest 1.1 and 1.3 in favour of the instanceOf(Class) method. Unfortunately, existing usages of it could still compile against the is(Object) method instead. Although not every existing usage would compile successfully it is possible that some could and that would result in a change in the runtime behavior that could be difficult to detect and fix. This change aims to turn any significant usage of this method into a compile time error. Bug: 30946317 Test: make checkbuild Change-Id: I48d1c80fb9faae4e4c490f30c9fe0275fd66a58b
-rw-r--r--hamcrest-core/src/main/java/org/hamcrest/CoreMatchers.java16
-rw-r--r--hamcrest-library/src/main/java/org/hamcrest/Matchers.java16
2 files changed, 32 insertions, 0 deletions
diff --git a/hamcrest-core/src/main/java/org/hamcrest/CoreMatchers.java b/hamcrest-core/src/main/java/org/hamcrest/CoreMatchers.java
index ada655a..799a26a 100644
--- a/hamcrest-core/src/main/java/org/hamcrest/CoreMatchers.java
+++ b/hamcrest-core/src/main/java/org/hamcrest/CoreMatchers.java
@@ -115,6 +115,22 @@ public class CoreMatchers {
}
/**
+ * Provided to cause compile time error when used in preference to a possible runtime error if
+ * this was not here.
+ *
+ * <p>This method was removed upstream between Hamcrest 1.1 and 1.3 in favour of the
+ * instanceOf(Class) method. Unfortunately, existing usages of it could still compile against the
+ * {@link #is(Object)} method instead. Although not every existing usage would compile
+ * successfully it is possible that some could and that would result in a change in the runtime
+ * behavior that could be difficult to detect and fix. This change aims to turn any significant
+ * usage of this method into a compile time error.
+ *
+ * @deprecated Use instanceOf(SomeClass.class) instead.
+ */
+ public static void is(java.lang.Class<?> type) {
+ }
+
+ /**
* A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>.
* For example:
* <pre>assertThat(cheese, isA(Cheddar.class))</pre>
diff --git a/hamcrest-library/src/main/java/org/hamcrest/Matchers.java b/hamcrest-library/src/main/java/org/hamcrest/Matchers.java
index ca1238d..b04c45d 100644
--- a/hamcrest-library/src/main/java/org/hamcrest/Matchers.java
+++ b/hamcrest-library/src/main/java/org/hamcrest/Matchers.java
@@ -201,6 +201,22 @@ public class Matchers {
}
/**
+ * Provided to cause compile time error when used in preference to a possible runtime error if
+ * this was not here.
+ *
+ * <p>This method was removed upstream between Hamcrest 1.1 and 1.3 in favour of the
+ * instanceOf(Class) method. Unfortunately, existing usages of it could still compile against the
+ * {@link #is(Object)} method instead. Although not every existing usage would compile
+ * successfully it is possible that some could and that would result in a change in the runtime
+ * behavior that could be difficult to detect and fix. This change aims to turn any significant
+ * usage of this method into a compile time error.
+ *
+ * @deprecated Use instanceOf(SomeClass.class) instead.
+ */
+ public static void is(java.lang.Class<?> type) {
+ }
+
+ /**
* A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>.
* For example:
* <pre>assertThat(cheese, isA(Cheddar.class))</pre>