changeset 9190:22e4a79f55d4 9-b73

Automated merge with http://hg.openjdk.java.net/openjfx/9-dev/rt
author kcr
date Mon, 13 Jul 2015 18:23:46 -0700
parents c0935d9bc932 4c7bb3801798
children 4ac6095398cf 9a1412716adf 0ba8ff7c29c7
files
diffstat 19 files changed, 183 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Jul 13 12:38:20 2015 -0700
+++ b/.hgtags	Mon Jul 13 18:23:46 2015 -0700
@@ -292,28 +292,37 @@
 adae30a7fe1ec2eb45de08ba3c58a276a60a73bf 8u60-b02
 9a0bb4610ea0e3fe93008c8ddf2757fdb9c3be35 8u45-b08
 5d3d6549067c18396d4f6a97adef23739c0ff57a 9-b51
+d488fa8851887680a690803f28112ed0a0776e53 8u51-b01
 298ec4ec6b354f2eb74a200b3415bc4566ddc1a7 8u40-b26
 13970a967383d6fa104858157d327c78077fe3b9 8u60-b03
 88882082520b7195b4e669955782ffc6757db7ac 8u45-b09
 3673a70e0e5ea4b26fbff1b29d8151ff147fdce9 9-b52
+1a31f06296ebb5d60cc22fe43420e430d6ecba61 8u51-b02
 e00e97499831954b5126d96da1299b1ecdf69e15 8u40-b27
 b76562e466d6e8b47e1d7b2cdb64eb53578eae7b 8u60-b04
 323febe44dc27bead06e734e3d71a1e0020e0c56 9-b53
 5fc0ddb4277679b69970d2993fefcda1fb711ae7 8u60-b05
 7f80261fd43cd42488dae00fb0e534ea40529bd4 9-b54
 f5b6e9bfedc64c3bc27d1fdd8888f5386b9c9f36 8u45-b10
+93a6bf73d3d06258dd48f958ec4f2eb91b1a7871 8u51-b03
 f5b6e9bfedc64c3bc27d1fdd8888f5386b9c9f36 8u45-b11
+2c2927b800ee06cf2a0216b07f0c7a1aa92e85b5 8u51-b04
 63e96de9d0965ad671cc7694a15b651a15dff9ed 8u45-b12
 93e3b40039ac3c0d6086e15d86dc8127d28f1587 8u45-b13
 5fc0ddb4277679b69970d2993fefcda1fb711ae7 8u60-b06
 cbe942c0e3bb4ece7864a1840af15e5ae49cb9a9 9-b55
-f5b6e9bfedc64c3bc27d1fdd8888f5386b9c9f36 8u45-b11
-b7d32ba7de74acdc83b06ca4d82c6c5e30946cd8 8u45-b11
+8f360f8f1f9a4c12856a085b8c732e27963d3c23 8u51-b05
+e7d9670a725c567dd5d7161865b16983b0929a1b 8u51-b06
 537f7640d63cf8e0b37592a62604a7d29b606c48 8u60-b06
 2f8b9acb3035b798db982f4ce957ada7f3a0f672 8u60-b07
 28006a7446da8cb8f4d30f8821120c9702ceb9ed 8u60-b08
+f5b6e9bfedc64c3bc27d1fdd8888f5386b9c9f36 8u45-b11
+b7d32ba7de74acdc83b06ca4d82c6c5e30946cd8 8u45-b11
+9623a72711f88683fc1e4f2c5a2bfc9c565a6544 8u51-b07
 5a7451f667fc559613b35acca4520158fed3d865 9-b56
+2c85d158a09c401e0338943f8bbf1050027e9bcc 8u51-b08
 da5be0935d4b288d72846c867301ac274258e61d 9-b57
+1f6939b73280bd5d93e4e2bd7e56db698009639e 8u51-b09
 de031c9cec1fc739295e70052621d2a877485b12 9-b58
 c76fdbcbd413576c1adf32ed0a7328974efe606e 9-b59
 24bd4905d09f0893383026e8ceb76eee01a05ec9 9-b60
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/base/src/main/java/com/sun/javafx/property/adapter/Disposer.java	Mon Jul 13 18:23:46 2015 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.property.adapter;
+
+import java.lang.ref.PhantomReference;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * This class is used for registering and disposing various
+ * data associated with java objects.
+ *
+ * The object can register itself by calling the addRecord method and
+ * providing a descendant of the Runnable class with overridden
+ * run() method.
+ *
+ * When the object becomes phantom-reachable, the run() method
+ * of the associated Runnable object will be called.
+ */
+public class Disposer implements Runnable {
+    private static final ReferenceQueue queue = new ReferenceQueue();
+    private static final Map<Object, Runnable> records = new ConcurrentHashMap<>();
+    private static Disposer disposerInstance;
+
+    static {
+        disposerInstance = new Disposer();
+
+        java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction() {
+                public Object run() {
+                    /* The thread must be a member of a thread group
+                     * which will not get GCed before VM exit.
+                     * Make its parent the top-level thread group.
+                     */
+                    ThreadGroup tg = Thread.currentThread().getThreadGroup();
+                    for (ThreadGroup tgn = tg;
+                         tgn != null;
+                         tg = tgn, tgn = tg.getParent());
+                    Thread t =
+                        new Thread(tg, disposerInstance, "Property Disposer");
+                    t.setContextClassLoader(null);
+                    t.setDaemon(true);
+                    t.setPriority(Thread.MAX_PRIORITY);
+                    t.start();
+                    return null;
+                }
+            }
+        );
+    }
+
+    /**
+     * Registers the object and the data for later disposal.
+     * @param target Object to be registered
+     * @param rec the associated Runnable object
+     */
+    public static void addRecord(Object target, Runnable rec) {
+        PhantomReference ref = new PhantomReference<>(target, queue);
+        records.put(ref, rec);
+    }
+
+    public void run() {
+        while (true) {
+            try {
+                Object obj = queue.remove();
+                ((Reference)obj).clear();
+                Runnable rec = (Runnable)records.remove(obj);
+                rec.run();
+            } catch (Exception e) {
+                System.out.println("Exception while removing reference: " + e);
+                e.printStackTrace();
+            }
+        }
+    }
+}
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanBooleanProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanBooleanProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -26,6 +26,7 @@
 package javafx.beans.property.adapter;
 
 import com.sun.javafx.binding.ExpressionHelper;
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.PropertyDescriptor;
 import javafx.beans.InvalidationListener;
 import javafx.beans.property.BooleanProperty;
@@ -34,7 +35,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessControlContext;
 import java.security.AccessController;
@@ -77,7 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Boolean>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanDoubleProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanDoubleProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -26,6 +26,7 @@
 package javafx.beans.property.adapter;
 
 import com.sun.javafx.binding.ExpressionHelper;
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.PropertyDescriptor;
 import javafx.beans.InvalidationListener;
 import javafx.beans.property.DoubleProperty;
@@ -34,7 +35,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessControlContext;
 import java.security.AccessController;
@@ -77,7 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanFloatProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanFloatProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -26,6 +26,7 @@
 package javafx.beans.property.adapter;
 
 import com.sun.javafx.binding.ExpressionHelper;
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.PropertyDescriptor;
 import javafx.beans.InvalidationListener;
 import javafx.beans.property.FloatProperty;
@@ -34,7 +35,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessControlContext;
 import java.security.AccessController;
@@ -77,7 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanIntegerProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanIntegerProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -26,6 +26,7 @@
 package javafx.beans.property.adapter;
 
 import com.sun.javafx.binding.ExpressionHelper;
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.PropertyDescriptor;
 import javafx.beans.InvalidationListener;
 import javafx.beans.property.IntegerProperty;
@@ -34,7 +35,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessControlContext;
 import java.security.AccessController;
@@ -77,7 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanLongProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanLongProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -26,6 +26,7 @@
 package javafx.beans.property.adapter;
 
 import com.sun.javafx.binding.ExpressionHelper;
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.PropertyDescriptor;
 import javafx.beans.InvalidationListener;
 import javafx.beans.property.LongProperty;
@@ -34,7 +35,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessControlContext;
 import java.security.AccessController;
@@ -77,7 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanObjectProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanObjectProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -26,6 +26,7 @@
 package javafx.beans.property.adapter;
 
 import com.sun.javafx.binding.ExpressionHelper;
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.PropertyDescriptor;
 import javafx.beans.InvalidationListener;
 import javafx.beans.property.ObjectProperty;
@@ -34,7 +35,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -79,7 +79,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<T>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanStringProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanStringProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -26,6 +26,7 @@
 package javafx.beans.property.adapter;
 
 import com.sun.javafx.binding.ExpressionHelper;
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.PropertyDescriptor;
 import javafx.beans.InvalidationListener;
 import javafx.beans.property.StringProperty;
@@ -34,7 +35,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -77,7 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<String>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanBooleanProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanBooleanProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -25,12 +25,12 @@
 
 package javafx.beans.property.adapter;
 
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
 import javafx.beans.property.ReadOnlyBooleanPropertyBase;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -66,7 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Boolean>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanDoubleProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanDoubleProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -25,12 +25,12 @@
 
 package javafx.beans.property.adapter;
 
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
 import javafx.beans.property.ReadOnlyDoublePropertyBase;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -66,7 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanFloatProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanFloatProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -25,12 +25,12 @@
 
 package javafx.beans.property.adapter;
 
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
 import javafx.beans.property.ReadOnlyFloatPropertyBase;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -66,7 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanIntegerProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanIntegerProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -25,12 +25,12 @@
 
 package javafx.beans.property.adapter;
 
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
 import javafx.beans.property.ReadOnlyIntegerPropertyBase;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -66,7 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanLongProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanLongProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -25,12 +25,12 @@
 
 package javafx.beans.property.adapter;
 
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
 import javafx.beans.property.ReadOnlyLongPropertyBase;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -66,7 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanObjectProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanObjectProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -25,12 +25,12 @@
 
 package javafx.beans.property.adapter;
 
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
 import javafx.beans.property.ReadOnlyObjectPropertyBase;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -68,7 +68,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<T>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanStringProperty.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanStringProperty.java	Mon Jul 13 18:23:46 2015 -0700
@@ -25,12 +25,12 @@
 
 package javafx.beans.property.adapter;
 
+import com.sun.javafx.property.adapter.Disposer;
 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
 import javafx.beans.property.ReadOnlyStringPropertyBase;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
-import sun.misc.Cleaner;
 
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -66,7 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<String>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
+        Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/graphics/src/main/java/com/sun/javafx/font/CMap.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/CMap.java	Mon Jul 13 18:23:46 2015 -0700
@@ -45,6 +45,8 @@
     static final int SHORTMASK = 0x0000ffff;
     static final int INTMASK   = 0xffffffff;
 
+    private static final int MAX_CODE_POINTS = 0x10ffff;
+
     static CMap initialize(PrismFontFile font) {
 
         CMap cmap = null;
@@ -472,6 +474,11 @@
              buffer.position(offset+12);
              startCharCode = buffer.getInt() & INTMASK;
              numChars = buffer.getInt() & INTMASK;
+             if (numChars <= 0 || numChars > MAX_CODE_POINTS ||
+                 offset > buffer.capacity() - numChars*2 - 12 - 8)
+             {
+                 throw new RuntimeException("Invalid cmap subtable");   
+             }
              glyphIdArray = new char[numChars];
              for (int i=0; i< numChars; i++) {
                  glyphIdArray[i] = buffer.getChar();
@@ -504,6 +511,11 @@
         CMapFormat12(Buffer buffer, int offset) {
 
             numGroups = buffer.getInt(offset+12);
+            if (numGroups <= 0 || numGroups > MAX_CODE_POINTS ||
+                offset > buffer.capacity() - numGroups*12 - 12 - 4)
+            {
+                throw new RuntimeException("Invalid cmap subtable");
+            }
             startCharCode = new long[numGroups];
             endCharCode = new long[numGroups];
             startGlyphID = new int[numGroups];
--- a/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFile.java	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFile.java	Mon Jul 13 18:23:46 2015 -0700
@@ -512,6 +512,9 @@
 
             setStyle();
 
+            // sanity check the cmap table
+            checkCMAP();
+
             /* Get names last, as the name table is far from the file header.
              * Although its also likely too big to fit in the read cache
              * in which case that would remain valid, but also will help
@@ -824,6 +827,31 @@
         }
     }
 
+    private void checkCMAP() throws Exception {
+        DirectoryEntry cmapDE = getDirectoryEntry(FontConstants.cmapTag);
+        if (cmapDE != null) {
+            if (cmapDE.length < 4) {
+                throw new Exception("Invalid cmap table length");
+            }
+            Buffer cmapTableHeader = filereader.readBlock(cmapDE.offset, 4);
+            short version = cmapTableHeader.getShort();
+            short numberSubTables = cmapTableHeader.getShort();
+            int indexLength = numberSubTables * 8;
+            if (numberSubTables <= 0 || cmapDE.length < indexLength + 4) {
+                throw new Exception("Invalid cmap subtables count");
+            }
+            Buffer cmapTableIndex = filereader.readBlock(cmapDE.offset + 4, indexLength);
+            for (int i = 0; i < numberSubTables; i++) {
+                short platformID = cmapTableIndex.getShort();
+                short encodingID = cmapTableIndex.getShort();
+                int offset = cmapTableIndex.getInt();
+                if (offset < 0 || offset >= cmapDE.length) {
+                    throw new Exception("Invalid cmap subtable offset");
+                }
+            }
+        }
+    }
+    
     /*** BEGIN LOCALE_ID MAPPING ****/
 
     private static Map<String, Short> lcidMap;
--- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/GlyphPageTreeNodeJava.cpp	Mon Jul 13 12:38:20 2015 -0700
+++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/GlyphPageTreeNodeJava.cpp	Mon Jul 13 18:23:46 2015 -0700
@@ -23,6 +23,8 @@
     JLocalRef<jcharArray> jchars(env->NewCharArray(bufferLength));
     CheckAndClearException(env); // OOME
     ASSERT(jchars);
+    if (!jchars)
+        return false;
 
     jchar* chars = (jchar*)env->GetPrimitiveArrayCritical(jchars, NULL);
     ASSERT(chars);
@@ -33,6 +35,9 @@
     ASSERT(mid);
     JLocalRef<jintArray> jglyphs(static_cast<jintArray>(env->CallObjectMethod(*jFont, mid, (jcharArray)jchars)));
     CheckAndClearException(env);
+    ASSERT(jglyphs);
+    if (!jglyphs)
+        return false;
 
     Glyph* glyphs = (Glyph*)env->GetPrimitiveArrayCritical(jglyphs, NULL);
     ASSERT(glyphs);