Skip to content

Commit c593f8b

Browse files
committedOct 27, 2023
8318091: Remove empty initIDs functions
Reviewed-by: prr, aivanov
1 parent 4f9f195 commit c593f8b

File tree

17 files changed

+16
-361
lines changed

17 files changed

+16
-361
lines changed
 

‎src/java.desktop/macosx/native/libawt_lwawt/awt/InitIDs.m

+1-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -32,11 +32,6 @@
3232
{
3333
}
3434

35-
JNIEXPORT void JNICALL Java_java_awt_Button_initIDs
36-
(JNIEnv *env, jclass cls)
37-
{
38-
}
39-
4035
JNIEXPORT void JNICALL Java_java_awt_Checkbox_initIDs
4136
(JNIEnv *env, jclass cls)
4237
{
@@ -52,11 +47,6 @@
5247
{
5348
}
5449

55-
JNIEXPORT void JNICALL Java_java_awt_Color_initIDs
56-
(JNIEnv *env, jclass cls)
57-
{
58-
}
59-
6050
JNIEXPORT void JNICALL Java_java_awt_Component_initIDs
6151
(JNIEnv *env, jclass cls)
6252
{
@@ -87,11 +77,6 @@
8777
{
8878
}
8979

90-
JNIEXPORT void JNICALL Java_java_awt_FileDialog_initIDs
91-
(JNIEnv *env, jclass cls)
92-
{
93-
}
94-
9580
JNIEXPORT void JNICALL Java_java_awt_Font_initIDs
9681
(JNIEnv *env, jclass cls)
9782
{
@@ -112,11 +97,6 @@
11297
{
11398
}
11499

115-
JNIEXPORT void JNICALL Java_java_awt_KeyboardFocusManager_initIDs
116-
(JNIEnv *env, jclass cls)
117-
{
118-
}
119-
120100
JNIEXPORT void JNICALL Java_java_awt_Label_initIDs
121101
(JNIEnv *env, jclass cls)
122102
{
@@ -142,11 +122,6 @@
142122
{
143123
}
144124

145-
JNIEXPORT void JNICALL Java_java_awt_Rectangle_initIDs
146-
(JNIEnv *env, jclass cls)
147-
{
148-
}
149-
150125
JNIEXPORT void JNICALL Java_java_awt_ScrollPane_initIDs
151126
(JNIEnv *env, jclass cls)
152127
{
@@ -167,11 +142,6 @@
167142
{
168143
}
169144

170-
JNIEXPORT void JNICALL Java_java_awt_TextField_initIDs
171-
(JNIEnv *env, jclass cls)
172-
{
173-
}
174-
175145
JNIEXPORT void JNICALL Java_java_awt_Toolkit_initIDs
176146
(JNIEnv *env, jclass cls)
177147
{

‎src/java.desktop/share/classes/java/awt/Button.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -122,21 +122,6 @@ public class Button extends Component implements Accessible {
122122
@Serial
123123
private static final long serialVersionUID = -8774683716313001058L;
124124

125-
126-
static {
127-
/* ensure that the necessary native libraries are loaded */
128-
Toolkit.loadLibraries();
129-
if (!GraphicsEnvironment.isHeadless()) {
130-
initIDs();
131-
}
132-
}
133-
134-
/**
135-
* Initialize JNI field and method IDs for fields that may be
136-
* accessed from C.
137-
*/
138-
private static native void initIDs();
139-
140125
/**
141126
* Constructs a button with an empty string for its label.
142127
*

‎src/java.desktop/share/classes/java/awt/Color.java

+1-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -260,26 +260,6 @@ public class Color implements Paint, java.io.Serializable {
260260
@Serial
261261
private static final long serialVersionUID = 118526816881161077L;
262262

263-
/**
264-
* Initialize JNI field and method IDs
265-
*/
266-
private static native void initIDs();
267-
268-
static {
269-
/** 4112352 - Calling getDefaultToolkit()
270-
** here can cause this class to be accessed before it is fully
271-
** initialized. DON'T DO IT!!!
272-
**
273-
** Toolkit.getDefaultToolkit();
274-
**/
275-
276-
/* ensure that the necessary native libraries are loaded */
277-
Toolkit.loadLibraries();
278-
if (!GraphicsEnvironment.isHeadless()) {
279-
initIDs();
280-
}
281-
}
282-
283263
/**
284264
* Checks the color integer components supplied for validity.
285265
* Throws an {@link IllegalArgumentException} if the value is out of

‎src/java.desktop/share/classes/java/awt/FileDialog.java

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
3131
import java.io.IOException;
3232
import java.io.ObjectInputStream;
3333
import java.io.Serial;
34+
import java.lang.annotation.Native;
3435

3536
import sun.awt.AWTAccessor;
3637

@@ -55,12 +56,14 @@ public class FileDialog extends Dialog {
5556
* This constant value indicates that the purpose of the file
5657
* dialog window is to locate a file from which to read.
5758
*/
59+
@Native
5860
public static final int LOAD = 0;
5961

6062
/**
6163
* This constant value indicates that the purpose of the file
6264
* dialog window is to locate a file to which to write.
6365
*/
66+
@Native
6467
public static final int SAVE = 1;
6568

6669
/**
@@ -140,15 +143,6 @@ public class FileDialog extends Dialog {
140143
@Serial
141144
private static final long serialVersionUID = 5035145889651310422L;
142145

143-
144-
static {
145-
/* ensure that the necessary native libraries are loaded */
146-
Toolkit.loadLibraries();
147-
if (!GraphicsEnvironment.isHeadless()) {
148-
initIDs();
149-
}
150-
}
151-
152146
static {
153147
AWTAccessor.setFileDialogAccessor(
154148
new AWTAccessor.FileDialogAccessor() {
@@ -169,12 +163,6 @@ public boolean isMultipleMode(FileDialog fileDialog) {
169163
});
170164
}
171165

172-
/**
173-
* Initialize JNI field and method IDs for fields that may be
174-
accessed from C.
175-
*/
176-
private static native void initIDs();
177-
178166
/**
179167
* Creates a file dialog for loading a file. The title of the
180168
* file dialog is initially empty. This is a convenience method for

‎src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -109,11 +109,6 @@ public abstract class KeyboardFocusManager
109109
private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.KeyboardFocusManager");
110110

111111
static {
112-
/* ensure that the necessary native libraries are loaded */
113-
Toolkit.loadLibraries();
114-
if (!GraphicsEnvironment.isHeadless()) {
115-
initIDs();
116-
}
117112
AWTAccessor.setKeyboardFocusManagerAccessor(
118113
new AWTAccessor.KeyboardFocusManagerAccessor() {
119114
public int shouldNativelyFocusHeavyweight(Component heavyweight,
@@ -157,11 +152,6 @@ public Container getCurrentFocusCycleRoot() {
157152

158153
transient KeyboardFocusManagerPeer peer;
159154

160-
/**
161-
* Initialize JNI field and method IDs
162-
*/
163-
private static native void initIDs();
164-
165155
private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.KeyboardFocusManager");
166156

167157
/**

‎src/java.desktop/share/classes/java/awt/Rectangle.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -165,19 +165,6 @@ public class Rectangle extends Rectangle2D
165165
@Serial
166166
private static final long serialVersionUID = -4345857070255674764L;
167167

168-
/**
169-
* Initialize JNI field and method IDs
170-
*/
171-
private static native void initIDs();
172-
173-
static {
174-
/* ensure that the necessary native libraries are loaded */
175-
Toolkit.loadLibraries();
176-
if (!GraphicsEnvironment.isHeadless()) {
177-
initIDs();
178-
}
179-
}
180-
181168
/**
182169
* Constructs a new {@code Rectangle} whose upper-left corner
183170
* is at (0, 0) in the coordinate space, and whose width and

‎src/java.desktop/share/classes/java/awt/TextField.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -137,19 +137,6 @@ public non-sealed class TextField extends TextComponent {
137137
@Serial
138138
private static final long serialVersionUID = -2966288784432217853L;
139139

140-
/**
141-
* Initialize JNI field and method ids
142-
*/
143-
private static native void initIDs();
144-
145-
static {
146-
/* ensure that the necessary native libraries are loaded */
147-
Toolkit.loadLibraries();
148-
if (!GraphicsEnvironment.isHeadless()) {
149-
initIDs();
150-
}
151-
}
152-
153140
/**
154141
* Constructs a new text field.
155142
* @throws HeadlessException if GraphicsEnvironment.isHeadless()

‎src/java.desktop/unix/native/common/awt/X11Color.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
3939
#include <X11/Xutil.h>
4040
#endif /* !HEADLESS */
4141
#include "awt_p.h"
42-
#include "java_awt_Color.h"
4342
#include "java_awt_SystemColor.h"
4443
#include "java_awt_color_ColorSpace.h"
4544
#include "java_awt_Transparency.h"

‎src/java.desktop/unix/native/libawt/awt/initIDs.c

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,10 @@
2323
* questions.
2424
*/
2525

26-
#include "java_awt_Color.h"
2726
#include "java_awt_Dimension.h"
2827
#include "java_awt_MenuBar.h"
2928
#include "java_awt_FontMetrics.h"
3029
#include "java_awt_event_MouseEvent.h"
31-
#include "java_awt_Rectangle.h"
3230
#include "java_awt_ScrollPaneAdjustable.h"
3331
#include "java_awt_Toolkit.h"
3432
#include "java_awt_CheckboxMenuItem.h"
@@ -40,12 +38,6 @@
4038
* which are used in the win32 awt.
4139
*/
4240

43-
JNIEXPORT void JNICALL
44-
Java_java_awt_Color_initIDs
45-
(JNIEnv *env, jclass clazz)
46-
{
47-
}
48-
4941
JNIEXPORT void JNICALL
5042
Java_java_awt_MenuBar_initIDs
5143
(JNIEnv *env, jclass clazz)
@@ -94,12 +86,6 @@ Java_java_awt_Dimension_initIDs
9486
{
9587
}
9688

97-
JNIEXPORT void JNICALL
98-
Java_java_awt_Rectangle_initIDs
99-
(JNIEnv *env, jclass clazz)
100-
{
101-
}
102-
10389
JNIEXPORT void JNICALL
10490
Java_java_awt_event_MouseEvent_initIDs
10591
(JNIEnv *env, jclass clazz)

‎src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c

-35
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ extern Display* awt_init_Display(JNIEnv *env, jobject this);
7878
extern void freeNativeStringArray(char **array, jsize length);
7979
extern char** stringArrayToNative(JNIEnv *env, jobjectArray array, jsize * ret_length);
8080

81-
/* This function gets called from the static initializer for FileDialog.java
82-
to initialize the fieldIDs for fields that may be accessed from C */
83-
84-
JNIEXPORT void JNICALL
85-
Java_java_awt_FileDialog_initIDs
86-
(JNIEnv *env, jclass cls)
87-
{
88-
89-
}
90-
9181
JNIEXPORT void JNICALL
9282
Java_sun_awt_X11_XToolkit_initIDs
9383
(JNIEnv *env, jclass clazz)
@@ -223,14 +213,6 @@ Java_java_awt_Container_initIDs
223213

224214
}
225215

226-
227-
JNIEXPORT void JNICALL
228-
Java_java_awt_Button_initIDs
229-
(JNIEnv *env, jclass cls)
230-
{
231-
232-
}
233-
234216
JNIEXPORT void JNICALL
235217
Java_java_awt_Scrollbar_initIDs
236218
(JNIEnv *env, jclass cls)
@@ -297,12 +279,6 @@ JNIEXPORT void JNICALL Java_java_awt_ScrollPane_initIDs
297279
{
298280
}
299281

300-
JNIEXPORT void JNICALL
301-
Java_java_awt_TextField_initIDs
302-
(JNIEnv *env, jclass cls)
303-
{
304-
}
305-
306282
JNIEXPORT void JNICALL Java_java_awt_Dialog_initIDs (JNIEnv *env, jclass cls)
307283
{
308284
}
@@ -733,17 +709,6 @@ static void wakeUp() {
733709

734710
/* ========================== End poll section ================================= */
735711

736-
/*
737-
* Class: java_awt_KeyboardFocusManager
738-
* Method: initIDs
739-
* Signature: ()V
740-
*/
741-
JNIEXPORT void JNICALL
742-
Java_java_awt_KeyboardFocusManager_initIDs
743-
(JNIEnv *env, jclass cls)
744-
{
745-
}
746-
747712
/*
748713
* Class: sun_awt_X11_XToolkit
749714
* Method: getEnv

‎src/java.desktop/windows/native/libawt/windows/awt_Button.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
2828

2929
#include "awt_Component.h"
3030

31-
#include "java_awt_Button.h"
3231
#include "sun_awt_windows_WButtonPeer.h"
3332

3433

‎src/java.desktop/windows/native/libawt/windows/awt_Color.cpp

-44
This file was deleted.

‎src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,6 @@
5656

5757
#include <java_awt_Toolkit.h>
5858
#include <java_awt_FontMetrics.h>
59-
#include <java_awt_Color.h>
6059
#include <java_awt_Event.h>
6160
#include <java_awt_event_KeyEvent.h>
6261
#include <java_awt_Insets.h>

‎src/java.desktop/windows/native/libawt/windows/awt_KeyboardFocusManager.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
2626
#include "awt.h"
2727
#include "awt_Component.h"
2828
#include "awt_Toolkit.h"
29-
#include <java_awt_KeyboardFocusManager.h>
3029
#include <jni.h>
3130

3231
static jobject getNativeFocusState(JNIEnv *env, void*(*ftn)()) {
@@ -42,17 +41,6 @@ static jobject getNativeFocusState(JNIEnv *env, void*(*ftn)()) {
4241

4342
extern "C" {
4443

45-
/*
46-
* Class: java_awt_KeyboardFocusManager
47-
* Method: initIDs
48-
* Signature: ()V
49-
*/
50-
JNIEXPORT void JNICALL
51-
Java_java_awt_KeyboardFocusManager_initIDs
52-
(JNIEnv *env, jclass cls)
53-
{
54-
}
55-
5644
/*
5745
* Class: sun_awt_windows_WKeyboardFocusManagerPeer
5846
* Method: setNativeFocusOwner

‎src/java.desktop/windows/native/libawt/windows/awt_Rectangle.cpp

-38
This file was deleted.

‎src/java.desktop/windows/native/libawt/windows/awt_TextField.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
2828

2929
#include "awt_TextComponent.h"
3030

31-
#include "java_awt_TextField.h"
3231
#include "sun_awt_windows_WTextFieldPeer.h"
3332

3433
#include <ole2.h>

‎src/java.desktop/windows/native/libawt/windows/initIDs.cpp

-85
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.