8030087: Avoid public native methods in sun.awt packages
authorserb
Sat, 16 May 2015 02:37:16 +0300
changeset 30938 35ae5c70d60e
parent 30937 95d84a11bee3
child 30939 59e64fa7aec2
8030087: Avoid public native methods in sun.awt packages Reviewed-by: azvegint, prr
jdk/src/java.desktop/share/classes/sun/awt/DefaultMouseInfoPeer.java
jdk/src/java.desktop/share/classes/sun/awt/HToolkit.java
jdk/src/java.desktop/unix/classes/sun/awt/FcFontManager.java
jdk/src/java.desktop/unix/classes/sun/awt/X11FontManager.java
jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java
jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java
jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java
jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java
jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java
jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java
jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/DefaultMouseInfoPeer.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/DefaultMouseInfoPeer.java	Sat May 16 02:37:16 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -29,7 +29,7 @@
 import java.awt.Window;
 import java.awt.peer.MouseInfoPeer;
 
-public class DefaultMouseInfoPeer implements MouseInfoPeer {
+public final class DefaultMouseInfoPeer implements MouseInfoPeer {
 
     /**
      * Package-private constructor to prevent instantiation.
--- a/jdk/src/java.desktop/share/classes/sun/awt/HToolkit.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/HToolkit.java	Sat May 16 02:37:16 2015 +0300
@@ -45,8 +45,7 @@
  * with the HeadlessToolkit.  It is primarily used
  * in embedded JRE's that do not have sun/awt/X11 classes.
  */
-public class HToolkit extends SunToolkit
-    implements ComponentFactory {
+public final class HToolkit extends SunToolkit implements ComponentFactory {
 
     private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
         @Override
--- a/jdk/src/java.desktop/unix/classes/sun/awt/FcFontManager.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/FcFontManager.java	Sat May 16 02:37:16 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -98,8 +98,7 @@
         return info;
     }
 
-    protected native String getFontPathNative(boolean noType1Fonts,
-                                              boolean isX11GE);
+    native String getFontPathNative(boolean noType1Fonts, boolean isX11GE);
 
     protected synchronized String getFontPath(boolean noType1Fonts) {
         return getFontPathNative(noType1Fonts, false);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11FontManager.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11FontManager.java	Sat May 16 02:37:16 2015 +0300
@@ -44,7 +44,6 @@
 import sun.font.CompositeFont;
 import sun.font.FontManager;
 import sun.font.SunFontManager;
-import sun.font.FontConfigManager;
 import sun.font.FcFontConfiguration;
 import sun.font.FontAccess;
 import sun.font.FontUtilities;
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java	Sat May 16 02:37:16 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -27,7 +27,6 @@
 
 import java.awt.AWTException;
 import java.awt.BufferCapabilities;
-import java.awt.BufferCapabilities.FlipContents;
 import java.awt.Component;
 import java.awt.Toolkit;
 import java.awt.GraphicsConfiguration;
@@ -35,7 +34,6 @@
 import java.awt.Image;
 import java.awt.ImageCapabilities;
 import java.awt.Transparency;
-import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
 import java.awt.color.ColorSpace;
 import java.awt.image.ComponentColorModel;
@@ -55,7 +53,6 @@
 import sun.awt.image.OffScreenImage;
 import sun.awt.image.SunVolatileImage;
 import sun.awt.image.SurfaceManager;
-import sun.awt.X11ComponentPeer;
 
 /**
  * This is an implementation of a GraphicsConfiguration object for a
@@ -314,7 +311,7 @@
         return pGetBounds(screen.getScreen());
     }
 
-    public native Rectangle pGetBounds(int screenNum);
+    private native Rectangle pGetBounds(int screenNum);
 
     private static class XDBECapabilities extends BufferCapabilities {
         public XDBECapabilities() {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Sat May 16 02:37:16 2015 +0300
@@ -52,10 +52,8 @@
  * @see GraphicsEnvironment
  * @see GraphicsConfiguration
  */
-public class X11GraphicsDevice
-    extends GraphicsDevice
-    implements DisplayChangedListener
-{
+public final class X11GraphicsDevice extends GraphicsDevice
+        implements DisplayChangedListener {
     int screen;
     HashMap<SurfaceType, Object> x11ProxyKeyMap = new HashMap<>();
 
@@ -201,16 +199,15 @@
     /*
      * Returns the depth for the given index of graphics configurations.
      */
-    public native int getConfigDepth (int index, int screen);
+    private native int getConfigDepth(int index, int screen);
 
     /*
      * Returns the colormap for the given index of graphics configurations.
      */
-    public native int getConfigColormap (int index, int screen);
-
+    private native int getConfigColormap(int index, int screen);
 
     // Whether or not double-buffering extension is supported
-    public static native boolean isDBESupported();
+    static native boolean isDBESupported();
     // Callback for adding a new double buffer visual into our set
     private void addDoubleBufferVisual(int visNum) {
         doubleBufferVisuals.add(Integer.valueOf(visNum));
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java	Sat May 16 02:37:16 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -29,13 +29,6 @@
 import java.awt.GraphicsDevice;
 import java.awt.Point;
 import java.awt.Rectangle;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.StreamTokenizer;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
 import java.net.SocketException;
@@ -43,11 +36,6 @@
 
 import java.util.*;
 
-import sun.font.MFontConfiguration;
-import sun.font.FcFontConfiguration;
-import sun.font.Font2D;
-import sun.font.FontManager;
-import sun.font.NativeFont;
 import sun.java2d.SunGraphicsEnvironment;
 import sun.java2d.SurfaceManagerFactory;
 import sun.java2d.UnixSurfaceManagerFactory;
@@ -62,9 +50,8 @@
  * @see GraphicsDevice
  * @see GraphicsConfiguration
  */
-public class X11GraphicsEnvironment
-    extends SunGraphicsEnvironment
-{
+public final class X11GraphicsEnvironment extends SunGraphicsEnvironment {
+
     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11GraphicsEnvironment");
     private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.screen.X11GraphicsEnvironment");
 
@@ -200,7 +187,7 @@
         return new X11GraphicsDevice(screennum);
     }
 
-    protected native int getDefaultScreenNum();
+    private native int getDefaultScreenNum();
     /**
      * Returns the default screen graphics device.
      */
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java	Sat May 16 02:37:16 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -35,16 +35,9 @@
 import java.awt.Container;
 import java.awt.EventQueue;
 import java.awt.Window;
-import java.awt.im.InputContext;
 import java.awt.im.InputMethodHighlight;
 import java.awt.im.spi.InputMethodContext;
 import sun.awt.im.InputMethodAdapter;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-import java.awt.event.FocusEvent;
-import java.awt.event.ComponentEvent;
-import java.awt.event.WindowEvent;
 import java.awt.event.InputMethodEvent;
 import java.awt.font.TextAttribute;
 import java.awt.font.TextHitInfo;
@@ -1095,7 +1088,7 @@
     /*
      * Native methods
      */
-    protected native String resetXIC();
+    private native String resetXIC();
     private native void disposeXIC();
     private native boolean setCompositionEnabledNative(boolean enable);
     private native boolean isCompositionEnabledNative();
--- a/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java	Sat May 16 02:37:16 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, 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
@@ -279,9 +279,9 @@
          });
     }
 
-    protected static native void registerFontWithPlatform(String fontName);
+    private static native void registerFontWithPlatform(String fontName);
 
-    protected static native void deRegisterFontWithPlatform(String fontName);
+    private static native void deRegisterFontWithPlatform(String fontName);
 
     /**
      * populate the map with the most common windows fonts.
--- a/jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java	Sat May 16 02:37:16 2015 +0300
@@ -226,7 +226,7 @@
      * are disabled.  Do not call this function with an index of 0.
      * @param index a PixelFormat index
      */
-    protected native boolean isPixFmtSupported(int index, int screen);
+    private native boolean isPixFmtSupported(int index, int screen);
 
     /**
      * Returns the PixelFormatID of the default graphics configuration
--- a/jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java	Fri May 15 22:11:14 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java	Sat May 16 02:37:16 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -28,19 +28,11 @@
 import java.awt.AWTError;
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import java.awt.Toolkit;
 import java.awt.peer.ComponentPeer;
-import java.io.File;
-import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-import sun.awt.DisplayChangedListener;
-import sun.awt.SunDisplayChanger;
-import sun.awt.windows.WPrinterJob;
+
 import sun.awt.windows.WToolkit;
 import sun.java2d.SunGraphicsEnvironment;
 import sun.java2d.SurfaceManagerFactory;
@@ -57,9 +49,8 @@
  * @see GraphicsConfiguration
  */
 
-public class Win32GraphicsEnvironment
-    extends SunGraphicsEnvironment
-{
+public final class Win32GraphicsEnvironment extends SunGraphicsEnvironment {
+
     static {
         // Ensure awt is loaded already.  Also, this forces static init
         // of WToolkit and Toolkit, which we depend upon
@@ -91,7 +82,7 @@
     }
 
     protected native int getNumScreens();
-    protected native int getDefaultScreen();
+    private native int getDefaultScreen();
 
     public GraphicsDevice getDefaultScreenDevice() {
         GraphicsDevice[] screens = getScreenDevices();