mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 03:43:21 +00:00
8163362: Reconsider reflection usage in java.awt.font.JavaAWTFontAccessImpl class
Reviewed-by: naoto, okutsu, prr
This commit is contained in:
parent
82a6f08720
commit
f423e1290f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2016 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
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package java.awt.font;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import jdk.internal.misc.JavaAWTFontAccess;
|
||||
|
||||
class JavaAWTFontAccessImpl implements JavaAWTFontAccess {
|
||||
@ -33,19 +32,17 @@ class JavaAWTFontAccessImpl implements JavaAWTFontAccess {
|
||||
// java.awt.font.TextAttribute constants
|
||||
public Object getTextAttributeConstant(String name) {
|
||||
switch (name) {
|
||||
case "RUN_DIRECTION":
|
||||
case "NUMERIC_SHAPING":
|
||||
case "BIDI_EMBEDDING":
|
||||
case "RUN_DIRECTION_LTR":
|
||||
try {
|
||||
Field f = TextAttribute.class.getField(name);
|
||||
return f.get(null);
|
||||
} catch (NoSuchFieldException | IllegalAccessException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
case "RUN_DIRECTION":
|
||||
return TextAttribute.RUN_DIRECTION;
|
||||
case "NUMERIC_SHAPING":
|
||||
return TextAttribute.NUMERIC_SHAPING;
|
||||
case "BIDI_EMBEDDING":
|
||||
return TextAttribute.BIDI_EMBEDDING;
|
||||
case "RUN_DIRECTION_LTR":
|
||||
return TextAttribute.RUN_DIRECTION_LTR;
|
||||
default:
|
||||
throw new AssertionError("Constant name is not recognized");
|
||||
}
|
||||
|
||||
throw new AssertionError("Constant name is not recognized");
|
||||
}
|
||||
|
||||
// java.awt.font.NumericShaper
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user