提交 e000263e 编写于 作者: A alanb

7026507: Bidi initialization fails if AWT not present

Reviewed-by: okutsu
上级 82b1a278
...@@ -3457,13 +3457,18 @@ public class BidiBase { ...@@ -3457,13 +3457,18 @@ public class BidiBase {
*/ */
static final AttributedCharacterIterator.Attribute RUN_DIRECTION = static final AttributedCharacterIterator.Attribute RUN_DIRECTION =
getTextAttribute("RUN_DIRECTION"); getTextAttribute("RUN_DIRECTION");
static final Boolean RUN_DIRECTION_LTR =
(Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING = static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING =
getTextAttribute("NUMERIC_SHAPING"); getTextAttribute("NUMERIC_SHAPING");
static final AttributedCharacterIterator.Attribute BIDI_EMBEDDING = static final AttributedCharacterIterator.Attribute BIDI_EMBEDDING =
getTextAttribute("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) { private static Class<?> getClass(String name) {
try { try {
return Class.forName(name, true, null); return Class.forName(name, true, null);
...@@ -3473,27 +3478,25 @@ public class BidiBase { ...@@ -3473,27 +3478,25 @@ public class BidiBase {
} }
private static Object getStaticField(Class<?> clazz, String name) { private static Object getStaticField(Class<?> clazz, String name) {
if (clazz == null) {
// fake attribute
return new AttributedCharacterIterator.Attribute(name) { };
} else {
try { try {
Field f = clazz.getField(name); Field f = clazz.getField(name);
return f.get(null); return f.get(null);
} catch (NoSuchFieldException x) { } catch (NoSuchFieldException | IllegalAccessException x) {
throw new AssertionError(x); throw new AssertionError(x);
} catch (IllegalAccessException x) {
throw new AssertionError(x);
}
} }
} }
private static AttributedCharacterIterator.Attribute private static AttributedCharacterIterator.Attribute
getTextAttribute(String name) getTextAttribute(String name)
{ {
if (clazz == null) {
// fake attribute
return new AttributedCharacterIterator.Attribute(name) { };
} else {
return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name); return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
} }
} }
}
/** /**
* A class that provides access to java.awt.font.NumericShaping without * A class that provides access to java.awt.font.NumericShaping without
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册