aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/classes/sun')
-rw-r--r--src/share/classes/sun/awt/AWTAccessor.java148
-rw-r--r--src/share/classes/sun/awt/SunToolkit.java178
-rw-r--r--src/share/classes/sun/awt/shell/ShellFolder.java12
-rw-r--r--src/share/classes/sun/swing/AccessibleMethod.java136
-rw-r--r--src/share/classes/sun/swing/SwingAccessor.java96
-rw-r--r--src/share/classes/sun/text/normalizer/NormalizerBase.java27
6 files changed, 333 insertions, 264 deletions
diff --git a/src/share/classes/sun/awt/AWTAccessor.java b/src/share/classes/sun/awt/AWTAccessor.java
index f952dbec8..e427b8925 100644
--- a/src/share/classes/sun/awt/AWTAccessor.java
+++ b/src/share/classes/sun/awt/AWTAccessor.java
@@ -30,6 +30,7 @@ import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import sun.misc.Unsafe;
+import java.awt.peer.ComponentPeer;
/**
* The AWTAccessor utility class.
@@ -98,6 +99,21 @@ public final class AWTAccessor {
* any client code.
*/
boolean isVisible_NoClientCode(Component comp);
+
+ /**
+ * Sets the RequestFocusController.
+ */
+ void setRequestFocusController(RequestFocusController requestController);
+
+ /**
+ * Returns the appContext of the component.
+ */
+ AppContext getAppContext(Component comp);
+
+ /**
+ * Sets the appContext of the component.
+ */
+ void setAppContext(Component comp, AppContext appContext);
}
/*
@@ -153,23 +169,21 @@ public final class AWTAccessor {
*/
Point2D calculateSecurityWarningPosition(Window window,
double x, double y, double w, double h);
+
+ /** Sets the synchronous status of focus requests on lightweight
+ * components in the specified window to the specified value.
+ */
+ void setLWRequestStatus(Window changed, boolean status);
}
/*
* An accessor for the AWTEvent class.
*/
public interface AWTEventAccessor {
- /*
- *
- * Sets the flag on this AWTEvent indicating that it was
- * generated by the system.
- */
- void setSystemGenerated(AWTEvent ev);
- /*
- *
- * Indicates whether this AWTEvent was generated by the system.
+ /**
+ * Marks the event as posted.
*/
- boolean isSystemGenerated(AWTEvent ev);
+ void setPosted(AWTEvent ev);
}
/*
@@ -216,6 +230,51 @@ public final class AWTAccessor {
}
/*
+ * An accessor for the MenuComponent class.
+ */
+ public interface MenuComponentAccessor {
+ /**
+ * Returns the appContext of the menu component.
+ */
+ AppContext getAppContext(MenuComponent menuComp);
+
+ /**
+ * Sets the appContext of the menu component.
+ */
+ void setAppContext(MenuComponent menuComp, AppContext appContext);
+
+ /**
+ * Returns the menu container of the menu component
+ */
+ MenuContainer getParent(MenuComponent menuComp);
+ }
+
+ /*
+ * An accessor for the EventQueue class
+ */
+ public interface EventQueueAccessor {
+ /*
+ * Gets the next event queue.
+ */
+ EventQueue getNextQueue(EventQueue eventQueue);
+ /*
+ * Gets the event dispatch thread.
+ */
+ Thread getDispatchThread(EventQueue eventQueue);
+ }
+
+ /*
+ * An accessor for the PopupMenu class
+ */
+ public interface PopupMenuAccessor {
+ /*
+ * Returns whether the popup menu is attached to a tray
+ */
+ boolean isTrayIconPopup(PopupMenu popupMenu);
+ }
+
+
+ /*
* The java.awt.Component class accessor object.
*/
private static ComponentAccessor componentAccessor;
@@ -241,6 +300,21 @@ public final class AWTAccessor {
private static KeyboardFocusManagerAccessor kfmAccessor;
/*
+ * The java.awt.MenuComponent class accessor object.
+ */
+ private static MenuComponentAccessor menuComponentAccessor;
+
+ /*
+ * The java.awt.EventQueue class accessor object.
+ */
+ private static EventQueueAccessor eventQueueAccessor;
+
+ /*
+ * The java.awt.PopupMenu class accessor object.
+ */
+ private static PopupMenuAccessor popupMenuAccessor;
+
+ /*
* Set an accessor object for the java.awt.Component class.
*/
public static void setComponentAccessor(ComponentAccessor ca) {
@@ -286,6 +360,9 @@ public final class AWTAccessor {
* Retrieve the accessor object for the java.awt.AWTEvent class.
*/
public static AWTEventAccessor getAWTEventAccessor() {
+ if (awtEventAccessor == null) {
+ unsafe.ensureClassInitialized(AWTEvent.class);
+ }
return awtEventAccessor;
}
@@ -322,4 +399,55 @@ public final class AWTAccessor {
}
return kfmAccessor;
}
+
+ /*
+ * Set an accessor object for the java.awt.MenuComponent class.
+ */
+ public static void setMenuComponentAccessor(MenuComponentAccessor mca) {
+ menuComponentAccessor = mca;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.MenuComponent class.
+ */
+ public static MenuComponentAccessor getMenuComponentAccessor() {
+ if (menuComponentAccessor == null) {
+ unsafe.ensureClassInitialized(MenuComponent.class);
+ }
+ return menuComponentAccessor;
+ }
+
+ /*
+ * Set an accessor object for the java.awt.EventQueue class.
+ */
+ public static void setEventQueueAccessor(EventQueueAccessor eqa) {
+ eventQueueAccessor = eqa;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.EventQueue class.
+ */
+ public static EventQueueAccessor getEventQueueAccessor() {
+ if (eventQueueAccessor == null) {
+ unsafe.ensureClassInitialized(EventQueue.class);
+ }
+ return eventQueueAccessor;
+ }
+
+ /*
+ * Set an accessor object for the java.awt.PopupMenu class.
+ */
+ public static void setPopupMenuAccessor(PopupMenuAccessor pma) {
+ popupMenuAccessor = pma;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.PopupMenu class.
+ */
+ public static PopupMenuAccessor getPopupMenuAccessor() {
+ if (popupMenuAccessor == null) {
+ unsafe.ensureClassInitialized(PopupMenu.class);
+ }
+ return popupMenuAccessor;
+ }
}
diff --git a/src/share/classes/sun/awt/SunToolkit.java b/src/share/classes/sun/awt/SunToolkit.java
index fb554ef78..7f0ac590f 100644
--- a/src/share/classes/sun/awt/SunToolkit.java
+++ b/src/share/classes/sun/awt/SunToolkit.java
@@ -77,14 +77,7 @@ public abstract class SunToolkit extends Toolkit
*/
public static final int GRAB_EVENT_MASK = 0x80000000;
- private static Field syncLWRequestsField;
private static Method wakeupMethod;
- private static Field componentKeyField;
- private static Field menuComponentKeyField;
- private static Field trayIconKeyField;
- private static Field componentAppContextField;
- private static Field menuComponentAppContextField;
- private static Field isPostedField;
/* The key to put()/get() the PostEventQueue into/from the AppContext.
*/
private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue";
@@ -422,32 +415,21 @@ public abstract class SunToolkit extends Toolkit
private static final Map appContextMap =
Collections.synchronizedMap(new WeakHashMap());
-
/**
* Sets the appContext field of target. If target is not a Component or
* MenuComponent, this returns false.
*/
- private static boolean setAppContext(Object target, AppContext context)
- {
- if (!(target instanceof Component) && !(target instanceof MenuComponent)) {
+ private static boolean setAppContext(Object target,
+ AppContext context) {
+ if (target instanceof Component) {
+ AWTAccessor.getComponentAccessor().
+ setAppContext((Component)target, context);
+ } else if (target instanceof MenuComponent) {
+ AWTAccessor.getMenuComponentAccessor().
+ setAppContext((MenuComponent)target, context);
+ } else {
return false;
}
- try{
- if (target instanceof Component){
- if (componentAppContextField == null) {
- componentAppContextField = getField(Component.class, "appContext");
- }
- componentAppContextField.set(target, context);
- } else if (target instanceof MenuComponent) {
- if (menuComponentAppContextField == null) {
- menuComponentAppContextField = getField(MenuComponent.class, "appContext");
- }
- menuComponentAppContextField.set(target, context);
- }
- } catch( IllegalAccessException e){
- assert false;
- }
-
return true;
}
@@ -456,23 +438,15 @@ public abstract class SunToolkit extends Toolkit
* Component or MenuComponent this returns null.
*/
private static AppContext getAppContext(Object target) {
- AppContext retObj = null;
- try{
- if (target instanceof Component){
- if (componentAppContextField == null) {
- componentAppContextField = getField(Component.class, "appContext");
- }
- retObj = (AppContext) componentAppContextField.get(target);
- } else if (target instanceof MenuComponent) {
- if (menuComponentAppContextField == null) {
- menuComponentAppContextField = getField(MenuComponent.class, "appContext");
- }
- retObj = (AppContext) menuComponentAppContextField.get(target);
- }
- } catch( IllegalAccessException e){
- assert false;
+ if (target instanceof Component) {
+ return AWTAccessor.getComponentAccessor().
+ getAppContext((Component)target);
+ } else if (target instanceof MenuComponent) {
+ return AWTAccessor.getMenuComponentAccessor().
+ getAppContext((MenuComponent)target);
+ } else {
+ return null;
}
- return retObj;
}
/*
@@ -520,16 +494,7 @@ public abstract class SunToolkit extends Toolkit
*/
public static void setLWRequestStatus(Window changed,boolean status){
- if (syncLWRequestsField == null){
- syncLWRequestsField = getField(Window.class, "syncLWRequests");
- }
- try{
- if (syncLWRequestsField != null){
- syncLWRequestsField.setBoolean(changed, status);
- }
- } catch( IllegalAccessException e){
- assert false;
- }
+ AWTAccessor.getWindowAccessor().setLWRequestStatus(changed, status);
};
public static void checkAndSetPolicy(Container cont, boolean isSwingCont)
@@ -637,18 +602,9 @@ public abstract class SunToolkit extends Toolkit
* Post AWTEvent of high priority.
*/
public static void postPriorityEvent(final AWTEvent e) {
- if (isPostedField == null) {
- isPostedField = getField(AWTEvent.class, "isPosted");
- }
PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
public void run() {
- try {
- isPostedField.setBoolean(e, true);
- } catch (IllegalArgumentException e) {
- assert(false);
- } catch (IllegalAccessException e) {
- assert(false);
- }
+ AWTAccessor.getAWTEventAccessor().setPosted(e);
((Component)e.getSource()).dispatchEvent(e);
}
}, PeerEvent.ULTIMATE_PRIORITY_EVENT);
@@ -757,36 +713,6 @@ public abstract class SunToolkit extends Toolkit
}
/*
- * Returns next queue for the given EventQueue which has private access
- */
- private static EventQueue getNextQueue(final Object o) {
- EventQueue result = null;
- try{
- Field nextQueueField = getField(EventQueue.class,
- "nextQueue");
- result = (EventQueue)nextQueueField.get(o);
- } catch( IllegalAccessException e){
- assert false;
- }
- return result;
- }
-
- /*
- * Returns dispatch thread for the given EventQueue which has private access
- */
- private static Thread getDispatchThread(final Object o) {
- Thread result = null;
- try{
- Field dispatchThreadField = getField(EventQueue.class,
- "dispatchThread");
- result = (Thread)dispatchThreadField.get(o);
- } catch( IllegalAccessException e){
- assert false;
- }
- return result;
- }
-
- /*
* Returns true if the calling thread is the event dispatch thread
* contained within AppContext which associated with the given target.
* Use this call to ensure that a given task is being executed
@@ -796,13 +722,14 @@ public abstract class SunToolkit extends Toolkit
AppContext appContext = targetToAppContext(target);
EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
- EventQueue next = getNextQueue(eq);
+ AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor();
+ EventQueue next = accessor.getNextQueue(eq);
while (next != null) {
eq = next;
- next = getNextQueue(eq);
+ next = accessor.getNextQueue(eq);
}
- return (Thread.currentThread() == getDispatchThread(eq));
+ return (Thread.currentThread() == accessor.getDispatchThread(eq));
}
public Dimension getScreenSize() {
@@ -1356,22 +1283,7 @@ public abstract class SunToolkit extends Toolkit
return false;
}
- private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE;
-
- static {
- DEFAULT_MODAL_EXCLUSION_TYPE = (Dialog.ModalExclusionType)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- Dialog.ModalExclusionType defaultType = Dialog.ModalExclusionType.NO_EXCLUDE;
- try {
- java.lang.reflect.Field f = Dialog.class.getDeclaredField("DEFAULT_MODAL_EXCLUSION_TYPE");
- f.setAccessible(true);
- defaultType = (Dialog.ModalExclusionType)f.get(null);
- } catch (Exception e) {
- }
- return defaultType;
- }
- });
- }
+ private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE = null;
/**
* Returns whether the XEmbed server feature is requested by
@@ -1430,6 +1342,9 @@ public abstract class SunToolkit extends Toolkit
*/
public static void setModalExcluded(Window window)
{
+ if (DEFAULT_MODAL_EXCLUSION_TYPE == null) {
+ DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE;
+ }
window.setModalExclusionType(DEFAULT_MODAL_EXCLUSION_TYPE);
}
@@ -1451,6 +1366,9 @@ public abstract class SunToolkit extends Toolkit
*/
public static boolean isModalExcluded(Window window)
{
+ if (DEFAULT_MODAL_EXCLUSION_TYPE == null) {
+ DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE;
+ }
return window.getModalExclusionType().compareTo(DEFAULT_MODAL_EXCLUSION_TYPE) >= 0;
}
@@ -2104,6 +2022,42 @@ public abstract class SunToolkit extends Toolkit
public int getNumberOfButtons(){
return 3;
}
+
+ /**
+ * Checks that the given object implements/extends the given
+ * interface/class.
+ *
+ * Note that using the instanceof operator causes a class to be loaded.
+ * Using this method doesn't load a class and it can be used instead of
+ * the instanceof operator for performance reasons.
+ *
+ * @param obj Object to be checked
+ * @param type The name of the interface/class. Must be
+ * fully-qualified interface/class name.
+ * @return true, if this object implements/extends the given
+ * interface/class, false, otherwise, or if obj or type is null
+ */
+ public static boolean isInstanceOf(Object obj, String type) {
+ if (obj == null) return false;
+ if (type == null) return false;
+
+ return isInstanceOf(obj.getClass(), type);
+ }
+
+ private static boolean isInstanceOf(Class cls, String type) {
+ if (cls == null) return false;
+
+ if (cls.getName().equals(type)) {
+ return true;
+ }
+
+ for (Class c : cls.getInterfaces()) {
+ if (c.getName().equals(type)) {
+ return true;
+ }
+ }
+ return isInstanceOf(cls.getSuperclass(), type);
+ }
} // class SunToolkit
diff --git a/src/share/classes/sun/awt/shell/ShellFolder.java b/src/share/classes/sun/awt/shell/ShellFolder.java
index 965dd6f04..d38fd98e0 100644
--- a/src/share/classes/sun/awt/shell/ShellFolder.java
+++ b/src/share/classes/sun/awt/shell/ShellFolder.java
@@ -202,8 +202,16 @@ public abstract class ShellFolder extends File {
private static ShellFolderManager shellFolderManager;
static {
- Class managerClass = (Class)Toolkit.getDefaultToolkit().
- getDesktopProperty("Shell.shellFolderManager");
+ String managerClassName = (String)Toolkit.getDefaultToolkit().
+ getDesktopProperty("Shell.shellFolderManager");
+ Class managerClass = null;
+ try {
+ managerClass = Class.forName(managerClassName);
+ // swallow the exceptions below and use default shell folder
+ } catch(ClassNotFoundException e) {
+ } catch(NullPointerException e) {
+ }
+
if (managerClass == null) {
managerClass = ShellFolderManager.class;
}
diff --git a/src/share/classes/sun/swing/AccessibleMethod.java b/src/share/classes/sun/swing/AccessibleMethod.java
deleted file mode 100644
index 228808652..000000000
--- a/src/share/classes/sun/swing/AccessibleMethod.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2005-2008 Sun Microsystems, Inc. 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-package sun.swing;
-
-import java.security.*;
-import java.lang.reflect.*;
-
-/**
- * A utility for accessing and invoking methods, via reflection,
- * that would otherwise be unaccessible.
- *
- * @author Shannon Hickey
- */
-public class AccessibleMethod {
-
- private final Method method;
-
- /**
- * Construct an instance for the given params.
- *
- * @param klass the class to which the method belongs
- * @param methodName the name of the method
- * @param paramTypes the paramater type array
- * @throws NullPointerException if <code>klass</code>
- * or <code>name</code> is <code>null</code>
- * @throws NoSuchMethodException if the method can't be found
- */
- public AccessibleMethod(Class klass,
- String methodName,
- Class ... paramTypes) throws NoSuchMethodException {
- try {
- method = AccessController.doPrivileged(
- new AccessMethodAction(klass, methodName, paramTypes));
- } catch (PrivilegedActionException e) {
- throw (NoSuchMethodException)e.getCause();
- }
- }
-
- /**
- * Invoke the method that this object represents.
- * Has the same behavior and throws the same exceptions as
- * <code>java.lang.reflect.Method.invoke</code> with one
- * exception: This method does not throw
- * <code>IllegalAccessException</code> since the target
- * method has already been made accessible.
- *
- * @param obj the object the underlying method is invoked from
- * @param args the arguments used for the method call
- * @return the result of dispatching the method represented by
- * this object on <code>obj</code> with parameters
- * <code>args</code>
- * @see java.lang.reflect.Method#invoke
- */
- public Object invoke(Object obj, Object ... args)
- throws IllegalArgumentException, InvocationTargetException {
-
- try {
- return method.invoke(obj, args);
- } catch (IllegalAccessException e) {
- // should never happen since we've made it accessible
- throw new AssertionError("accessible method inaccessible");
- }
- }
-
- /**
- * Invoke the method that this object represents, with the
- * expectation that the method being called throws no
- * checked exceptions.
- * <p>
- * Simply calls <code>this.invoke(obj, args)</code>
- * but catches any <code>InvocationTargetException</code>
- * and returns the cause wrapped in a runtime exception.
- *
- * @param obj the object the underlying method is invoked from
- * @param args the arguments used for the method call
- * @return the result of dispatching the method represented by
- * this object on <code>obj</code> with parameters
- * <code>args</code>
- * @see #invoke
- */
- public Object invokeNoChecked(Object obj, Object ... args) {
- try {
- return invoke(obj, args);
- } catch (InvocationTargetException ex) {
- if (ex.getCause() instanceof RuntimeException) {
- throw (RuntimeException)ex.getCause();
- } else {
- throw new RuntimeException(ex.getCause());
- }
- }
- }
-
- /** The action used to fetch the method and make it accessible */
- private static class AccessMethodAction implements PrivilegedExceptionAction<Method> {
- private final Class<?> klass;
- private final String methodName;
- private final Class[] paramTypes;
-
- public AccessMethodAction(Class klass,
- String methodName,
- Class ... paramTypes) {
-
- this.klass = klass;
- this.methodName = methodName;
- this.paramTypes = paramTypes;
- }
-
- public Method run() throws NoSuchMethodException {
- Method method = klass.getDeclaredMethod(methodName, paramTypes);
- method.setAccessible(true);
- return method;
- }
- }
-}
diff --git a/src/share/classes/sun/swing/SwingAccessor.java b/src/share/classes/sun/swing/SwingAccessor.java
new file mode 100644
index 000000000..a6eefb0fb
--- /dev/null
+++ b/src/share/classes/sun/swing/SwingAccessor.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.swing;
+
+import sun.misc.Unsafe;
+
+import java.awt.Point;
+
+import javax.swing.text.JTextComponent;
+import javax.swing.TransferHandler;
+
+/**
+ * The SwingAccessor utility class.
+ * The main purpose of this class is to enable accessing
+ * private and package-private fields of classes from
+ * different classes/packages. See sun.misc.SharedSecretes
+ * for another example.
+ */
+public final class SwingAccessor {
+ private static final Unsafe unsafe = Unsafe.getUnsafe();
+
+ /**
+ * We don't need any objects of this class.
+ * It's rather a collection of static methods
+ * and interfaces.
+ */
+ private SwingAccessor() {
+ }
+
+ /**
+ * An accessor for the JTextComponent class.
+ * Note that we intentionally introduce the JTextComponentAccessor,
+ * and not the JComponentAccessor because the needed methods
+ * aren't override methods.
+ */
+ public interface JTextComponentAccessor {
+
+ /**
+ * Calculates a custom drop location for the text component,
+ * representing where a drop at the given point should insert data.
+ */
+ TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
+
+ /**
+ * Called to set or clear the drop location during a DnD operation.
+ */
+ Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
+ Object state, boolean forDrop);
+ }
+
+ /**
+ * The javax.swing.text.JTextComponent class accessor object.
+ */
+ private static JTextComponentAccessor jtextComponentAccessor;
+
+ /**
+ * Set an accessor object for the javax.swing.text.JTextComponent class.
+ */
+ public static void setJTextComponentAccessor(JTextComponentAccessor jtca) {
+ jtextComponentAccessor = jtca;
+ }
+
+ /**
+ * Retrieve the accessor object for the javax.swing.text.JTextComponent class.
+ */
+ public static JTextComponentAccessor getJTextComponentAccessor() {
+ if (jtextComponentAccessor == null) {
+ unsafe.ensureClassInitialized(JTextComponent.class);
+ }
+
+ return jtextComponentAccessor;
+ }
+}
diff --git a/src/share/classes/sun/text/normalizer/NormalizerBase.java b/src/share/classes/sun/text/normalizer/NormalizerBase.java
index a82475c60..b4df3e2a6 100644
--- a/src/share/classes/sun/text/normalizer/NormalizerBase.java
+++ b/src/share/classes/sun/text/normalizer/NormalizerBase.java
@@ -1598,15 +1598,34 @@ public final class NormalizerBase implements Cloneable {
* @param options the optional features to be enabled.
*/
public static String normalize(String str, Normalizer.Form form, int options) {
+ int len = str.length();
+ boolean asciiOnly = true;
+ if (len < 80) {
+ for (int i = 0; i < len; i++) {
+ if (str.charAt(i) > 127) {
+ asciiOnly = false;
+ break;
+ }
+ }
+ } else {
+ char[] a = str.toCharArray();
+ for (int i = 0; i < len; i++) {
+ if (a[i] > 127) {
+ asciiOnly = false;
+ break;
+ }
+ }
+ }
+
switch (form) {
case NFC :
- return NFC.normalize(str, options);
+ return asciiOnly ? str : NFC.normalize(str, options);
case NFD :
- return NFD.normalize(str, options);
+ return asciiOnly ? str : NFD.normalize(str, options);
case NFKC :
- return NFKC.normalize(str, options);
+ return asciiOnly ? str : NFKC.normalize(str, options);
case NFKD :
- return NFKD.normalize(str, options);
+ return asciiOnly ? str : NFKD.normalize(str, options);
}
throw new IllegalArgumentException("Unexpected normalization form: " +