changeset 2859:c595c2730226

6989721: awt native code compiler warnings Reviewed-by: yan, uta
author art
date Thu, 14 Oct 2010 14:07:50 +0400
parents 278bd32a15de
children 8022709a306d
files src/share/classes/java/awt/event/InputEvent.java src/share/classes/sun/awt/AWTAccessor.java src/share/native/sun/awt/libpng/pngrtran.c src/share/native/sun/awt/libpng/pngrutil.c src/share/native/sun/awt/splashscreen/splashscreen_gif.c src/solaris/classes/sun/awt/X11/XRobotPeer.java src/solaris/native/sun/awt/awt.h src/solaris/native/sun/awt/awt_DrawingSurface.c src/solaris/native/sun/awt/awt_InputMethod.c src/solaris/native/sun/awt/awt_Robot.c src/solaris/native/sun/awt/awt_UNIXToolkit.c src/solaris/native/sun/xawt/XlibWrapper.c src/solaris/native/sun/xawt/awt_Desktop.c src/windows/native/sun/windows/WPrinterJob.cpp src/windows/native/sun/windows/awt_BitmapUtil.cpp src/windows/native/sun/windows/awt_DesktopProperties.cpp src/windows/native/sun/windows/awt_DrawingSurface.h src/windows/native/sun/windows/awt_Font.cpp src/windows/native/sun/windows/awt_PrintJob.cpp src/windows/native/sun/windows/awt_Toolkit.cpp src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp src/windows/native/sun/windows/awt_Window.cpp
diffstat 22 files changed, 139 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/event/InputEvent.java	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/share/classes/java/awt/event/InputEvent.java	Thu Oct 14 14:07:50 2010 +0400
@@ -29,8 +29,10 @@
 import java.awt.Component;
 import java.awt.GraphicsEnvironment;
 import java.awt.Toolkit;
+import java.util.Arrays;
+
+import sun.awt.AWTAccessor;
 import sun.util.logging.PlatformLogger;
-import java.util.Arrays;
 
 /**
  * The root event class for all component-level input events.
@@ -54,6 +56,7 @@
  * @since 1.1
  */
 public abstract class InputEvent extends ComponentEvent {
+
     private static final PlatformLogger logger = PlatformLogger.getLogger("java.awt.event.InputEvent");
 
     /**
@@ -288,6 +291,12 @@
         if (!GraphicsEnvironment.isHeadless()) {
             initIDs();
         }
+        AWTAccessor.setInputEventAccessor(
+            new AWTAccessor.InputEventAccessor() {
+                public int[] getButtonDownMasks() {
+                    return getButtonDownMasks();
+                }
+            });
     }
 
     /**
--- a/src/share/classes/sun/awt/AWTAccessor.java	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Thu Oct 14 14:07:50 2010 +0400
@@ -26,6 +26,7 @@
 package sun.awt;
 
 import java.awt.*;
+import java.awt.event.InputEvent;
 import java.awt.geom.Point2D;
 import java.awt.image.BufferedImage;
 
@@ -303,6 +304,13 @@
         void setPosted(AWTEvent ev);
     }
 
+    public interface InputEventAccessor {
+        /*
+         * Accessor for InputEvent.getButtonDownMasks()
+         */
+        int[] getButtonDownMasks();
+    }
+
     /*
      * An accessor for the java.awt.Frame class.
      */
@@ -436,6 +444,11 @@
     private static AWTEventAccessor awtEventAccessor;
 
     /*
+     * The java.awt.event.InputEvent class accessor object.
+     */
+    private static InputEventAccessor inputEventAccessor;
+
+    /*
      * The java.awt.Frame class accessor object.
      */
     private static FrameAccessor frameAccessor;
@@ -518,6 +531,23 @@
     }
 
     /*
+     * Set an accessor object for the java.awt.event.InputEvent class.
+     */
+    public static void setInputEventAccessor(InputEventAccessor iea) {
+        inputEventAccessor = iea;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.event.InputEvent class.
+     */
+    public static InputEventAccessor getInputEventAccessor() {
+        if (inputEventAccessor == null) {
+            unsafe.ensureClassInitialized(InputEvent.class);
+        }
+        return inputEventAccessor;
+    }
+
+    /*
      * Set an accessor object for the java.awt.Frame class.
      */
     public static void setFrameAccessor(FrameAccessor fa) {
--- a/src/share/native/sun/awt/libpng/pngrtran.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/share/native/sun/awt/libpng/pngrtran.c	Thu Oct 14 14:07:50 2010 +0400
@@ -3993,7 +3993,7 @@
 
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 #if defined(PNG_READ_GAMMA_SUPPORTED)
-const static int png_gamma_shift[] =
+static PNG_CONST int png_gamma_shift[] =
    {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
 
 /* We build the 8- or 16-bit gamma tables here.  Note that for 16-bit
--- a/src/share/native/sun/awt/libpng/pngrutil.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/share/native/sun/awt/libpng/pngrutil.c	Thu Oct 14 14:07:50 2010 +0400
@@ -209,7 +209,7 @@
                               png_charp chunkdata, png_size_t chunklength,
                               png_size_t prefix_size, png_size_t *newlength)
 {
-   const static char msg[] = "Error decoding compressed text";
+   static PNG_CONST char msg[] = "Error decoding compressed text";
    png_charp text;
    png_size_t text_size;
 
--- a/src/share/native/sun/awt/splashscreen/splashscreen_gif.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/share/native/sun/awt/splashscreen/splashscreen_gif.c	Thu Oct 14 14:07:50 2010 +0400
@@ -51,7 +51,7 @@
 #define NSEXT_LOOP      0x01    // Loop Count field code
 
 // convert libungif samples to our ones
-#define MAKE_QUAD_GIF(c,a) MAKE_QUAD((c).Red, (c).Green, (c).Blue, (a))
+#define MAKE_QUAD_GIF(c,a) MAKE_QUAD((c).Red, (c).Green, (c).Blue, (unsigned)(a))
 
 /* stdio FILE* and memory input functions for libungif */
 int
@@ -165,7 +165,7 @@
                 {
                     int flag = pExtension[0];
 
-                    frameDelay = (pExtension[2] << 8) | pExtension[1];
+                    frameDelay = (((int)pExtension[2]) << 8) | pExtension[1];
                     if (frameDelay < 10)
                         frameDelay = 10;
                     if (flag & GIF_TRANSPARENT) {
@@ -191,7 +191,7 @@
                         iSubCode = pExtension[0] & 0x07;
                         if (iSubCode == NSEXT_LOOP) {
                             splash->loopCount =
-                                (pExtension[1] | (pExtension[2] << 8)) - 1;
+                                (pExtension[1] | (((int)pExtension[2]) << 8)) - 1;
                         }
                     }
                     break;
--- a/src/solaris/classes/sun/awt/X11/XRobotPeer.java	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/classes/sun/awt/X11/XRobotPeer.java	Thu Oct 14 14:07:50 2010 +0400
@@ -25,11 +25,15 @@
 package sun.awt.X11;
 
 import java.awt.*;
+import java.awt.event.InputEvent;
 import java.awt.peer.*;
+
+import sun.awt.AWTAccessor;
+import sun.awt.SunToolkit;
 import sun.awt.X11GraphicsConfig;
-import sun.awt.SunToolkit;
 
 class XRobotPeer implements RobotPeer {
+
     private X11GraphicsConfig   xgc = null;
     /*
      * native implementation uses some static shared data (pipes, processes)
@@ -40,7 +44,7 @@
     XRobotPeer(GraphicsConfiguration gc) {
         this.xgc = (X11GraphicsConfig)gc;
         SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
-        setup(tk.getNumberOfButtons());
+        setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks());
     }
 
     public void dispose() {
@@ -83,7 +87,7 @@
         return pixelArray;
     }
 
-    private static native synchronized void setup(int numberOfButtons);
+    private static native synchronized void setup(int numberOfButtons, int[] buttonDownMasks);
 
     private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
     private static native synchronized void mousePressImpl(int buttons);
--- a/src/solaris/native/sun/awt/awt.h	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/native/sun/awt/awt.h	Thu Oct 14 14:07:50 2010 +0400
@@ -159,20 +159,8 @@
 #endif /* DEBUG_AWT_LOCK && !XAWT */
 
 #ifndef HEADLESS
-extern Display         *awt_display;            /* awt_GraphicsEnv.c */
-extern XtAppContext     awt_appContext;         /* awt_MToolkit.c */
-extern Widget           awt_root_shell;
-extern Pixel            awt_defaultBg;
-extern Pixel            awt_defaultFg;
-extern int              awt_multiclick_time;    /* awt_MToolkit.c */
-extern int              awt_multiclick_smudge;  /* canvas.c */
-extern unsigned int     awt_MetaMask;           /* awt_MToolkit.c */
-extern unsigned int     awt_AltMask;
-extern unsigned int     awt_NumLockMask;
-extern unsigned int     awt_ModeSwitchMask;
-extern Cursor           awt_scrollCursor;       /* awt_MToolkit.c */
-extern Boolean          awt_ModLockIsShiftLock;
-
+extern Display         *awt_display; /* awt_GraphicsEnv.c */
+extern Boolean          awt_ModLockIsShiftLock; /* XToolkit.c */
 #endif /* !HEADLESS */
 
 #endif /* ! _AWT_ */
--- a/src/solaris/native/sun/awt/awt_DrawingSurface.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/native/sun/awt/awt_DrawingSurface.c	Thu Oct 14 14:07:50 2010 +0400
@@ -264,7 +264,7 @@
 #ifndef XAWT
     px->drawable = XtWindow(cdata->widget);
 #else
-    px->drawable = JNU_GetLongFieldAsPtr(env, peer, windowID);
+    px->drawable = (*env)->GetLongField(env, peer, windowID);
 #endif
     px->display = awt_display;
 
--- a/src/solaris/native/sun/awt/awt_InputMethod.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/native/sun/awt/awt_InputMethod.c	Thu Oct 14 14:07:50 2010 +0400
@@ -46,8 +46,6 @@
 #ifdef XAWT
 #include <sun_awt_X11_XComponentPeer.h>
 #include <sun_awt_X11_XInputMethod.h>
-
-#define XtWindow(w)     (w)
 #else /* !XAWT */
 #include <sun_awt_motif_MComponentPeer.h>
 #include <sun_awt_motif_MInputMethod.h>
@@ -670,7 +668,8 @@
     int  mccr = 0;
     char *dsr;
     Pixel bg, fg, light, dim;
-    int x, y, w, h, bw, depth, off_x, off_y, xx, yy;
+    int x, y, off_x, off_y, xx, yy;
+    unsigned int w, h, bw, depth;
     XGCValues values;
     unsigned long valuemask = 0;  /*ignore XGCvalue and use defaults*/
     int screen = 0;
@@ -709,7 +708,7 @@
     light = adata->AwtColorMatch(195, 195, 195, adata);
     dim   = adata->AwtColorMatch(128, 128, 128, adata);
 
-    XGetWindowAttributes(dpy, XtWindow(parent), &xwa);
+    XGetWindowAttributes(dpy, parent, &xwa);
     bw = 2; /*xwa.border_width does not have the correct value*/
 
     /*compare the size difference between parent container
@@ -717,7 +716,7 @@
       and title bar height (?)*/
 
     XQueryTree( dpy,
-                XtWindow(parent),
+                parent,
                 &rootWindow,
                 &containerWindow,
                 &ignoreWindowPtr,
@@ -731,7 +730,7 @@
     XGetWindowAttributes(dpy, rootWindow, &xxwa);
 
     XTranslateCoordinates(dpy,
-                          XtWindow(parent), xwa.root,
+                          parent, xwa.root,
                           xwa.x, xwa.y,
                           &x, &y,
                           &child);
@@ -833,9 +832,9 @@
     if (statusWindow->parent != parent){
         statusWindow->parent = parent;
     }
-    XGetWindowAttributes(dpy, XtWindow(parent), &xwa);
+    XGetWindowAttributes(dpy, parent, &xwa);
     XTranslateCoordinates(dpy,
-                          XtWindow(parent), xwa.root,
+                          parent, xwa.root,
                           xwa.x, xwa.y,
                           &x, &y,
                           &child);
@@ -966,9 +965,9 @@
         XWindowAttributes xwa;
         int x, y;
         Window child;
-        XGetWindowAttributes(dpy, XtWindow(shell), &xwa);
+        XGetWindowAttributes(dpy, shell, &xwa);
         XTranslateCoordinates(dpy,
-                              XtWindow(shell), xwa.root,
+                              shell, xwa.root,
                               xwa.x, xwa.y,
                               &x, &y,
                               &child);
@@ -1033,7 +1032,7 @@
         return False;
     }
 #ifdef XAWT
-    if (w == NULL) {
+    if (!w) {
         return False;
     }
 #else /* !XAWT */
@@ -1148,8 +1147,8 @@
                 goto err;
             pX11IMData->statusWindow = createStatusWindow(w);
             pX11IMData->ic_active = XCreateIC(X11im,
-                                              XNClientWindow, XtWindow(w),
-                                              XNFocusWindow, XtWindow(w),
+                                              XNClientWindow, w,
+                                              XNFocusWindow, w,
                                               XNInputStyle, active_styles,
                                               XNPreeditAttributes, preedit,
                                               XNStatusAttributes, status,
@@ -1166,8 +1165,8 @@
                 goto err;
             pX11IMData->statusWidget = awt_util_getXICStatusAreaWindow(w);
             pX11IMData->ic_active = XCreateIC(X11im,
-                                              XNClientWindow, XtWindow(pX11IMData->statusWidget),
-                                              XNFocusWindow, XtWindow(w),
+                                              XNClientWindow, pX11IMData->statusWidget,
+                                              XNFocusWindow, w,
                                               XNInputStyle, active_styles,
                                               XNPreeditAttributes, preedit,
                                               XNStatusAttributes, status,
@@ -1176,8 +1175,8 @@
         } else {
 #endif /* XAWT */
             pX11IMData->ic_active = XCreateIC(X11im,
-                                              XNClientWindow, XtWindow(w),
-                                              XNFocusWindow, XtWindow(w),
+                                              XNClientWindow, w,
+                                              XNFocusWindow, w,
                                               XNInputStyle, active_styles,
                                               XNPreeditAttributes, preedit,
                                               NULL);
@@ -1187,15 +1186,15 @@
         XFree((void *)preedit);
 #endif /* __linux__ */
         pX11IMData->ic_passive = XCreateIC(X11im,
-                                           XNClientWindow, XtWindow(w),
-                                           XNFocusWindow, XtWindow(w),
+                                           XNClientWindow, w,
+                                           XNFocusWindow, w,
                                            XNInputStyle, passive_styles,
                                            NULL);
 
     } else {
         pX11IMData->ic_active = XCreateIC(X11im,
-                                          XNClientWindow, XtWindow(w),
-                                          XNFocusWindow, XtWindow(w),
+                                          XNClientWindow, w,
+                                          XNFocusWindow, w,
                                           XNInputStyle, active_styles,
                                           NULL);
         pX11IMData->ic_passive = pX11IMData->ic_active;
@@ -1213,7 +1212,7 @@
     {
         XIMCallback cb;
         cb.client_data = (XPointer) pX11IMData->x11inputmethod;
-        cb.callback = CommitStringCallback;
+        cb.callback = (XIMProc) CommitStringCallback;
         XSetICValues (pX11IMData->ic_active, XNCommitStringCallback, &cb, NULL);
         if (pX11IMData->ic_active != pX11IMData->ic_passive) {
             XSetICValues (pX11IMData->ic_passive, XNCommitStringCallback, &cb, NULL);
@@ -1506,7 +1505,7 @@
     AWT_LOCK();
 
 #ifdef XAWT
-    dpy = (Display *)display;
+    dpy = (Display *)jlong_to_ptr(display);
 #else
     dpy = awt_display;
 #endif
@@ -1516,7 +1515,7 @@
 */
 #ifdef __linux__
     registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL,
-                     NULL, (XIMProc)OpenXIMCallback, NULL);
+                     NULL, (XIDProc)OpenXIMCallback, NULL);
     if (!registered) {
         /* directly call openXIM callback */
 #endif
@@ -1551,7 +1550,7 @@
     AWT_LOCK();
 
 #ifdef XAWT
-    if (window == NULL) {
+    if (!window) {
 #else /* !XAWT */
     if (JNU_IsNull(env, comp)) {
 #endif /* XAWT */
@@ -1660,7 +1659,7 @@
              * On Solaris2.6, setXICWindowFocus() has to be invoked
              * before setting focus.
              */
-            setXICWindowFocus(pX11IMData->current_ic, XtWindow(cdata->widget));
+            setXICWindowFocus(pX11IMData->current_ic, cdata->widget);
             setXICFocus(pX11IMData->current_ic, True);
         } else {
             destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
@@ -1701,7 +1700,7 @@
 
     if (req) {
 #ifdef XAWT
-        if (w == NULL) {
+        if (!w) {
             AWT_UNLOCK();
             return;
         }
@@ -1734,10 +1733,10 @@
 #ifndef XAWT
         w = cdata->widget;
 #endif /* XAWT */
-        setXICWindowFocus(pX11IMData->current_ic, XtWindow(w));
+        setXICWindowFocus(pX11IMData->current_ic, w);
         setXICFocus(pX11IMData->current_ic, req);
         currentX11InputMethodInstance = pX11IMData->x11inputmethod;
-        currentFocusWindow =  XtWindow(w);
+        currentFocusWindow =  w;
 #ifdef __linux__
         if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on)
             onoffStatusWindow(pX11IMData, w, True);
--- a/src/solaris/native/sun/awt/awt_Robot.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/native/sun/awt/awt_Robot.c	Thu Oct 14 14:07:50 2010 +0400
@@ -165,41 +165,34 @@
 
 // this should be called from XRobotPeer constructor
 JNIEXPORT void JNICALL
-Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons) {
+Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons, jintArray buttonDownMasks)
+{
     int32_t xtestAvailable;
+    jint *tmp;
+    int i;
 
     DTRACE_PRINTLN("RobotPeer: setup()");
 
     num_buttons = numberOfButtons;
-
-    jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
-    jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
-    jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
-    jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
-
-    masks  = (jint *)malloc(sizeof(jint) * num_buttons);
+    tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE);
+    masks = (jint *)malloc(sizeof(jint) * num_buttons);
     if (masks == (jint *) NULL) {
         JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
-        goto finally;
+        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
+        return;
     }
-
-    int i;
     for (i = 0; i < num_buttons; i++) {
         masks[i] = tmp[i];
     }
-    (*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
-    (*env)->DeleteLocalRef(env, obj);
+    (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
 
     AWT_LOCK();
     xtestAvailable = isXTestAvailable();
     DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable);
     if (!xtestAvailable) {
         JNU_ThrowByName(env, "java/awt/AWTException", "java.awt.Robot requires your X server support the XTEST extension version 2.2");
-        AWT_UNLOCK();
-        return;
     }
 
-    finally:
     AWT_UNLOCK();
 }
 
--- a/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Thu Oct 14 14:07:50 2010 +0400
@@ -112,7 +112,7 @@
         /* Copy the data array into a Java structure so we can pass it back. */
         jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
         (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
-                                   pixbuf_data);
+                                   (jbyte *)pixbuf_data);
 
         /* Release the pixbuf. */
         (*fp_g_object_unref)(pixbuf);
--- a/src/solaris/native/sun/xawt/XlibWrapper.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/native/sun/xawt/XlibWrapper.c	Thu Oct 14 14:07:50 2010 +0400
@@ -484,8 +484,8 @@
 (JNIEnv *env, jclass clazz, jlong lib_major_in_out, jlong lib_minor_in_out)
 {
     AWT_CHECK_HAVE_LOCK();
-    *((int *)lib_major_in_out) =  XkbMajorVersion;
-    *((int *)lib_minor_in_out) =  XkbMinorVersion;
+    *((int *)jlong_to_ptr(lib_major_in_out)) =  XkbMajorVersion;
+    *((int *)jlong_to_ptr(lib_minor_in_out)) =  XkbMinorVersion;
     return  XkbLibraryVersion((int *)jlong_to_ptr(lib_major_in_out), (int *)jlong_to_ptr(lib_minor_in_out));
 }
 
@@ -1229,7 +1229,6 @@
 (JNIEnv *env, jclass clazz, jlong display)
 {
     int xx;
-    AWT_CHECK_HAVE_LOCK();
     static jboolean result = JNI_FALSE;
 
     int32_t minKeyCode, maxKeyCode, keySymsPerKeyCode;
@@ -1237,6 +1236,8 @@
     int32_t i;
     int32_t kanaCount = 0;
 
+    AWT_CHECK_HAVE_LOCK();
+
     // There's no direct way to determine whether the keyboard has
     // a kana lock key. From available keyboard mapping tables, it looks
     // like only keyboards with the kana lock key can produce keysyms
@@ -1337,12 +1338,14 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XInternAtoms
 (JNIEnv *env, jclass clazz, jlong display, jobjectArray names_arr, jboolean only_if_exists, jlong atoms)
 {
-
     int length = (*env)->GetArrayLength(env, names_arr);
     char ** names = (char**)malloc(length*sizeof(char*));
     jboolean copy;
     int index, name_index = 0;
     int status;
+
+    AWT_CHECK_HAVE_LOCK();
+
     for (index = 0; index < length; index++) {
         jstring str = (*env)->GetObjectArrayElement(env, names_arr, index);
         if (!JNU_IsNull(env, str)) {
@@ -1352,7 +1355,6 @@
             (*env)->DeleteLocalRef(env, str);
         }
     }
-    AWT_CHECK_HAVE_LOCK();
     status = XInternAtoms((Display*)jlong_to_ptr(display), names, name_index, only_if_exists, (Atom*) jlong_to_ptr(atoms));
     for (index = 0; index < length; index++) {
         free(names[index]);
@@ -2186,12 +2188,12 @@
 Java_sun_awt_X11_XlibWrapper_SetZOrder
 (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong above)
 {
-    AWT_CHECK_HAVE_LOCK();
+    unsigned int value_mask = CWStackMode;
 
     XWindowChanges wc;
     wc.sibling = (Window)jlong_to_ptr(above);
 
-    unsigned int value_mask = CWStackMode;
+    AWT_CHECK_HAVE_LOCK();
 
     if (above == 0) {
         wc.stack_mode = Above;
@@ -2219,6 +2221,7 @@
     jboolean isCopy = JNI_FALSE;
     size_t worstBufferSize = (size_t)((width / 2 + 1) * height);
     RECT_T * pRect;
+    int numrects;
 
     AWT_CHECK_HAVE_LOCK();
 
@@ -2237,7 +2240,7 @@
     /* Note: the values[0] and values[1] are supposed to contain the width
      * and height (see XIconInfo.getIntData() for details). So, we do +2.
      */
-    int numrects = BitmapToYXBandedRectangles(32, (int)width, (int)height,
+    numrects = BitmapToYXBandedRectangles(32, (int)width, (int)height,
             (unsigned char *)(values + 2), pRect);
 
     XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
--- a/src/solaris/native/sun/xawt/awt_Desktop.c	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/solaris/native/sun/xawt/awt_Desktop.c	Thu Oct 14 14:07:50 2010 +0400
@@ -28,12 +28,15 @@
 
 typedef int gboolean;
 
-gboolean (*gnome_url_show) (const char *url, void **error);
+typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
+typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
+
+GNOME_URL_SHOW_TYPE *gnome_url_show;
+GNOME_VFS_INIT_TYPE *gnome_vfs_init;
 
 int init(){
     void *vfs_handle;
     void *gnome_handle;
-    gboolean (*gnome_vfs_init) (void);
     const char *errmsg;
 
     vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
@@ -44,7 +47,7 @@
         return 0;
     }
     dlerror(); /* Clear errors */
-    gnome_vfs_init = dlsym(vfs_handle, "gnome_vfs_init");
+    gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
     if ((errmsg = dlerror()) != NULL) {
 #ifdef INTERNAL_BUILD
         fprintf(stderr, "can not find symble gnome_vfs_init\n");
@@ -62,7 +65,7 @@
         return 0;
     }
     dlerror(); /* Clear errors */
-    gnome_url_show = dlsym(gnome_handle, "gnome_url_show");
+    gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
     if ((errmsg = dlerror()) != NULL) {
 #ifdef INTERNAL_BUILD
         fprintf(stderr, "can not find symble gnome_url_show\n");
@@ -94,14 +97,15 @@
   (JNIEnv *env, jobject obj, jbyteArray url_j)
 {
     gboolean success;
+    const char* url_c;
 
-    const char* url_c = (*env)->GetByteArrayElements(env, url_j, NULL);
+    if (gnome_url_show == NULL) {
+        return JNI_FALSE;
+    }
 
-    if (gnome_url_show == NULL) return JNI_FALSE;
-
+    url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
     // call gnome_url_show(const char* , GError**)
     success = (*gnome_url_show)(url_c, NULL);
-
     (*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0);
 
     return success ? JNI_TRUE : JNI_FALSE;
--- a/src/windows/native/sun/windows/WPrinterJob.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/WPrinterJob.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -639,7 +639,7 @@
     if( ::ExtEscape( hDC, GETTECHNOLOGY, 0, NULL, MAX_PATH,
                      (LPSTR)szTechnology ) <= 0 )
         return FALSE;
-    strupr( szTechnology );
+    _strupr_s(szTechnology, MAX_PATH);
     if(!strstr( szTechnology, "POSTSCRIPT" ) == NULL )
         return TRUE;
 
--- a/src/windows/native/sun/windows/awt_BitmapUtil.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_BitmapUtil.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -246,7 +246,7 @@
     UINT height = abs(bi.bmiHeader.biHeight);
 
     BYTE * buf = (BYTE*)safe_Malloc(bi.bmiHeader.biSizeImage);
-    bi.bmiHeader.biHeight = -height;
+    bi.bmiHeader.biHeight = -(INT)height;
     ::GetDIBits(hdc, hBitmap, 0, height, buf,
             reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS);
 
@@ -305,7 +305,7 @@
     UINT height = abs(bi.bmiHeader.biHeight);
 
     BYTE * buf = (BYTE*)safe_Malloc(bi.bmiHeader.biSizeImage);
-    bi.bmiHeader.biHeight = -height;
+    bi.bmiHeader.biHeight = -(INT)height;
     ::GetDIBits(hdc, hSrcBitmap, 0, height, buf,
             reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS);
 
--- a/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -238,7 +238,7 @@
     // when running on XP. However this can't be referenced at compile time
     // with the older SDK, so there use 'lfMessageFont' plus its size.
     if (!IS_WINVISTA) {
-#if defined(_MSC_VER) && (_MSC_VER >= 1600) {
+#if defined(_MSC_VER) && (_MSC_VER >= 1600)
         ncmetrics.cbSize = offsetof(NONCLIENTMETRICS, iPaddedBorderWidth);
 #else
         ncmetrics.cbSize = offsetof(NONCLIENTMETRICS,lfMessageFont) + sizeof(LOGFONT);
--- a/src/windows/native/sun/windows/awt_DrawingSurface.h	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_DrawingSurface.h	Thu Oct 14 14:07:50 2010 +0400
@@ -159,7 +159,8 @@
     void JNICALL DSUnlockAWT(JNIEnv* env);
 
     _JNI_IMPORT_OR_EXPORT_
-    jobject JNICALL DSGetComponent(JNIEnv* env, void* platformInfo);
+    jobject JNICALL DSGetComponent(
+        JNIEnv* env, void* platformInfo);
 
 #ifdef __cplusplus
 } /* extern "C" */
--- a/src/windows/native/sun/windows/awt_Font.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_Font.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -1189,7 +1189,7 @@
 
 AwtFontCache::Item::Item(const WCHAR* s, HFONT f, AwtFontCache::Item* n )
 {
-    name = wcsdup(s);
+    name = _wcsdup(s);
     font = f;
     next = n;
     refCount = 1;
@@ -1237,7 +1237,7 @@
         free(m_lpszFontName);
         m_lpszFontName = NULL;
     }
-    m_lpszFontName = wcsdup(name);
+    m_lpszFontName = _wcsdup(name);
     DASSERT(m_lpszFontName);
 }
 
--- a/src/windows/native/sun/windows/awt_PrintJob.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_PrintJob.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -1050,7 +1050,7 @@
     return NULL;
   }
 
-  LPTSTR port = wcsdup(info2->pPortName);
+  LPTSTR port = _wcsdup(info2->pPortName);
   ::GlobalFree(info2);
   return port;
 }
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_Toolkit.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -23,16 +23,12 @@
  * questions.
  */
 
+#define _JNI_IMPLEMENTATION_
+
 #include "awt.h"
 #include <signal.h>
 #include <windowsx.h>
 
-//#if defined(_DEBUG) && defined(_MSC_VER) && _MSC_VER >= 1000
-//#include <crtdbg.h>
-//#endif
-
-#define _JNI_IMPLEMENTATION_
-
 #include "awt_DrawingSurface.h"
 #include "awt_AWTEvent.h"
 #include "awt_Component.h"
@@ -2224,21 +2220,21 @@
     WCHAR szVer[128];
 
     DWORD version = ::GetVersion();
-    swprintf(szVer, L"0x%x = %ld", version, version);
+    swprintf(szVer, 128, L"0x%x = %ld", version, version);
     int l = lstrlen(szVer);
 
     if (IS_WIN2000) {
         if (IS_WINXP) {
             if (IS_WINVISTA) {
-                swprintf(szVer + l, L" (Windows Vista)");
+                swprintf(szVer + l, 128, L" (Windows Vista)");
             } else {
-                swprintf(szVer + l, L" (Windows XP)");
+                swprintf(szVer + l, 128, L" (Windows XP)");
             }
         } else {
-            swprintf(szVer + l, L" (Windows 2000)");
+            swprintf(szVer + l, 128, L" (Windows 2000)");
         }
     } else {
-        swprintf(szVer + l, L" (Unknown)");
+        swprintf(szVer + l, 128, L" (Unknown)");
     }
 
     return JNU_NewStringPlatform(env, szVer);
--- a/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -269,7 +269,7 @@
         //if the fontPath includes %SystemRoot%
         LPWSTR systemRoot = _wgetenv(L"SystemRoot");
         if (systemRoot != NULL
-            && swprintf(tmpPath, L"%s%s", systemRoot, fontPath + 12) != -1) {
+            && swprintf(tmpPath, MAX_PATH, L"%s%s", systemRoot, fontPath + 12) != -1) {
             fontPath = tmpPath;
         }
         else {
@@ -279,7 +279,7 @@
         //else to see if it only inludes "EUDC.TTE"
         WCHAR systemRoot[MAX_PATH + 1];
         if (GetWindowsDirectory(systemRoot, MAX_PATH + 1) != 0) {
-            swprintf(tmpPath, L"%s\\FONTS\\EUDC.TTE", systemRoot);
+            swprintf(tmpPath, MAX_PATH, L"%s\\FONTS\\EUDC.TTE", systemRoot);
             fontPath = tmpPath;
         }
         else {
--- a/src/windows/native/sun/windows/awt_Window.cpp	Wed Oct 13 17:03:13 2010 +0400
+++ b/src/windows/native/sun/windows/awt_Window.cpp	Thu Oct 14 14:07:50 2010 +0400
@@ -219,7 +219,7 @@
 
     ::InitializeCriticalSection(&contentBitmapCS);
 
-    m_windowType = Type::NORMAL;
+    m_windowType = NORMAL;
     m_alwaysOnTop = false;
 }
 
@@ -1016,9 +1016,9 @@
     }
 
     if (strcmp(valueNative, "UTILITY") == 0) {
-        m_windowType = Type::UTILITY;
+        m_windowType = UTILITY;
     } else if (strcmp(valueNative, "POPUP") == 0) {
-        m_windowType = Type::POPUP;
+        m_windowType = POPUP;
     }
 
     env->ReleaseStringUTFChars(value, valueNative);
@@ -1029,10 +1029,10 @@
 void AwtWindow::TweakStyle(DWORD & style, DWORD & exStyle)
 {
     switch (GetType()) {
-        case Type::UTILITY:
+        case UTILITY:
             exStyle |= WS_EX_TOOLWINDOW;
             break;
-        case Type::POPUP:
+        case POPUP:
             style &= ~WS_OVERLAPPED;
             style |= WS_POPUP;
             break;