changeset 4061:646047d77db9

7026507: Bidi initialization fails if AWT not present Reviewed-by: okutsu
author alanb
date Wed, 30 Mar 2011 00:59:07 +0100
parents 19567f9d6962
children a40982a82291
files src/share/classes/sun/text/bidi/BidiBase.java
diffstat 1 files changed, 18 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/text/bidi/BidiBase.java	Tue Mar 29 08:15:16 2011 -0400
+++ b/src/share/classes/sun/text/bidi/BidiBase.java	Wed Mar 30 00:59:07 2011 +0100
@@ -3457,13 +3457,18 @@
          */
         static final AttributedCharacterIterator.Attribute RUN_DIRECTION =
             getTextAttribute("RUN_DIRECTION");
-        static final Boolean RUN_DIRECTION_LTR =
-            (Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
         static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING =
             getTextAttribute("NUMERIC_SHAPING");
         static final AttributedCharacterIterator.Attribute BIDI_EMBEDDING =
             getTextAttribute("BIDI_EMBEDDING");
 
+        /**
+         * TextAttribute.RUN_DIRECTION_LTR
+         */
+        static final Boolean RUN_DIRECTION_LTR = (clazz == null) ?
+            Boolean.FALSE : (Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
+
+
         private static Class<?> getClass(String name) {
             try {
                 return Class.forName(name, true, null);
@@ -3473,25 +3478,23 @@
         }
 
         private static Object getStaticField(Class<?> clazz, String name) {
-            if (clazz == null) {
-                // fake attribute
-                return new AttributedCharacterIterator.Attribute(name) { };
-            } else {
-                try {
-                    Field f = clazz.getField(name);
-                    return f.get(null);
-                } catch (NoSuchFieldException x) {
-                    throw new AssertionError(x);
-                } catch (IllegalAccessException x) {
-                    throw new AssertionError(x);
-                }
+            try {
+                Field f = clazz.getField(name);
+                return f.get(null);
+            } catch (NoSuchFieldException | IllegalAccessException x) {
+                throw new AssertionError(x);
             }
         }
 
         private static AttributedCharacterIterator.Attribute
             getTextAttribute(String name)
         {
-            return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
+            if (clazz == null) {
+                // fake attribute
+                return new AttributedCharacterIterator.Attribute(name) { };
+            } else {
+                return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
+            }
         }
     }