Merge
authorpsadhukhan
Thu, 29 Aug 2019 16:11:22 +0530 (2019-08-29)
changeset 58317 ddd26bd764e8
parent 58316 718496767a7d (diff)
parent 57933 c16208de74da (current diff)
child 58318 f39420849ae9
Merge
src/hotspot/os_cpu/linux_aarch64/gc/z/zBackingFile_linux_aarch64.cpp
src/hotspot/os_cpu/linux_aarch64/gc/z/zBackingFile_linux_aarch64.hpp
src/hotspot/os_cpu/linux_aarch64/gc/z/zBackingPath_linux_aarch64.cpp
src/hotspot/os_cpu/linux_aarch64/gc/z/zBackingPath_linux_aarch64.hpp
src/hotspot/os_cpu/linux_aarch64/gc/z/zPhysicalMemoryBacking_linux_aarch64.cpp
src/hotspot/os_cpu/linux_aarch64/gc/z/zPhysicalMemoryBacking_linux_aarch64.hpp
src/hotspot/os_cpu/linux_x86/gc/z/zBackingFile_linux_x86.cpp
src/hotspot/os_cpu/linux_x86/gc/z/zBackingFile_linux_x86.hpp
src/hotspot/os_cpu/linux_x86/gc/z/zBackingPath_linux_x86.cpp
src/hotspot/os_cpu/linux_x86/gc/z/zBackingPath_linux_x86.hpp
src/hotspot/os_cpu/linux_x86/gc/z/zPhysicalMemoryBacking_linux_x86.cpp
src/hotspot/os_cpu/linux_x86/gc/z/zPhysicalMemoryBacking_linux_x86.hpp
src/hotspot/share/classfile/sharedPathsMiscInfo.cpp
src/hotspot/share/classfile/sharedPathsMiscInfo.hpp
test/jdk/ProblemList.txt
test/jdk/javax/xml/jaxp/testng/validation/jdk8037819/BasicTest1.java
--- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java	Thu Aug 29 16:11:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, 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
@@ -48,8 +48,9 @@
 
     native void validate(int xoff, int yoff, int width, int height, boolean isOpaque);
 
-    private native void initOps(long pConfigInfo, long pPeerData, long layerPtr,
-                                int xoff, int yoff, boolean isOpaque);
+    private native void initOps(OGLGraphicsConfig gc, long pConfigInfo,
+                                long pPeerData, long layerPtr, int xoff,
+                                int yoff, boolean isOpaque);
 
     protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
                              int width, int height) {
@@ -74,7 +75,7 @@
             pPeerData = pView.getAWTView();
             isOpaque = pView.isOpaque();
         }
-        initOps(pConfigInfo, pPeerData, 0, 0, 0, isOpaque);
+        initOps(gc, pConfigInfo, pPeerData, 0, 0, 0, isOpaque);
     }
 
     protected CGLSurfaceData(CGLLayer layer, CGLGraphicsConfig gc,
@@ -90,7 +91,7 @@
             layerPtr = layer.getPointer();
             isOpaque = layer.isOpaque();
         }
-        initOps(pConfigInfo, 0, layerPtr, 0, 0, isOpaque);
+        initOps(gc, pConfigInfo, 0, layerPtr, 0, 0, isOpaque);
     }
 
     @Override //SurfaceData
--- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m	Thu Aug 29 16:11:22 2019 +0530
@@ -131,31 +131,6 @@
 }
 
 /**
- * Returns a pointer (as a jlong) to the native CGLGraphicsConfigInfo
- * associated with the given OGLSDOps.  This method can be called from
- * shared code to retrieve the native GraphicsConfig data in a platform-
- * independent manner.
- */
-jlong
-OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
-{
-    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_GetNativeConfigInfo");
-
-    if (oglsdo == NULL) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: ops are null");
-        return 0L;
-    }
-
-    CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
-    if (cglsdo == NULL) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: cgl ops are null");
-        return 0L;
-    }
-
-    return ptr_to_jlong(cglsdo->configInfo);
-}
-
-/**
  * Makes the given GraphicsConfig's context current to its associated
  * "scratch" surface.  If there is a problem making the context current,
  * this method will return NULL; otherwise, returns a pointer to the
@@ -359,7 +334,7 @@
 
 JNIEXPORT void JNICALL
 Java_sun_java2d_opengl_CGLSurfaceData_initOps
-    (JNIEnv *env, jobject cglsd,
+    (JNIEnv *env, jobject cglsd, jobject gc,
      jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
      jint xoff, jint yoff, jboolean isOpaque)
 {
@@ -367,8 +342,22 @@
     J2dTraceLn1(J2D_TRACE_INFO, "  pPeerData=%p", jlong_to_ptr(pPeerData));
     J2dTraceLn2(J2D_TRACE_INFO, "  xoff=%d, yoff=%d", (int)xoff, (int)yoff);
 
+    gc = (*env)->NewGlobalRef(env, gc);
+    if (gc == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+        return;
+    }
+
     OGLSDOps *oglsdo = (OGLSDOps *)
         SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));
+    if (oglsdo == NULL) {
+        (*env)->DeleteGlobalRef(env, gc);
+        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+        return;
+    }
+    // later the graphicsConfig will be used for deallocation of oglsdo
+    oglsdo->graphicsConfig = gc;
+
     CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
     if (cglsdo == NULL) {
         JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
--- a/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java	Thu Aug 29 16:11:22 2019 +0530
@@ -27,6 +27,7 @@
 
 import java.awt.AlphaComposite;
 import java.awt.Composite;
+import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsEnvironment;
 import java.awt.Rectangle;
 import java.awt.Transparency;
@@ -578,16 +579,16 @@
      * (referenced by the pData parameter).  This method is invoked from
      * the native Dispose() method from the Disposer thread when the
      * Java-level OGLSurfaceData object is about to go away.  Note that we
-     * also pass a reference to the native GLX/WGLGraphicsConfigInfo
-     * (pConfigInfo) for the purposes of making a context current.
+     * also pass a reference to the OGLGraphicsConfig
+     * for the purposes of making a context current.
      */
-    static void dispose(long pData, long pConfigInfo) {
+    static void dispose(long pData, OGLGraphicsConfig gc) {
         OGLRenderQueue rq = OGLRenderQueue.getInstance();
         rq.lock();
         try {
             // make sure we have a current context before
             // disposing the native resources (e.g. texture object)
-            OGLContext.setScratchSurface(pConfigInfo);
+            OGLContext.setScratchSurface(gc);
 
             RenderBuffer buf = rq.getBuffer();
             rq.ensureCapacityAndAlignment(12, 4);
--- a/src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.c	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.c	Thu Aug 29 16:11:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -37,7 +37,6 @@
  * The following methods are implemented in the windowing system (i.e. GLX
  * and WGL) source files.
  */
-extern jlong OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo);
 extern jboolean OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo);
 extern void OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo);
 
@@ -593,11 +592,14 @@
 OGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops)
 {
     OGLSDOps *oglsdo = (OGLSDOps *)ops;
-    jlong pConfigInfo = OGLSD_GetNativeConfigInfo(oglsdo);
+    jobject graphicsConfig = oglsdo->graphicsConfig;
 
     JNU_CallStaticMethodByName(env, NULL, "sun/java2d/opengl/OGLSurfaceData",
-                               "dispose", "(JJ)V",
-                               ptr_to_jlong(ops), pConfigInfo);
+                               "dispose",
+                               "(JLsun/java2d/opengl/OGLGraphicsConfig;)V",
+                               ptr_to_jlong(ops), graphicsConfig);
+    (*env)->DeleteGlobalRef(env, graphicsConfig);
+    oglsdo->graphicsConfig = NULL;
 }
 
 /**
--- a/src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.h	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.h	Thu Aug 29 16:11:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -85,6 +85,9 @@
  * Pointer to native-specific (GLX, WGL, etc.) SurfaceData info, such as the
  * native Drawable handle and GraphicsConfig data.
  *
+ *     jobject graphicsConfig;;
+ * Strong reference to the OGLGraphicsConfig used by this OGLSurfaceData.
+ *
  *     jint drawableType;
  * The surface type; can be any one of the surface type constants defined
  * below (OGLSD_WINDOW, OGLSD_TEXTURE, etc).
@@ -162,6 +165,7 @@
 struct _OGLSDOps {
     SurfaceDataOps               sdOps;
     void                         *privOps;
+    jobject                      graphicsConfig;
     jint                         drawableType;
     GLenum                       activeBuffer;
     jboolean                     isOpaque;
--- a/src/java.desktop/unix/classes/sun/java2d/opengl/GLXSurfaceData.java	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/unix/classes/sun/java2d/opengl/GLXSurfaceData.java	Thu Aug 29 16:11:22 2019 +0530
@@ -40,7 +40,8 @@
     protected X11ComponentPeer peer;
     private GLXGraphicsConfig graphicsConfig;
 
-    private native void initOps(X11ComponentPeer peer, long aData);
+    private native void initOps(OGLGraphicsConfig gc, X11ComponentPeer peer,
+                                long aData);
 
     protected GLXSurfaceData(X11ComponentPeer peer, GLXGraphicsConfig gc,
                              ColorModel cm, int type)
@@ -48,7 +49,7 @@
         super(gc, cm, type);
         this.peer = peer;
         this.graphicsConfig = gc;
-        initOps(peer, graphicsConfig.getAData());
+        initOps(gc, peer, graphicsConfig.getAData());
     }
 
     public GraphicsConfiguration getDeviceConfiguration() {
--- a/src/java.desktop/unix/native/common/java2d/opengl/GLXSurfaceData.c	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/unix/native/common/java2d/opengl/GLXSurfaceData.c	Thu Aug 29 16:11:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -54,23 +54,32 @@
 
 JNIEXPORT void JNICALL
 Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
+                                              jobject gc,
                                               jobject peer, jlong aData)
 {
 #ifndef HEADLESS
-    GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
-
-    if (glxsdo == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
+    gc = (*env)->NewGlobalRef(env, gc);
+    if (gc == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
         return;
     }
 
     OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
                                                        sizeof(OGLSDOps));
     if (oglsdo == NULL) {
-        free(glxsdo);
+        (*env)->DeleteGlobalRef(env, gc);
         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
         return;
     }
+    // later the graphicsConfig will be used for deallocation of oglsdo
+    oglsdo->graphicsConfig = gc;
+
+    GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
+
+    if (glxsdo == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
+        return;
+    }
 
     J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");
 
@@ -153,39 +162,6 @@
 }
 
 /**
- * Returns a pointer (as a jlong) to the native GLXGraphicsConfigInfo
- * associated with the given OGLSDOps.  This method can be called from
- * shared code to retrieve the native GraphicsConfig data in a platform-
- * independent manner.
- */
-jlong
-OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
-{
-    GLXSDOps *glxsdo;
-
-    if (oglsdo == NULL) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSD_GetNativeConfigInfo: ops are null");
-        return 0L;
-    }
-
-    glxsdo = (GLXSDOps *)oglsdo->privOps;
-    if (glxsdo == NULL) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSD_GetNativeConfigInfo: glx ops are null");
-        return 0L;
-    }
-
-    if (glxsdo->configData == NULL) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSD_GetNativeConfigInfo: config data is null");
-        return 0L;
-    }
-
-    return ptr_to_jlong(glxsdo->configData->glxInfo);
-}
-
-/**
  * Makes the given GraphicsConfig's context current to its associated
  * "scratch" surface.  If there is a problem making the context current,
  * this method will return NULL; otherwise, returns a pointer to the
--- a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java	Thu Aug 29 16:11:22 2019 +0530
@@ -46,8 +46,8 @@
     protected double scaleX = 1;
     protected double scaleY = 1;
 
-    private native void initOps(long pConfigInfo, WComponentPeer peer,
-                                long hwnd);
+    private native void initOps(OGLGraphicsConfig gc, long pConfigInfo,
+                                WComponentPeer peer, long hwnd);
 
     protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
                              ColorModel cm, int type)
@@ -62,7 +62,7 @@
         long pConfigInfo = gc.getNativeConfigInfo();
         long hwnd = peer != null ? peer.getHWnd() : 0L;
 
-        initOps(pConfigInfo, peer, hwnd);
+        initOps(gc, pConfigInfo, peer, hwnd);
     }
 
     @Override
--- a/src/java.desktop/windows/native/common/awt/systemscale/systemScale.cpp	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/windows/native/common/awt/systemscale/systemScale.cpp	Thu Aug 29 16:11:22 2019 +0530
@@ -24,7 +24,6 @@
  */
 #include "systemScale.h"
 #include <d2d1.h>
-#pragma comment(lib, "d2d1")
 #include <jdk_util.h>
 #ifndef MDT_EFFECTIVE_DPI
 #define MDT_EFFECTIVE_DPI 0
@@ -53,6 +52,9 @@
         return;
     }
 
+    typedef HRESULT(WINAPI D2D1CreateFactoryFunc)
+                   (D2D1_FACTORY_TYPE, REFIID,
+                    CONST D2D1_FACTORY_OPTIONS*, ID2D1Factory**);
     typedef HRESULT(WINAPI GetDpiForMonitorFunc)(HMONITOR, int, UINT*, UINT*);
     static HMODULE hLibSHCoreDll = NULL;
     static GetDpiForMonitorFunc *lpGetDpiForMonitor = NULL;
@@ -73,12 +75,27 @@
             *dpiY = static_cast<float>(y);
         }
     } else {
-        ID2D1Factory* m_pDirect2dFactory;
-        HRESULT res = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
-                                        &m_pDirect2dFactory);
-        if (res == S_OK) {
-            m_pDirect2dFactory->GetDesktopDpi(dpiX, dpiY);
-            m_pDirect2dFactory->Release();
+        static HMODULE d2dDll = NULL;
+        static BOOL loadAttempted = FALSE;
+        static D2D1CreateFactoryFunc *lpD2D1CreateFactory = NULL;
+        if (!loadAttempted && d2dDll == NULL) {
+            loadAttempted = TRUE;
+            d2dDll = JDK_LoadSystemLibrary("d2d1.dll");
+        }
+        if (d2dDll != NULL && lpD2D1CreateFactory == NULL) {
+            lpD2D1CreateFactory = (D2D1CreateFactoryFunc*)GetProcAddress(
+                    d2dDll, "D2D1CreateFactory");
+        }
+        if (lpD2D1CreateFactory != NULL) {
+            ID2D1Factory* m_pDirect2dFactory;
+            HRESULT res = lpD2D1CreateFactory
+                          (D2D1_FACTORY_TYPE_SINGLE_THREADED,
+                           __uuidof(ID2D1Factory), NULL,
+                           &m_pDirect2dFactory);
+            if (res == S_OK) {
+                m_pDirect2dFactory->GetDesktopDpi(dpiX, dpiY);
+                m_pDirect2dFactory->Release();
+            }
         }
     }
     return;
--- a/src/java.desktop/windows/native/libawt/java2d/opengl/WGLSurfaceData.c	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/windows/native/libawt/java2d/opengl/WGLSurfaceData.c	Thu Aug 29 16:11:22 2019 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, 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
@@ -58,11 +58,25 @@
 
 JNIEXPORT void JNICALL
 Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd,
-                                              jlong pConfigInfo,
+                                              jobject gc, jlong pConfigInfo,
                                               jobject peer, jlong hwnd)
 {
+    gc = (*env)->NewGlobalRef(env, gc);
+    if (gc == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+        return;
+    }
+
     OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, wglsd,
                                                        sizeof(OGLSDOps));
+    if (oglsdo == NULL) {
+        (*env)->DeleteGlobalRef(env, gc);
+        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+        return;
+    }
+    // later the graphicsConfig will be used for deallocation of oglsdo
+    oglsdo->graphicsConfig = gc;
+
     WGLSDOps *wglsdo = (WGLSDOps *)malloc(sizeof(WGLSDOps));
 
     J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps");
@@ -145,33 +159,6 @@
 }
 
 /**
- * Returns a pointer (as a jlong) to the native WGLGraphicsConfigInfo
- * associated with the given OGLSDOps.  This method can be called from
- * shared code to retrieve the native GraphicsConfig data in a platform-
- * independent manner.
- */
-jlong
-OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
-{
-    WGLSDOps *wglsdo;
-
-    if (oglsdo == NULL) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSD_GetNativeConfigInfo: ops are null");
-        return 0L;
-    }
-
-    wglsdo = (WGLSDOps *)oglsdo->privOps;
-    if (wglsdo == NULL) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSD_GetNativeConfigInfo: wgl ops are null");
-        return 0L;
-    }
-
-    return ptr_to_jlong(wglsdo->configInfo);
-}
-
-/**
  * Makes the given GraphicsConfig's context current to its associated
  * "scratch" surface.  If there is a problem making the context current,
  * this method will return NULL; otherwise, returns a pointer to the
--- a/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp	Thu Aug 29 15:09:48 2019 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp	Thu Aug 29 16:11:22 2019 +0530
@@ -49,8 +49,6 @@
 #include "dither.h"
 #include "img_util_md.h"
 #include "Devices.h"
-#include <d2d1.h>
-#pragma comment(lib, "d2d1")
 #include "systemScale.h"
 
 uns_ordered_dither_array img_oda_alpha;