Merge
authorprr
Wed, 29 Apr 2015 09:44:24 -0700
changeset 30490 2c6afe93e4cd
parent 30489 7ea6d8a61086 (current diff)
parent 30488 3a8007752b94 (diff)
child 30491 ea1c291ee28f
Merge
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/FrameSetView.java	Wed Apr 29 08:52:47 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/FrameSetView.java	Wed Apr 29 09:44:24 2015 -0700
@@ -126,7 +126,7 @@
                 if (children[i].length() > 1) {
                     relativeChildren[i] =
                         Integer.parseInt(children[i].substring(
-                            0, children[i].length()-1));
+                            0, children[i].length()-1).trim());
                     relativeTotals += relativeChildren[i];
                 } else {
                     relativeChildren[i] = 1;
@@ -136,7 +136,11 @@
                 percentChildren[i] = parseDigits(children[i]);
                 percentTotals += percentChildren[i];
             } else {
-                absoluteChildren[i] = Integer.parseInt(children[i]);
+                String value = children[i].toLowerCase();
+                if (value.endsWith("px")) {
+                    value = value.substring(0, value.length()-2).trim();
+                }
+                absoluteChildren[i] = Integer.parseInt(value);
             }
         }
         if (percentTotals > 100) {
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAutoShutdown.java	Wed Apr 29 08:52:47 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAutoShutdown.java	Wed Apr 29 09:44:24 2015 -0700
@@ -26,7 +26,6 @@
 package sun.awt;
 
 import java.awt.AWTEvent;
-
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.HashSet;
@@ -34,9 +33,9 @@
 import java.util.Map;
 import java.util.Set;
 
+import sun.awt.util.ThreadGroupUtils;
 import sun.misc.InnocuousThread;
 import sun.util.logging.PlatformLogger;
-import sun.awt.util.ThreadGroupUtils;
 
 /**
  * This class is to let AWT shutdown automatically when a user is done
@@ -218,10 +217,7 @@
         synchronized (activationLock) {
             synchronized (mainLock) {
                 if (!isReadyToShutdown() && blockerThread == null) {
-                    AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-                        activateBlockerThread();
-                        return null;
-                    });
+                    activateBlockerThread();
                 } else {
                     mainLock.notifyAll();
                     timeoutPassed = false;
@@ -337,21 +333,22 @@
     /**
      * Creates and starts a new blocker thread. Doesn't return until
      * the new blocker thread starts.
-     *
-     * Must be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
      */
     private void activateBlockerThread() {
-        Thread thread;
-        String name =  "AWT-Shutdown";
-        if (System.getSecurityManager() == null) {
-            thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, name);
-        } else {
-            thread = new InnocuousThread(this, name);
-        }
-        thread.setContextClassLoader(null);
-        thread.setDaemon(false);
-        blockerThread = thread;
-        thread.start();
+        AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
+            Thread thread;
+            String name = "AWT-Shutdown";
+            if (System.getSecurityManager() == null) {
+                thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this,
+                                    name);
+            } else {
+                thread = new InnocuousThread(this, name);
+            }
+            thread.setContextClassLoader(null);
+            thread.setDaemon(false);
+            blockerThread = thread;
+            return thread;
+        }).start();
         try {
             /* Wait for the blocker thread to start. */
             mainLock.wait();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/8031109/bug8031109.java	Wed Apr 29 09:44:24 2015 -0700
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.net.URL;
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.swing.text.EditorKit;
+/*
+ * @test
+ * @bug 8031109
+ * @author Victor Dyakov
+ * @summary  Rendering HTML code in JEditorPane throws NumberFormatException
+ * @run main bug8031109
+ */
+public class bug8031109 {
+
+    private static final String TEXT_HTML = "text/html";
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                JEditorPane editorPane = new JEditorPane();
+                editorPane.setEditable(false);
+                EditorKit defaultHtmlEditor = JEditorPane
+                        .createEditorKitForContentType(TEXT_HTML);
+                editorPane.setEditorKitForContentType(TEXT_HTML, defaultHtmlEditor);
+                editorPane.setContentType(TEXT_HTML);
+                editorPane.getDocument().putProperty("IgnoreCharsetDirective",
+                        Boolean.TRUE);
+                URL url = generateHtmlFile();
+                String html = "<html>"
+                        + "<frameset rows=\"120px, 120 PX ,  * , 10 *\">\n"
+                        + "   <frame name=\"top\" src=\"" + url + "\" />\n"
+                        + "   <frame name=\"center\" src=\"" + url + "\" />\n"
+                        + "   <frame name=\"main\" src=\"" + url + "\" />\n"
+                        + "   <noframes>\n"
+                        + "   <body>\n"
+                        + "      Your browser does not support frames.\n"
+                        + "   </body>\n"
+                        + "   </noframes>\n"
+                        + "</frameset>";
+                editorPane.setText(html);
+                JScrollPane scrollPane = new JScrollPane(editorPane);
+
+                JFrame frame = new JFrame();
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                frame.getContentPane().add(scrollPane);
+                frame.setSize(500, 500);
+                frame.setVisible(true);
+            }
+        });
+    }
+
+    private static URL generateHtmlFile() {
+        File file = new File("hello.html");
+        try (
+                FileWriter fw = new FileWriter(file.getAbsoluteFile());
+                BufferedWriter bw = new BufferedWriter(fw);) {
+            bw.write("<head></head><body>Hello World!</body>");
+            return file.toURI().toURL();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}