8154801: deprecate Observer and Observable
authorsmarks
Thu, 28 Apr 2016 14:29:09 -0700
changeset 37682 faf3ae8eefc7
parent 37681 b1a0f119f766
child 37683 bb46e12e08a0
child 38342 cc0c454f13c8
8154801: deprecate Observer and Observable Reviewed-by: darcy
jdk/src/java.base/share/classes/java/util/Observable.java
jdk/src/java.base/share/classes/java/util/Observer.java
--- a/jdk/src/java.base/share/classes/java/util/Observable.java	Thu Apr 28 09:38:19 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Observable.java	Thu Apr 28 14:29:09 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,19 @@
  * @see     java.util.Observer
  * @see     java.util.Observer#update(java.util.Observable, java.lang.Object)
  * @since   1.0
+ *
+ * @deprecated
+ * This class and the {@link Observer} interface have been deprecated.
+ * The event model supported by {@code Observer} and {@code Observable}
+ * is quite limited, the order of notifications delivered by
+ * {@code Observable} is unspecified, and state changes are not in
+ * one-for-one correspondence with notifications.
+ * For a richer event model, consider using the
+ * {@link java.beans} package.  For reliable and ordered
+ * messaging among threads, consider using one of the concurrent data
+ * structures in the {@link java.util.concurrent} package.
  */
+@Deprecated(since="9")
 public class Observable {
     private boolean changed = false;
     private Vector<Observer> obs;
--- a/jdk/src/java.base/share/classes/java/util/Observer.java	Thu Apr 28 09:38:19 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Observer.java	Thu Apr 28 14:29:09 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,12 @@
  * @author  Chris Warth
  * @see     java.util.Observable
  * @since   1.0
+ *
+ * @deprecated
+ * This interface has been deprecated. See the {@link Observable}
+ * class for further information.
  */
+@Deprecated(since="9")
 public interface Observer {
     /**
      * This method is called whenever the observed object is changed. An