<AWT Dev> [8] [PATCH] 6818083: When DISPLAY is bad, InternalError thrown, not AWTError
Mikhail Cherkasov
mikhail.cherkasov at oracle.com
Mon Oct 15 09:07:08 PDT 2012
Test was renamed to BadDisplayTest.
New patch is attached.
On 10/15/2012 6:42 PM, Anthony Petrov wrote:
> Hi Mikhail,
>
> The fix looks good to me. However, please consider naming the test
> files with human-readable names. E.g.
> test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java|.sh.
>
> --
> best regards,
> Anthony
>
> On 10/12/12 19:43, Mikhail Cherkasov wrote:
>> Hi all,
>>
>> Could you please review a fix for 6818083: When DISPLAY is bad,
>> InternalError thrown, not AWTError
>> Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6818083
>>
>> InternalError was replaced with AWTError. Patch is attached.
>>
>> Thanks,
>> Mikhail.
-------------- next part --------------
diff --git a/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/src/solaris/native/sun/awt/awt_GraphicsEnv.c
--- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c
+++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, 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
@@ -753,7 +753,7 @@
sizeof(errmsg),
"Can't connect to X11 window server using '%s' as the value of the DISPLAY variable.",
(getenv("DISPLAY") == NULL) ? ":0.0" : getenv("DISPLAY"));
- JNU_ThrowInternalError(env, errmsg);
+ JNU_ThrowByName(env, "java/awt/AWTError", errmsg);
return NULL;
}
diff --git a/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java b/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java
new file mode 100644
--- /dev/null
+++ b/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+
+
+/*
+ * @test
+ * @summary Test that Toolkit.getDefaultToolkit throws AWTError exception if bad DISPLAY variable was set
+ * @bug 6818083
+ *
+ * @run shell/timeout=240 BadDisplayTest.sh
+ */
+
+import java.awt.*;
+
+public class BadDisplayTest{
+ public static void main(String[] args) {
+
+ Throwable th = null;
+ try {
+ Toolkit.getDefaultToolkit();
+ } catch (Throwable x) {
+ th = x;
+ }
+ if ( !(th instanceof AWTError)) {
+ System.exit(1);
+ }
+ }
+}
diff --git a/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh b/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh
new file mode 100644
--- /dev/null
+++ b/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh
@@ -0,0 +1,42 @@
+# Copyright (c) 2012, 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.
+
+${TESTJAVA}/bin/javac -cp ${TESTSRC} -d . ${TESTSRC}/BadDisplayTest.java
+
+
+export DISPLAY=
+
+OS=`uname -s`
+case "$OS" in
+ SunOS )
+ ${TESTJAVA}/bin/java BadDisplayTest
+ ;;
+ Linux )
+ ${TESTJAVA}/bin/java BadDisplayTest
+ ;;
+ * )
+ echo "Unsupported System: ${OS}"
+ exit 0;
+ ;;
+esac
+
+exit $?
+
More information about the awt-dev
mailing list