Skip to content
Permalink
Browse files
8263142: Delete unused entry points in libawt/libawt_xawt/libawt_head…
…less

Reviewed-by: kizune, aivanov
  • Loading branch information
mrserb committed Mar 9, 2021
1 parent b7f0b3f commit 86fac952ab6228455023a083aa50c03673e71642
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 220 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@@ -43,13 +43,6 @@
#define VERBOSE_AWT_DEBUG
#endif

#ifdef STATIC_BUILD
extern void Java_sun_xawt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
jobject frame, jstring jcommand);

extern void Java_sun_xawt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jarray);
#endif

static void *awtHandle = NULL;

typedef jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
@@ -193,75 +186,3 @@ DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
{
return AWT_OnLoad(vm, reserved);
}

/*
* This entry point must remain in libawt.so as part of a contract
* with the CDE variant of Java Media Framework. (sdtjmplay)
* Reflect this call over to the correct libawt_<toolkit>.so.
*/
JNIEXPORT void JNICALL
Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
jobject frame, jstring jcommand)
{
/* type of the old backdoor function */
typedef void JNICALL
XsessionWMcommand_type(JNIEnv *env, jobject this,
jobject frame, jstring jcommand);

static XsessionWMcommand_type *XsessionWMcommand = NULL;
#ifndef STATIC_BUILD
if (XsessionWMcommand == NULL && awtHandle == NULL) {
return;
}

XsessionWMcommand = (XsessionWMcommand_type *)
dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand");
#else
XsessionWMcommand = (XsessionWMcommand_type *)Java_sun_xawt_motif_XsessionWMcommand;
#endif
if (XsessionWMcommand == NULL)
return;

(*XsessionWMcommand)(env, this, frame, jcommand);
}


/*
* This entry point must remain in libawt.so as part of a contract
* with the CDE variant of Java Media Framework. (sdtjmplay)
* Reflect this call over to the correct libawt_<toolkit>.so.
*/
JNIEXPORT void JNICALL
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
{
typedef void JNICALL
XsessionWMcommand_New_type(JNIEnv *env, jobjectArray jargv);

static XsessionWMcommand_New_type *XsessionWMcommand = NULL;
#ifndef STATIC_BUILD
if (XsessionWMcommand == NULL && awtHandle == NULL) {
return;
}

XsessionWMcommand = (XsessionWMcommand_New_type *)
dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand_New");
#else
XsessionWMcommand = (XsessionWMcommand_New_type *)Java_sun_xawt_motif_XsessionWMcommand_New;
#endif

if (XsessionWMcommand == NULL)
return;

(*XsessionWMcommand)(env, jargv);
}

#ifdef STATIC_BUILD
__attribute__((weak)) void Java_sun_xawt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jarray)
{
}

__attribute__((weak)) void Java_sun_xawt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
jobject frame, jstring jcommand)
{
}
#endif
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, 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,11 +37,4 @@ DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_VERSION_1_2;
}

#ifndef STATIC_BUILD
// The same function exists in libawt.a::awt_LoadLibrary.c
JNIEXPORT jboolean JNICALL AWTIsHeadless() {
return JNI_TRUE;
}
#endif

#endif
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, 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
@@ -303,13 +303,6 @@ Java_java_awt_TextField_initIDs
{
}

#ifndef STATIC_BUILD
// The same function exists in libawt.a::awt_LoadLibrary.c
JNIEXPORT jboolean JNICALL AWTIsHeadless() {
return JNI_FALSE;
}
#endif

JNIEXPORT void JNICALL Java_java_awt_Dialog_initIDs (JNIEnv *env, jclass cls)
{
}
@@ -800,130 +793,6 @@ Window get_xawt_root_shell(JNIEnv *env) {
return xawt_root_shell;
}

/*
* Old, compatibility, backdoor for DT. This is a different
* implementation. It keeps the signature, but acts on
* awt_root_shell, not the frame passed as an argument. Note, that
* the code that uses the old backdoor doesn't work correctly with
* gnome session proxy that checks for WM_COMMAND when the window is
* firts mapped, because DT code calls this old backdoor *after* the
* frame is shown or it would get NPE with old AWT (previous
* implementation of this backdoor) otherwise. Old style session
* managers (e.g. CDE) that check WM_COMMAND only during session
* checkpoint should work fine, though.
*
* NB: The function name looks deceptively like a JNI native method
* name. It's not! It's just a plain function.
*/

JNIEXPORT void JNICALL
#ifdef STATIC_BUILD
Java_sun_xawt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
jobject frame, jstring jcommand)
#else
Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
jobject frame, jstring jcommand)
#endif
{
const char *command;
XTextProperty text_prop;
char *c[1];
int32_t status;
Window xawt_root_window;

AWT_LOCK();
xawt_root_window = get_xawt_root_shell(env);

if ( xawt_root_window == None ) {
AWT_UNLOCK();
JNU_ThrowNullPointerException(env, "AWT root shell is unrealized");
return;
}

command = (char *) JNU_GetStringPlatformChars(env, jcommand, NULL);
if (command != NULL) {
c[0] = (char *)command;
status = XmbTextListToTextProperty(awt_display, c, 1,
XStdICCTextStyle, &text_prop);

if (status == Success || status > 0) {
XSetTextProperty(awt_display, xawt_root_window,
&text_prop, XA_WM_COMMAND);
if (text_prop.value != NULL)
XFree(text_prop.value);
}
JNU_ReleaseStringPlatformChars(env, jcommand, command);
}
AWT_UNLOCK();
}


/*
* New DT backdoor to set WM_COMMAND. New code should use this
* backdoor and call it *before* the first frame is shown so that
* gnome session proxy can correctly handle it.
*
* NB: The function name looks deceptively like a JNI native method
* name. It's not! It's just a plain function.
*/
JNIEXPORT void JNICALL
#ifdef STATIC_BUILD
Java_sun_xawt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jarray)
#else
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jarray)
#endif
{
jsize length;
char ** array;
XTextProperty text_prop;
int status;
Window xawt_root_window;

AWT_LOCK();
xawt_root_window = get_xawt_root_shell(env);

if (xawt_root_window == None) {
AWT_UNLOCK();
JNU_ThrowNullPointerException(env, "AWT root shell is unrealized");
return;
}

array = stringArrayToNative(env, jarray, &length);

if (array != NULL) {
status = XmbTextListToTextProperty(awt_display, array, length,
XStdICCTextStyle, &text_prop);
if (status < 0) {
switch (status) {
case XNoMemory:
JNU_ThrowOutOfMemoryError(env,
"XmbTextListToTextProperty: XNoMemory");
break;
case XLocaleNotSupported:
JNU_ThrowInternalError(env,
"XmbTextListToTextProperty: XLocaleNotSupported");
break;
case XConverterNotFound:
JNU_ThrowNullPointerException(env,
"XmbTextListToTextProperty: XConverterNotFound");
break;
default:
JNU_ThrowInternalError(env,
"XmbTextListToTextProperty: unknown error");
}
} else {
XSetTextProperty(awt_display, xawt_root_window,
&text_prop, XA_WM_COMMAND);
}

if (text_prop.value != NULL)
XFree(text_prop.value);

freeNativeStringArray(array, length);
}
AWT_UNLOCK();
}

/*
* Class: java_awt_TrayIcon
* Method: initIDs

0 comments on commit 86fac95

Please sign in to comment.