--- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java Wed Aug 24 00:23:49 2016 +0400
@@ -25,7 +25,6 @@
package apple.laf;
-import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.lang.annotation.Native;
@@ -70,6 +69,21 @@
throw new RuntimeException("Constant not implemented in native: " + this);
}
+ private String getConstantName(Key hit) {
+ if (hit == VALUE) {
+ return "VALUE";
+ } else if (hit == THUMB_PROPORTION) {
+ return "THUMB_PROPORTION";
+ } else if (hit == THUMB_START) {
+ return "THUMB_START";
+ } else if (hit == WINDOW_TITLE_BAR_HEIGHT) {
+ return "WINDOW_TITLE_BAR_HEIGHT";
+ } else if (hit == THUMB_START) {
+ return "ANIMATION_FRAME";
+ }
+ return getClass().getSimpleName();
+ }
+
public String toString() {
return getConstantName(this) + (ptr == 0 ? "(unlinked)" : "");
}
@@ -138,7 +152,7 @@
}
public String toString() {
- return getConstantName(this);
+ return getClass().getSimpleName();
}
}
@@ -779,6 +793,17 @@
return hit > 0;
}
+ private String getConstantName(Hit hit) {
+ if (hit == UNKNOWN) {
+ return "UNKNOWN";
+ } else if (hit == NONE) {
+ return "NONE";
+ } else if (hit == HIT) {
+ return "HIT";
+ }
+ return getClass().getSimpleName();
+ }
+
public String toString() {
return getConstantName(this);
}
@@ -829,16 +854,4 @@
}
return Hit.UNKNOWN;
}
-
- static String getConstantName(final Object object) {
- final Class<? extends Object> clazz = object.getClass();
- try {
- for (final Field field : clazz.getFields()) {
- if (field.get(null) == object) {
- return field.getName();
- }
- }
- } catch (final Exception e) {}
- return clazz.getSimpleName();
- }
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java Wed Aug 24 00:23:49 2016 +0400
@@ -72,7 +72,7 @@
public void setDockIconImage(final Image image) {
try {
- final CImage cImage = getCImageCreator().createFromImage(image);
+ final CImage cImage = CImage.createFromImage(image);
final long nsImagePtr = getNSImagePtrFrom(cImage);
nativeSetDockIconImage(nsImagePtr);
} catch (final Throwable e) {
@@ -84,7 +84,11 @@
try {
final long dockNSImage = nativeGetDockIconImage();
if (dockNSImage == 0) return null;
- return getCImageCreator().createImageUsingNativeSize(dockNSImage);
+ final Method getCreatorMethod = CImage.class.getDeclaredMethod(
+ "getCreator", new Class<?>[]{});
+ getCreatorMethod.setAccessible(true);
+ Creator imageCreator = (Creator) getCreatorMethod.invoke(null, new Object[]{});
+ return imageCreator.createImageUsingNativeSize(dockNSImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
@@ -98,16 +102,6 @@
nativeSetDockIconProgress(value);
}
- static Creator getCImageCreator() {
- try {
- final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class<?>[] {});
- getCreatorMethod.setAccessible(true);
- return (Creator)getCreatorMethod.invoke(null, new Object[] {});
- } catch (final Throwable e) {
- throw new RuntimeException(e);
- }
- }
-
static long getNSImagePtrFrom(final CImage cImage) {
if (cImage == null) return 0;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java Wed Aug 24 00:23:49 2016 +0400
@@ -37,6 +37,7 @@
import com.apple.laf.AquaUtilControlSize.*;
import com.apple.laf.AquaUtils.RecyclableSingleton;
+import sun.lwawt.macosx.CImage;
public class AquaIcon {
interface InvertableIcon extends Icon {
@@ -226,7 +227,7 @@
}
Image createImage() {
- return AquaUtils.getCImageCreator().createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight());
+ return CImage.createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight());
}
}
@@ -299,7 +300,7 @@
}
Image createImage() {
- return AquaUtils.getCImageCreator().createSystemImageFromSelector(
+ return CImage.createSystemImageFromSelector(
selector, getIconWidth(), getIconHeight());
}
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java Wed Aug 24 00:23:49 2016 +0400
@@ -46,8 +46,8 @@
import com.apple.laf.AquaIcon.SystemIcon;
import com.apple.laf.AquaUtils.RecyclableObject;
import com.apple.laf.AquaUtils.RecyclableSingleton;
-import java.awt.image.MultiResolutionImage;
import sun.awt.image.MultiResolutionCachedImage;
+import sun.lwawt.macosx.CImage;
public class AquaImageFactory {
public static IconUIResource getConfirmImageIcon() {
@@ -73,7 +73,7 @@
public static IconUIResource getLockImageIcon() {
// public, because UIDefaults.ProxyLazyValue uses reflection to get this value
if (JRSUIUtils.Images.shouldUseLegacySecurityUIPath()) {
- final Image lockIcon = AquaUtils.getCImageCreator().createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize);
+ final Image lockIcon = CImage.createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize);
return getAppIconCompositedOn(lockIcon);
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java Wed Aug 24 00:23:49 2016 +0400
@@ -41,8 +41,6 @@
import sun.awt.AppContext;
-import sun.lwawt.macosx.CImage;
-import sun.lwawt.macosx.CImage.Creator;
import sun.lwawt.macosx.CPlatformWindow;
import sun.reflect.misc.ReflectUtil;
import sun.security.action.GetPropertyAction;
@@ -50,6 +48,7 @@
import com.apple.laf.AquaImageFactory.SlicedImageControl;
import sun.awt.image.MultiResolutionCachedImage;
+import sun.swing.SwingAccessor;
final class AquaUtils {
@@ -78,32 +77,6 @@
}
}
- private static Creator getCImageCreatorInternal() {
- return AccessController.doPrivileged(new PrivilegedAction<Creator>() {
- @Override
- public Creator run() {
- try {
- final Method getCreatorMethod = CImage.class.getDeclaredMethod(
- "getCreator", new Class<?>[] {});
- getCreatorMethod.setAccessible(true);
- return (Creator)getCreatorMethod.invoke(null, new Object[] {});
- } catch (final Exception ignored) {
- return null;
- }
- }
- });
- }
-
- private static final RecyclableSingleton<Creator> cImageCreator = new RecyclableSingleton<Creator>() {
- @Override
- protected Creator getInstance() {
- return getCImageCreatorInternal();
- }
- };
- static Creator getCImageCreator() {
- return cImageCreator.get();
- }
-
static Image generateSelectedDarkImage(final Image image) {
final ImageFilter filter = new IconImageFilter() {
@Override
@@ -405,15 +378,9 @@
}
};
- private static final Integer OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET
+ private static final int OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET
static boolean hasOpaqueBeenExplicitlySet(final JComponent c) {
- final Method method = getJComponentGetFlagMethod.get();
- if (method == null) return false;
- try {
- return Boolean.TRUE.equals(method.invoke(c, OPAQUE_SET_FLAG));
- } catch (final Throwable ignored) {
- return false;
- }
+ return SwingAccessor.getJComponentAccessor().getFlag(c, OPAQUE_SET_FLAG);
}
private static boolean isWindowTextured(final Component c) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java Wed Aug 24 00:23:49 2016 +0400
@@ -37,6 +37,7 @@
import javax.accessibility.*;
import javax.swing.*;
+import sun.awt.AWTAccessor;
class CAccessibility implements PropertyChangeListener {
private static Set<String> ignoredRoles;
@@ -205,33 +206,12 @@
}, c);
}
- static Field getAccessibleBundleKeyFieldWithReflection() {
- try {
- final Field fieldKey = AccessibleBundle.class.getDeclaredField("key");
- fieldKey.setAccessible(true);
- return fieldKey;
- } catch (final SecurityException e) {
- e.printStackTrace();
- } catch (final NoSuchFieldException e) {
- e.printStackTrace();
- }
- return null;
- }
- private static final Field FIELD_KEY = getAccessibleBundleKeyFieldWithReflection();
-
static String getAccessibleRoleFor(final Accessible a) {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return null;
final AccessibleRole role = ac.getAccessibleRole();
- try {
- return (String)FIELD_KEY.get(role);
- } catch (final IllegalArgumentException e) {
- e.printStackTrace();
- } catch (final IllegalAccessException e) {
- e.printStackTrace();
- }
- return null;
+ return AWTAccessor.getAccessibleBundleAccessor().getKey(role);
}
public static String getAccessibleRole(final Accessible a, final Component c) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java Wed Aug 24 00:23:49 2016 +0400
@@ -28,7 +28,6 @@
import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.lang.reflect.Field;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
@@ -41,36 +40,23 @@
import static javax.accessibility.AccessibleContext.ACCESSIBLE_CARET_PROPERTY;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_TEXT_PROPERTY;
+import sun.awt.AWTAccessor;
class CAccessible extends CFRetainedResource implements Accessible {
- static Field getNativeAXResourceField() {
- try {
- final Field field = AccessibleContext.class.getDeclaredField("nativeAXResource");
- field.setAccessible(true);
- return field;
- } catch (final Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- private static Field nativeAXResourceField = getNativeAXResourceField();
public static CAccessible getCAccessible(final Accessible a) {
if (a == null) return null;
AccessibleContext context = a.getAccessibleContext();
- try {
- final CAccessible cachedCAX = (CAccessible) nativeAXResourceField.get(context);
- if (cachedCAX != null) return cachedCAX;
-
- final CAccessible newCAX = new CAccessible(a);
- nativeAXResourceField.set(context, newCAX);
- return newCAX;
- } catch (final Exception e) {
- e.printStackTrace();
- return null;
+ AWTAccessor.AccessibleContextAccessor accessor
+ = AWTAccessor.getAccessibleContextAccessor();
+ final CAccessible cachedCAX = (CAccessible) accessor.getNativeAXResource(context);
+ if (cachedCAX != null) {
+ return cachedCAX;
}
+ final CAccessible newCAX = new CAccessible(a);
+ accessor.setNativeAXResource(context, newCAX);
+ return newCAX;
}
private static native void unregisterFromCocoaAXSystem(long ptr);
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java Wed Aug 24 00:23:49 2016 +0400
@@ -56,6 +56,25 @@
return creator;
}
+ // This is used to create a CImage that represents the icon of the given file.
+ public static Image createImageOfFile(String file, int width, int height) {
+ return getCreator().createImageOfFile(file, width, height);
+ }
+
+ public static Image createSystemImageFromSelector(String iconSelector,
+ int width, int height) {
+ return getCreator().createSystemImageFromSelector(iconSelector, width, height);
+ }
+
+ public static Image createImageFromFile(String file, double width, double height) {
+ return getCreator().createImageFromFile(file, width, height);
+ }
+
+ // This is used to create a CImage from a Image
+ public static CImage createFromImage(final Image image) {
+ return getCreator().createFromImage(image);
+ }
+
public static class Creator {
Creator() { }
--- a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java Wed Aug 24 00:23:49 2016 +0400
@@ -284,35 +284,6 @@
});
}
- private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
- if (inputEvent_CanAccessSystemClipboard_Field == null) {
- inputEvent_CanAccessSystemClipboard_Field =
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction<Field>() {
- public Field run() {
- Field field = null;
- try {
- field = InputEvent.class.
- getDeclaredField("canAccessSystemClipboard");
- field.setAccessible(true);
- return field;
- } catch (SecurityException e) {
- if (log.isLoggable(PlatformLogger.Level.FINE)) {
- log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got SecurityException ", e);
- }
- } catch (NoSuchFieldException e) {
- if (log.isLoggable(PlatformLogger.Level.FINE)) {
- log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got NoSuchFieldException ", e);
- }
- }
- return null;
- }
- });
- }
-
- return inputEvent_CanAccessSystemClipboard_Field;
- }
-
/**
* Initialize JNI field and method IDs for fields that may be
* accessed from C.
@@ -593,33 +564,20 @@
that.bdata = this.bdata;
// Copy canAccessSystemClipboard value from this into that.
if (this instanceof InputEvent && that instanceof InputEvent) {
- Field field = get_InputEvent_CanAccessSystemClipboard();
- if (field != null) {
- try {
- boolean b = field.getBoolean(this);
- field.setBoolean(that, b);
- } catch(IllegalAccessException e) {
- if (log.isLoggable(PlatformLogger.Level.FINE)) {
- log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e);
- }
- }
- }
+
+ AWTAccessor.InputEventAccessor accessor
+ = AWTAccessor.getInputEventAccessor();
+
+ boolean b = accessor.canAccessSystemClipboard((InputEvent) this);
+ accessor.setCanAccessSystemClipboard((InputEvent) that, b);
}
that.isSystemGenerated = this.isSystemGenerated;
}
void dispatched() {
if (this instanceof InputEvent) {
- Field field = get_InputEvent_CanAccessSystemClipboard();
- if (field != null) {
- try {
- field.setBoolean(this, false);
- } catch(IllegalAccessException e) {
- if (log.isLoggable(PlatformLogger.Level.FINE)) {
- log.fine("AWTEvent.dispatched() got IllegalAccessException ", e);
- }
- }
- }
+ AWTAccessor.getInputEventAccessor().
+ setCanAccessSystemClipboard((InputEvent) this, false);
}
}
} // class AWTEvent
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java Wed Aug 24 00:23:49 2016 +0400
@@ -53,13 +53,11 @@
import java.awt.im.InputContext;
import java.awt.im.InputMethodRequests;
import java.awt.dnd.DropTarget;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.security.AccessControlContext;
import javax.accessibility.*;
import java.applet.Applet;
+import javax.swing.JComponent;
import sun.awt.ComponentFactory;
import sun.security.action.GetPropertyAction;
@@ -81,6 +79,7 @@
import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
import sun.awt.RequestFocusController;
import sun.java2d.SunGraphicsEnvironment;
+import sun.swing.SwingAccessor;
import sun.util.logging.PlatformLogger;
/**
@@ -8695,6 +8694,9 @@
* the Swing package private method {@code compWriteObjectNotify}.
*/
private void doSwingSerialization() {
+ if (!(this instanceof JComponent)) {
+ return;
+ }
@SuppressWarnings("deprecation")
Package swingPackage = Package.getPackage("javax.swing");
// For Swing serialization to correctly work Swing needs to
@@ -8707,36 +8709,10 @@
klass = klass.getSuperclass()) {
if (klass.getPackage() == swingPackage &&
klass.getClassLoader() == null) {
- final Class<?> swingClass = klass;
- // Find the first override of the compWriteObjectNotify method
- Method[] methods = AccessController.doPrivileged(
- new PrivilegedAction<Method[]>() {
- public Method[] run() {
- return swingClass.getDeclaredMethods();
- }
- });
- for (int counter = methods.length - 1; counter >= 0;
- counter--) {
- final Method method = methods[counter];
- if (method.getName().equals("compWriteObjectNotify")){
- // We found it, use doPrivileged to make it accessible
- // to use.
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- public Void run() {
- method.setAccessible(true);
- return null;
- }
- });
- // Invoke the method
- try {
- method.invoke(this, (Object[]) null);
- } catch (IllegalAccessException iae) {
- } catch (InvocationTargetException ite) {
- }
- // We're done, bail.
- return;
- }
- }
+
+ SwingAccessor.getJComponentAccessor()
+ .compWriteObjectNotify((JComponent) this);
+ return;
}
}
}
--- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java Wed Aug 24 00:23:49 2016 +0400
@@ -40,8 +40,6 @@
import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
-
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -140,6 +138,10 @@
public void removeLastFocusRequest(Component heavyweight) {
KeyboardFocusManager.removeLastFocusRequest(heavyweight);
}
+ @Override
+ public Component getMostRecentFocusOwner(Window window) {
+ return KeyboardFocusManager.getMostRecentFocusOwner(window);
+ }
public void setMostRecentFocusOwner(Window window, Component component) {
KeyboardFocusManager.setMostRecentFocusOwner(window, component);
}
@@ -3053,32 +3055,9 @@
}
}
- static Field proxyActive;
// Accessor to private field isProxyActive of KeyEvent
private static boolean isProxyActiveImpl(KeyEvent e) {
- if (proxyActive == null) {
- proxyActive = AccessController.doPrivileged(new PrivilegedAction<Field>() {
- public Field run() {
- Field field = null;
- try {
- field = KeyEvent.class.getDeclaredField("isProxyActive");
- if (field != null) {
- field.setAccessible(true);
- }
- } catch (NoSuchFieldException nsf) {
- assert(false);
- }
- return field;
- }
- });
- }
-
- try {
- return proxyActive.getBoolean(e);
- } catch (IllegalAccessException iae) {
- assert(false);
- }
- return false;
+ return AWTAccessor.getKeyEventAccessor().isProxyActive(e);
}
// Returns the value of this KeyEvent's field isProxyActive
--- a/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java Wed Aug 24 00:23:49 2016 +0400
@@ -63,6 +63,10 @@
public boolean isSequencedEvent(AWTEvent event) {
return event instanceof SequencedEvent;
}
+
+ public AWTEvent create(AWTEvent event) {
+ return new SequencedEvent(event);
+ }
});
}
--- a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java Wed Aug 24 00:23:49 2016 +0400
@@ -302,6 +302,12 @@
public boolean canAccessSystemClipboard(InputEvent event) {
return event.canAccessSystemClipboard;
}
+
+ @Override
+ public void setCanAccessSystemClipboard(InputEvent event,
+ boolean canAccessSystemClipboard) {
+ event.canAccessSystemClipboard = canAccessSystemClipboard;
+ }
});
}
--- a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java Wed Aug 24 00:23:49 2016 +0400
@@ -1091,6 +1091,11 @@
public Component getOriginalSource( KeyEvent ev ) {
return ev.originalSource;
}
+
+ @Override
+ public boolean isProxyActive(KeyEvent ev) {
+ return ev.isProxyActive;
+ }
});
}
--- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java Wed Aug 24 00:23:49 2016 +0400
@@ -31,6 +31,7 @@
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import sun.awt.AWTAccessor;
/**
* <p>Base class used to maintain a strongly typed enumeration. This is
@@ -53,6 +54,17 @@
private final String defaultResourceBundleName
= "com.sun.accessibility.internal.resources.accessibility";
+ static {
+ AWTAccessor.setAccessibleBundleAccessor(
+ new AWTAccessor.AccessibleBundleAccessor() {
+
+ @Override
+ public String getKey(AccessibleBundle accessibleBundle) {
+ return accessibleBundle.key;
+ }
+ });
+ }
+
/**
* Construct an {@code AccessibleBundle}.
*/
--- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java Wed Aug 24 00:23:49 2016 +0400
@@ -99,6 +99,16 @@
public AppContext getAppContext(AccessibleContext accessibleContext) {
return accessibleContext.targetAppContext;
}
+
+ @Override
+ public Object getNativeAXResource(AccessibleContext accessibleContext) {
+ return accessibleContext.nativeAXResource;
+ }
+
+ @Override
+ public void setNativeAXResource(AccessibleContext accessibleContext, Object value) {
+ accessibleContext.nativeAXResource = value;
+ }
});
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java Wed Aug 24 00:23:49 2016 +0400
@@ -40,8 +40,8 @@
import javax.accessibility.*;
import sun.awt.AppContext;
-import java.lang.reflect.Field;
import java.security.*;
+import sun.awt.AWTAccessor;
/**
* An implementation of the Icon interface that paints Icons
@@ -106,11 +106,8 @@
final Component component = createNoPermsComponent();
// 6482575 - clear the appContext field so as not to leak it
- Field appContextField =
-
- Component.class.getDeclaredField("appContext");
- appContextField.setAccessible(true);
- appContextField.set(component, null);
+ AWTAccessor.getComponentAccessor().
+ setAppContext(component, null);
return component;
} catch (Throwable e) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Wed Aug 24 00:23:49 2016 +0400
@@ -55,6 +55,7 @@
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
+import sun.swing.SwingAccessor;
import sun.swing.SwingUtilities2;
/**
@@ -376,6 +377,21 @@
private transient Object aaHint;
private transient Object lcdRenderingHint;
+ static {
+ SwingAccessor.setJComponentAccessor(new SwingAccessor.JComponentAccessor() {
+
+ @Override
+ public boolean getFlag(JComponent comp, int aFlag) {
+ return comp.getFlag(aFlag);
+ }
+
+ @Override
+ public void compWriteObjectNotify(JComponent comp) {
+ comp.compWriteObjectNotify();
+ }
+ });
+ }
+
static Graphics safelyGetGraphics(Component c) {
return safelyGetGraphics(c, SwingUtilities.getRoot(c));
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java Wed Aug 24 00:23:49 2016 +0400
@@ -261,23 +261,7 @@
if (painter == null) {
if (defaultPainter == null) {
// the classname should probably come from a property file.
- String classname = "javax.swing.text.GlyphPainter1";
- try {
- Class<?> c;
- ClassLoader loader = getClass().getClassLoader();
- if (loader != null) {
- c = loader.loadClass(classname);
- } else {
- c = Class.forName(classname);
- }
- Object o = c.newInstance();
- if (o instanceof GlyphPainter) {
- defaultPainter = (GlyphPainter) o;
- }
- } catch (Throwable e) {
- throw new StateInvariantError("GlyphView: Can't load glyph painter: "
- + classname);
- }
+ defaultPainter = new GlyphPainter1();
}
setGlyphPainter(defaultPainter.getPainter(this, getStartOffset(),
getEndOffset()));
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java Wed Aug 24 00:23:49 2016 +0400
@@ -61,20 +61,8 @@
Object i18nFlag = doc.getProperty(AbstractDocument.I18NProperty);
if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) {
try {
- if (i18nStrategy == null) {
- // the classname should probably come from a property file.
- String classname = "javax.swing.text.TextLayoutStrategy";
- ClassLoader loader = getClass().getClassLoader();
- if (loader != null) {
- i18nStrategy = loader.loadClass(classname);
- } else {
- i18nStrategy = Class.forName(classname);
- }
- }
- Object o = i18nStrategy.newInstance();
- if (o instanceof FlowStrategy) {
- strategy = (FlowStrategy) o;
- }
+ // the classname should probably come from a property file.
+ strategy = new TextLayoutStrategy();
} catch (Throwable e) {
throw new StateInvariantError("ParagraphView: Can't create i18n strategy: "
+ e.getMessage());
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java Wed Aug 24 00:23:49 2016 +0400
@@ -40,6 +40,7 @@
import java.lang.ref.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import javax.swing.text.html.parser.ParserDelegator;
/**
* The Swing JEditorPane text component supports different kinds
@@ -610,11 +611,7 @@
*/
protected Parser getParser() {
if (defaultParser == null) {
- try {
- Class<?> c = Class.forName("javax.swing.text.html.parser.ParserDelegator");
- defaultParser = (Parser) c.newInstance();
- } catch (Throwable e) {
- }
+ defaultParser = new ParserDelegator();
}
return defaultParser;
}
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java Wed Aug 24 00:23:49 2016 +0400
@@ -616,34 +616,8 @@
* calls KeyboardFocusManager directly.
*/
private Component getMostRecentFocusOwnerForWindow(Window w) {
- Method meth = AccessController.doPrivileged(
- new PrivilegedAction<Method>() {
- @Override
- public Method run() {
- Method meth = null;
- try {
- meth = KeyboardFocusManager.class.getDeclaredMethod(
- "getMostRecentFocusOwner",
- new Class<?>[]{Window.class});
- meth.setAccessible(true);
- } catch (Exception e) {
- // Must never happen
- e.printStackTrace();
- }
- return meth;
- }
- });
- if (meth != null) {
- // Meth refers static method
- try {
- return (Component)meth.invoke(null, new Object[] {w});
- } catch (Exception e) {
- // Must never happen
- e.printStackTrace();
- }
- }
- // Will get here if exception was thrown or meth is null
- return w.getMostRecentFocusOwner();
+ return AWTAccessor.getKeyboardFocusManagerAccessor()
+ .getMostRecentFocusOwner(w);
}
/*
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java Wed Aug 24 00:23:49 2016 +0400
@@ -34,6 +34,7 @@
import java.awt.dnd.DropTargetContext;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.dnd.peer.DropTargetContextPeer;
+import java.awt.event.AWTEventListener;
import java.awt.event.InputEvent;
import java.awt.event.InvocationEvent;
import java.awt.event.KeyEvent;
@@ -48,6 +49,7 @@
import java.io.File;
import java.util.ResourceBundle;
import java.util.Vector;
+import javax.accessibility.AccessibleBundle;
/**
* The AWTAccessor utility class.
@@ -406,6 +408,8 @@
* Accessor for InputEvent.canAccessSystemClipboard field
*/
boolean canAccessSystemClipboard(InputEvent event);
+ void setCanAccessSystemClipboard(InputEvent event,
+ boolean canAccessSystemClipboard);
}
/*
@@ -455,6 +459,11 @@
void removeLastFocusRequest(Component heavyweight);
/**
+ * Gets the most recent focus owner in the window.
+ */
+ Component getMostRecentFocusOwner(Window window);
+
+ /**
* Sets the most recent focus owner in the window.
*/
void setMostRecentFocusOwner(Window window, Component component);
@@ -708,6 +717,11 @@
* Gets original source for KeyEvent
*/
Component getOriginalSource(KeyEvent ev);
+
+ /**
+ * Gets isProxyActive field for KeyEvent
+ */
+ boolean isProxyActive(KeyEvent ev);
}
/**
@@ -758,6 +772,11 @@
* Returns true if the event is an instances of SequencedEvent.
*/
boolean isSequencedEvent(AWTEvent event);
+
+ /*
+ * Creates SequencedEvent with the given nested event
+ */
+ AWTEvent create(AWTEvent event);
}
/*
@@ -787,6 +806,15 @@
public interface AccessibleContextAccessor {
void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
AppContext getAppContext(AccessibleContext accessibleContext);
+ Object getNativeAXResource(AccessibleContext accessibleContext);
+ void setNativeAXResource(AccessibleContext accessibleContext, Object value);
+ }
+
+ /*
+ * An accessor object for the AccessibleContext class
+ */
+ public interface AccessibleBundleAccessor {
+ String getKey(AccessibleBundle accessibleBundle);
}
/*
@@ -845,6 +873,7 @@
private static InvocationEventAccessor invocationEventAccessor;
private static SystemColorAccessor systemColorAccessor;
private static AccessibleContextAccessor accessibleContextAccessor;
+ private static AccessibleBundleAccessor accessibleBundleAccessor;
private static DragSourceContextAccessor dragSourceContextAccessor;
private static DropTargetContextAccessor dropTargetContextAccessor;
@@ -1235,9 +1264,13 @@
* Get the accessor object for the java.awt.SequencedEvent class.
*/
public static SequencedEventAccessor getSequencedEventAccessor() {
- // The class is not public. So we can't ensure it's initialized.
- // Null returned value means it's not initialized
- // (so not a single instance of the event has been created).
+ if (sequencedEventAccessor == null) {
+ try {
+ unsafe.ensureClassInitialized(
+ Class.forName("java.awt.SequencedEvent"));
+ } catch (ClassNotFoundException ignore) {
+ }
+ }
return sequencedEventAccessor;
}
@@ -1302,6 +1335,23 @@
}
/*
+ * Set the accessor object for the javax.accessibility.AccessibleBundle class.
+ */
+ public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) {
+ AWTAccessor.accessibleBundleAccessor = accessor;
+ }
+
+ /*
+ * Get the accessor object for the javax.accessibility.AccessibleBundle class.
+ */
+ public static AccessibleBundleAccessor getAccessibleBundleAccessor() {
+ if (accessibleBundleAccessor == null) {
+ unsafe.ensureClassInitialized(AccessibleBundle.class);
+ }
+ return accessibleBundleAccessor;
+ }
+
+ /*
* Set the accessor object for the javax.accessibility.AccessibleContext class.
*/
public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
@@ -1342,4 +1392,4 @@
AWTAccessor.dropTargetContextAccessor = accessor;
}
-}
+}
\ No newline at end of file
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java Wed Aug 24 00:23:49 2016 +0400
@@ -372,26 +372,6 @@
cont.setFocusTraversalPolicy(defaultPolicy);
}
- private static FocusTraversalPolicy createLayoutPolicy() {
- FocusTraversalPolicy policy = null;
- try {
- Class<?> layoutPolicyClass =
- Class.forName("javax.swing.LayoutFocusTraversalPolicy");
- policy = (FocusTraversalPolicy)layoutPolicyClass.newInstance();
- }
- catch (ClassNotFoundException e) {
- assert false;
- }
- catch (InstantiationException e) {
- assert false;
- }
- catch (IllegalAccessException e) {
- assert false;
- }
-
- return policy;
- }
-
/*
* Insert a mapping from target to AppContext, for later retrieval
* via targetToAppContext() above.
--- a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java Wed Aug 24 00:23:49 2016 +0400
@@ -51,6 +51,16 @@
}
/**
+ * An accessor for the JComponent class.
+ */
+ public interface JComponentAccessor {
+
+ boolean getFlag(JComponent comp, int aFlag);
+
+ void compWriteObjectNotify(JComponent comp);
+ }
+
+ /**
* An accessor for the JTextComponent class.
* Note that we intentionally introduce the JTextComponentAccessor,
* and not the JComponentAccessor because the needed methods
@@ -106,6 +116,29 @@
}
/**
+ * The javax.swing.JComponent class accessor object.
+ */
+ private static JComponentAccessor jComponentAccessor;
+
+ /**
+ * Set an accessor object for the javax.swing.JComponent class.
+ */
+ public static void setJComponentAccessor(JComponentAccessor jCompAccessor) {
+ jComponentAccessor = jCompAccessor;
+ }
+
+ /**
+ * Retrieve the accessor object for the javax.swing.JComponent class.
+ */
+ public static JComponentAccessor getJComponentAccessor() {
+ if (jComponentAccessor == null) {
+ unsafe.ensureClassInitialized(JComponent.class);
+ }
+
+ return jComponentAccessor;
+ }
+
+ /**
* The javax.swing.text.JTextComponent class accessor object.
*/
private static JTextComponentAccessor jtextComponentAccessor;
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java Wed Aug 24 00:23:49 2016 +0400
@@ -57,8 +57,6 @@
import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
-import java.lang.reflect.*;
-import java.security.*;
import java.util.Collection;
import java.util.Objects;
import java.util.Set;
@@ -241,46 +239,8 @@
return false;
}
- private static Class<?> seClass;
- private static Constructor<?> seCtor;
-
static final AWTEvent wrapInSequenced(AWTEvent event) {
- try {
- if (seClass == null) {
- seClass = Class.forName("java.awt.SequencedEvent");
- }
-
- if (seCtor == null) {
- seCtor = AccessController.doPrivileged(new
- PrivilegedExceptionAction<Constructor<?>>() {
- public Constructor<?> run() throws Exception {
- Constructor<?> ctor = seClass.getConstructor(
- new Class<?>[] { AWTEvent.class });
- ctor.setAccessible(true);
- return ctor;
- }
- });
- }
-
- return (AWTEvent) seCtor.newInstance(new Object[] { event });
- }
- catch (ClassNotFoundException e) {
- throw new NoClassDefFoundError("java.awt.SequencedEvent.");
- }
- catch (PrivilegedActionException ex) {
- throw new NoClassDefFoundError("java.awt.SequencedEvent.");
- }
- catch (InstantiationException e) {
- assert false;
- }
- catch (IllegalAccessException e) {
- assert false;
- }
- catch (InvocationTargetException e) {
- assert false;
- }
-
- return null;
+ return AWTAccessor.getSequencedEventAccessor().create(event);
}
// TODO: consider moving it to KeyboardFocusManagerPeerImpl
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java Wed Aug 24 00:23:49 2016 +0400
@@ -36,10 +36,6 @@
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-
-import java.lang.reflect.*;
import sun.awt.dnd.SunDragSourceContextPeer;
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java Tue Aug 23 20:45:35 2016 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java Wed Aug 24 00:23:49 2016 +0400
@@ -32,8 +32,6 @@
import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
-
import sun.awt.AWTAccessor.ComponentAccessor;
import sun.util.logging.PlatformLogger;
@@ -395,7 +393,6 @@
return false;
}
- static Method m_sendMessage;
static void sendEvent(final AWTEvent e) {
// The uses of this method imply that the incoming event is system-generated
SunToolkit.setSystemGenerated(e);