8319985: Delete sun.awt.windows.WToolkit.embedded*() API

Reviewed-by: prr
This commit is contained in:
Sergey Bylokhov 2023-11-17 18:58:19 +00:00
parent 1fce70b666
commit b5a7562bd1
3 changed files with 6 additions and 149 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, 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
@ -195,69 +195,6 @@ public final class WToolkit extends SunToolkit implements Runnable {
}
}
/*
* NOTE: The following embedded*() methods are non-public API intended
* for internal use only. The methods are unsupported and could go
* away in future releases.
*
* New hook functions for using the AWT as an embedded service. These
* functions replace the global C function AwtInit() which was previously
* exported by awt.dll.
*
* When used as an embedded service, the AWT does NOT have its own
* message pump. It instead relies on the parent application to provide
* this functionality. embeddedInit() assumes that the thread on which it
* is called is the message pumping thread. Violating this assumption
* will lead to undefined behavior.
*
* embeddedInit must be called before the WToolkit() constructor.
* embeddedDispose should be called before the application terminates the
* Java VM. It is currently unsafe to reinitialize the toolkit again
* after it has been disposed. Instead, awt.dll must be reloaded and the
* class loader which loaded WToolkit must be finalized before it is
* safe to reuse AWT. Dynamic reusability may be added to the toolkit in
* the future.
*/
/**
* Initializes the Toolkit for use in an embedded environment.
*
* @return true if the initialization succeeded; false if it failed.
* The function will fail if the Toolkit was already initialized.
* @since 1.3
*/
public static native boolean embeddedInit();
/**
* Disposes the Toolkit in an embedded environment. This method should
* not be called on exit unless the Toolkit was constructed with
* embeddedInit.
*
* @return true if the disposal succeeded; false if it failed. The
* function will fail if the calling thread is not the same
* thread which called embeddedInit(), or if the Toolkit was
* already disposed.
* @since 1.3
*/
public static native boolean embeddedDispose();
/**
* To be called after processing the event queue by users of the above
* embeddedInit() function. The reason for this additional call is that
* there are some operations performed during idle time in the AwtToolkit
* event loop which should also be performed during idle time in any
* other native event loop. Failure to do so could result in
* deadlocks.
*
* This method was added at the last minute of the jdk1.4 release
* to work around a specific customer problem. As with the above
* embedded*() class, this method is non-public and should not be
* used by external applications.
*
* See bug #4526587 for more information.
*/
public native void embeddedEventLoopIdleProcessing();
static class ToolkitDisposer implements sun.java2d.DisposerRecord {
@Override
public void dispose() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, 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
@ -294,7 +294,6 @@ jmethodID AwtToolkit::insetsMID;
*/
AwtToolkit::AwtToolkit() {
m_localPump = FALSE;
m_mainThreadId = 0;
m_toolkitHWnd = NULL;
m_inputMethodHWnd = NULL;
@ -604,7 +603,7 @@ Java_sun_awt_windows_WToolkit_startToolkitThread(JNIEnv *env, jclass cls, jobjec
return result ? JNI_TRUE : JNI_FALSE;
}
BOOL AwtToolkit::Initialize(BOOL localPump) {
BOOL AwtToolkit::Initialize() {
AwtToolkit& tk = AwtToolkit::GetInstance();
if (!tk.m_isActive || tk.m_mainThreadId != 0) {
@ -617,11 +616,6 @@ BOOL AwtToolkit::Initialize(BOOL localPump) {
// ComCtl32Util was constructed but not disposed
ComCtl32Util::GetInstance().InitLibraries();
if (!localPump) {
// if preload thread was run, terminate it
preloadThread.Terminate(true);
}
/* Register this toolkit's helper window */
VERIFY(tk.RegisterClass() != NULL);
@ -650,7 +644,6 @@ BOOL AwtToolkit::Initialize(BOOL localPump) {
::ReleaseDC(NULL, hDC);
///////////////////////////////////////////////////////////////////////////
tk.m_localPump = localPump;
tk.m_mainThreadId = ::GetCurrentThreadId();
/*
@ -1507,12 +1500,6 @@ const int AwtToolkit::EXIT_ALL_ENCLOSING_LOOPS = -1;
* for example, we might get a WINDOWPOSCHANGING event, then we
* idle and release the lock here, then eventually we get the
* WINDOWPOSCHANGED event.
*
* This method may be called from WToolkit.embeddedEventLoopIdleProcessing
* if there is a separate event loop that must do the same CriticalSection
* check.
*
* See bug #4526587 for more information.
*/
void VerifyWindowMoveLockReleased()
{
@ -2022,9 +2009,6 @@ JNIEnv* AwtToolkit::m_env;
DWORD AwtToolkit::m_threadId;
void AwtToolkit::SetEnv(JNIEnv *env) {
if (m_env != NULL) { // If already cashed (by means of embeddedInit() call).
return;
}
m_threadId = GetCurrentThreadId();
m_env = env;
}
@ -2494,53 +2478,6 @@ Java_sun_awt_windows_WToolkit_initIDs(JNIEnv *env, jclass cls)
CATCH_BAD_ALLOC;
}
/*
* Class: sun_awt_windows_WToolkit
* Method: embeddedInit
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_sun_awt_windows_WToolkit_embeddedInit(JNIEnv *env, jclass cls)
{
TRY;
AwtToolkit::SetEnv(env);
return AwtToolkit::GetInstance().Initialize(FALSE);
CATCH_BAD_ALLOC_RET(JNI_FALSE);
}
/*
* Class: sun_awt_windows_WToolkit
* Method: embeddedDispose
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_sun_awt_windows_WToolkit_embeddedDispose(JNIEnv *env, jclass cls)
{
TRY;
BOOL retval = AwtToolkit::GetInstance().Dispose();
AwtToolkit::GetInstance().SetPeer(env, NULL);
return retval;
CATCH_BAD_ALLOC_RET(JNI_FALSE);
}
/*
* Class: sun_awt_windows_WToolkit
* Method: embeddedEventLoopIdleProcessing
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_sun_awt_windows_WToolkit_embeddedEventLoopIdleProcessing(JNIEnv *env,
jobject self)
{
VerifyWindowMoveLockReleased();
}
/*
* Class: sun_awt_windows_WToolkit
* Method: init
@ -2557,7 +2494,7 @@ Java_sun_awt_windows_WToolkit_init(JNIEnv *env, jobject self)
// This call will fail if the Toolkit was already initialized.
// In that case, we don't want to start another message pump.
return AwtToolkit::GetInstance().Initialize(TRUE);
return AwtToolkit::GetInstance().Initialize();
CATCH_BAD_ALLOC_RET(FALSE);
}
@ -2572,8 +2509,6 @@ Java_sun_awt_windows_WToolkit_eventLoop(JNIEnv *env, jobject self)
{
TRY;
DASSERT(AwtToolkit::GetInstance().localPump());
AwtToolkit::SetBusy(TRUE);
AwtToolkit::GetInstance().MessageLoop(AwtToolkit::PrimaryIdleFunc,
@ -3231,4 +3166,3 @@ LRESULT AwtToolkit::InvokeInputMethodFunction(UINT msg, WPARAM wParam, LPARAM lP
return 0;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, 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,18 +27,6 @@
* The Toolkit class has two functions: it instantiates the AWT
* ToolkitPeer's native methods, and provides the DLL's core functions.
*
* There are two ways this DLL can be used: either as a dynamically-
* loaded Java native library from the interpreter, or by a Windows-
* specific app. The first manner requires that the Toolkit provide
* all support needed so the app can function as a first-class Windows
* app, while the second assumes that the app will provide that
* functionality. Which mode this DLL functions in is determined by
* which initialization paradigm is used. If the Toolkit is constructed
* normally, then the Toolkit will have its own pump. If it is explicitly
* initialized for an embedded environment (via a static method on
* sun.awt.windows.WToolkit), then it will rely on an external message
* pump.
*
* The most basic functionality needed is a Windows message pump (also
* known as a message loop). When an Java app is started as a console
* app by the interpreter, the Toolkit needs to provide that message
@ -222,7 +210,7 @@ public:
AwtToolkit();
~AwtToolkit();
BOOL Initialize(BOOL localPump);
BOOL Initialize();
BOOL Dispose();
void SetDynamicLayout(BOOL dynamic);
@ -246,7 +234,6 @@ public:
LRESULT InvokeInputMethodFunction(UINT msg, WPARAM wParam=0, LPARAM lParam=0);
INLINE BOOL localPump() { return m_localPump; }
INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag
INLINE HWND GetHWnd() { return m_toolkitHWnd; }
@ -449,7 +436,6 @@ private:
void InitTouchKeyboardExeFilePath();
HWND GetTouchKeyboardWindow();
BOOL m_localPump;
DWORD m_mainThreadId;
HWND m_toolkitHWnd;
HWND m_inputMethodHWnd;