|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-Nov-2021 | - |
| CmdIDList.cpp | H A D | 03-Nov-2021 | 4 KiB | 124 | 70 |
| CmdIDList.h | H A D | 03-Nov-2021 | 2.2 KiB | 65 | 24 |
| ComCtl32Util.cpp | H A D | 03-Nov-2021 | 3.2 KiB | 84 | 49 |
| ComCtl32Util.h | H A D | 03-Nov-2021 | 2.4 KiB | 66 | 27 |
| Devices.cpp | H A D | 03-Nov-2021 | 13.4 KiB | 402 | 190 |
| Devices.h | H A D | 03-Nov-2021 | 2.7 KiB | 78 | 37 |
| DllUtil.cpp | H A D | 03-Nov-2021 | 2.6 KiB | 87 | 51 |
| DllUtil.h | H A D | 03-Nov-2021 | 3.2 KiB | 98 | 49 |
| GDIHashtable.cpp | H A D | 03-Nov-2021 | 4 KiB | 139 | 88 |
| GDIHashtable.h | H A D | 03-Nov-2021 | 7.2 KiB | 206 | 59 |
| Hashtable.cpp | H A D | 03-Nov-2021 | 6.3 KiB | 233 | 180 |
| Hashtable.h | H A D | 03-Nov-2021 | 4.7 KiB | 186 | 63 |
| MouseInfo.cpp | H A D | 03-Nov-2021 | 3.9 KiB | 121 | 66 |
| ObjectList.cpp | H A D | 03-Nov-2021 | 3.6 KiB | 121 | 70 |
| ObjectList.h | H A D | 03-Nov-2021 | 1.8 KiB | 63 | 28 |
| README.JNI | H A D | 03-Nov-2021 | 4.5 KiB | 134 | 109 |
| ShellFolder2.cpp | H A D | 03-Nov-2021 | 52.2 KiB | 1,582 | 1,128 |
| ThemeReader.cpp | H A D | 03-Nov-2021 | 29.2 KiB | 878 | 618 |
| WPrinterJob.cpp | H A D | 03-Nov-2021 | 36.3 KiB | 1,183 | 895 |
| alloc.h | H A D | 03-Nov-2021 | 7.3 KiB | 208 | 110 |
| awt.h | H A D | 03-Nov-2021 | 14.4 KiB | 389 | 269 |
| awt.rc | H A D | 03-Nov-2021 | 2.9 KiB | 84 | 75 |
| awt_AWTEvent.cpp | H A D | 03-Nov-2021 | 3.6 KiB | 123 | 60 |
| awt_AWTEvent.h | H A D | 03-Nov-2021 | 1.7 KiB | 47 | 13 |
| awt_BitmapUtil.cpp | H A D | 03-Nov-2021 | 12.2 KiB | 394 | 273 |
| awt_BitmapUtil.h | H A D | 03-Nov-2021 | 3.1 KiB | 77 | 14 |
| awt_Brush.cpp | H A D | 03-Nov-2021 | 2.7 KiB | 84 | 40 |
| awt_Brush.h | H A D | 03-Nov-2021 | 2.1 KiB | 62 | 16 |
| awt_Button.cpp | H A D | 03-Nov-2021 | 11.1 KiB | 406 | 256 |
| awt_Button.h | H A D | 03-Nov-2021 | 2.3 KiB | 70 | 24 |
| awt_Canvas.cpp | H A D | 03-Nov-2021 | 8.3 KiB | 271 | 173 |
| awt_Canvas.h | H A D | 03-Nov-2021 | 1.9 KiB | 59 | 20 |
| awt_Checkbox.cpp | H A D | 03-Nov-2021 | 18.5 KiB | 686 | 464 |
| awt_Checkbox.h | H A D | 03-Nov-2021 | 2.8 KiB | 90 | 34 |
| awt_Choice.cpp | H A D | 03-Nov-2021 | 25.9 KiB | 900 | 590 |
| awt_Choice.h | H A D | 03-Nov-2021 | 3.3 KiB | 102 | 47 |
| awt_Clipboard.cpp | H A D | 03-Nov-2021 | 15.2 KiB | 502 | 342 |
| awt_Clipboard.h | H A D | 03-Nov-2021 | 2.4 KiB | 67 | 28 |
| awt_Color.cpp | H A D | 03-Nov-2021 | 1.5 KiB | 45 | 7 |
| awt_Component.cpp | H A D | 03-Nov-2021 | 241 KiB | 7,496 | 5,574 |
| awt_Component.h | H A D | 03-Nov-2021 | 32.1 KiB | 937 | 581 |
| awt_Container.cpp | H A D | 03-Nov-2021 | 1.8 KiB | 54 | 13 |
| awt_Container.h | H A D | 03-Nov-2021 | 1.5 KiB | 45 | 9 |
| awt_Cursor.cpp | H A D | 03-Nov-2021 | 17.1 KiB | 598 | 426 |
| awt_Cursor.h | H A D | 03-Nov-2021 | 2.8 KiB | 98 | 49 |
| awt_CustomPaletteDef.h | H A D | 03-Nov-2021 | 10.9 KiB | 275 | 241 |
| awt_DCHolder.cpp | H A D | 03-Nov-2021 | 3.1 KiB | 107 | 69 |
| awt_DCHolder.h | H A D | 03-Nov-2021 | 2.1 KiB | 73 | 40 |
| awt_DataTransferer.cpp | H A D | 03-Nov-2021 | 30.7 KiB | 882 | 638 |
| awt_DataTransferer.h | H A D | 03-Nov-2021 | 11.1 KiB | 180 | 129 |
| awt_Debug.cpp | H A D | 03-Nov-2021 | 7.2 KiB | 232 | 150 |
| awt_Debug.h | H A D | 03-Nov-2021 | 3.4 KiB | 91 | 40 |
| awt_Desktop.cpp | H A D | 03-Nov-2021 | 5.6 KiB | 169 | 100 |
| awt_DesktopProperties.cpp | H A D | 03-Nov-2021 | 39.3 KiB | 1,008 | 740 |
| awt_DesktopProperties.h | H A D | 03-Nov-2021 | 3.2 KiB | 88 | 49 |
| awt_Dialog.cpp | H A D | 03-Nov-2021 | 25.7 KiB | 846 | 577 |
| awt_Dialog.h | H A D | 03-Nov-2021 | 5.1 KiB | 140 | 59 |
| awt_Dimension.cpp | H A D | 03-Nov-2021 | 1.9 KiB | 57 | 16 |
| awt_Dimension.h | H A D | 03-Nov-2021 | 1.5 KiB | 47 | 10 |
| awt_DnDDS.cpp | H A D | 03-Nov-2021 | 46.8 KiB | 1,804 | 1,202 |
| awt_DnDDS.h | H A D | 03-Nov-2021 | 9.7 KiB | 284 | 154 |
| awt_DnDDT.cpp | H A D | 03-Nov-2021 | 46.3 KiB | 1,637 | 1,116 |
| awt_DnDDT.h | H A D | 03-Nov-2021 | 8.7 KiB | 273 | 160 |
| awt_DrawingSurface.cpp | H A D | 03-Nov-2021 | 8 KiB | 319 | 230 |
| awt_DrawingSurface.h | H A D | 03-Nov-2021 | 5.4 KiB | 180 | 90 |
| awt_Event.cpp | H A D | 03-Nov-2021 | 2 KiB | 63 | 21 |
| awt_Event.h | H A D | 03-Nov-2021 | 1.5 KiB | 48 | 11 |
| awt_FileDialog.cpp | H A D | 03-Nov-2021 | 23.6 KiB | 703 | 499 |
| awt_FileDialog.h | H A D | 03-Nov-2021 | 2.5 KiB | 76 | 33 |
| awt_Font.cpp | H A D | 03-Nov-2021 | 55.4 KiB | 1,936 | 1,445 |
| awt_Font.h | H A D | 03-Nov-2021 | 9.4 KiB | 299 | 138 |
| awt_Frame.cpp | H A D | 03-Nov-2021 | 62.4 KiB | 1,980 | 1,414 |
| awt_Frame.h | H A D | 03-Nov-2021 | 7.8 KiB | 233 | 105 |
| awt_GDIObject.cpp | H A D | 03-Nov-2021 | 6.3 KiB | 163 | 69 |
| awt_GDIObject.h | H A D | 03-Nov-2021 | 3.5 KiB | 112 | 50 |
| awt_IconCursor.cpp | H A D | 03-Nov-2021 | 3.2 KiB | 98 | 59 |
| awt_IconCursor.h | H A D | 03-Nov-2021 | 1.5 KiB | 41 | 10 |
| awt_InputEvent.cpp | H A D | 03-Nov-2021 | 1.7 KiB | 49 | 10 |
| awt_InputEvent.h | H A D | 03-Nov-2021 | 1.5 KiB | 45 | 9 |
| awt_InputMethod.cpp | H A D | 03-Nov-2021 | 20.1 KiB | 637 | 348 |
| awt_InputTextInfor.cpp | H A D | 03-Nov-2021 | 15.4 KiB | 458 | 305 |
| awt_InputTextInfor.h | H A D | 03-Nov-2021 | 3.2 KiB | 86 | 34 |
| awt_Insets.cpp | H A D | 03-Nov-2021 | 2.2 KiB | 68 | 25 |
| awt_Insets.h | H A D | 03-Nov-2021 | 1.6 KiB | 48 | 12 |
| awt_KeyEvent.cpp | H A D | 03-Nov-2021 | 2.8 KiB | 78 | 33 |
| awt_KeyEvent.h | H A D | 03-Nov-2021 | 1.7 KiB | 49 | 14 |
| awt_KeyboardFocusManager.cpp | H A D | 03-Nov-2021 | 3.1 KiB | 108 | 47 |
| awt_Label.cpp | H A D | 03-Nov-2021 | 11 KiB | 421 | 260 |
| awt_Label.h | H A D | 03-Nov-2021 | 2.4 KiB | 82 | 25 |
| awt_List.cpp | H A D | 03-Nov-2021 | 27.7 KiB | 1,028 | 700 |
| awt_List.h | H A D | 03-Nov-2021 | 6.5 KiB | 212 | 135 |
| awt_Menu.cpp | H A D | 03-Nov-2021 | 11.6 KiB | 440 | 298 |
| awt_Menu.h | H A D | 03-Nov-2021 | 3.3 KiB | 104 | 50 |
| awt_MenuBar.cpp | H A D | 03-Nov-2021 | 9.1 KiB | 361 | 224 |
| awt_MenuBar.h | H A D | 03-Nov-2021 | 2.6 KiB | 86 | 36 |
| awt_MenuItem.cpp | H A D | 03-Nov-2021 | 32.9 KiB | 1,155 | 787 |
| awt_MenuItem.h | H A D | 03-Nov-2021 | 5.7 KiB | 188 | 105 |
| awt_Mlib.cpp | H A D | 03-Nov-2021 | 3.6 KiB | 109 | 60 |
| awt_Mlib.h | H A D | 03-Nov-2021 | 1.7 KiB | 49 | 16 |
| awt_MouseEvent.cpp | H A D | 03-Nov-2021 | 2.3 KiB | 69 | 26 |
| awt_MouseEvent.h | H A D | 03-Nov-2021 | 1.6 KiB | 48 | 12 |
| awt_Object.cpp | H A D | 03-Nov-2021 | 8.5 KiB | 265 | 167 |
| awt_Object.h | H A D | 03-Nov-2021 | 4.6 KiB | 143 | 68 |
| awt_Palette.cpp | H A D | 03-Nov-2021 | 10.7 KiB | 355 | 236 |
| awt_Palette.h | H A D | 03-Nov-2021 | 4.4 KiB | 105 | 33 |
| awt_Panel.cpp | H A D | 03-Nov-2021 | 1.8 KiB | 56 | 14 |
| awt_Panel.h | H A D | 03-Nov-2021 | 1.5 KiB | 43 | 9 |
| awt_Pen.cpp | H A D | 03-Nov-2021 | 2.7 KiB | 85 | 41 |
| awt_Pen.h | H A D | 03-Nov-2021 | 2 KiB | 62 | 16 |
| awt_PopupMenu.cpp | H A D | 03-Nov-2021 | 9 KiB | 309 | 206 |
| awt_PopupMenu.h | H A D | 03-Nov-2021 | 2.3 KiB | 71 | 27 |
| awt_PrintControl.cpp | H A D | 03-Nov-2021 | 41.5 KiB | 1,149 | 853 |
| awt_PrintControl.h | H A D | 03-Nov-2021 | 5.1 KiB | 136 | 87 |
| awt_PrintDialog.cpp | H A D | 03-Nov-2021 | 10.5 KiB | 329 | 230 |
| awt_PrintDialog.h | H A D | 03-Nov-2021 | 1.8 KiB | 53 | 16 |
| awt_PrintJob.cpp | H A D | 03-Nov-2021 | 143.3 KiB | 4,328 | 2,770 |
| awt_Rectangle.cpp | H A D | 03-Nov-2021 | 1.4 KiB | 39 | 6 |
| awt_Robot.cpp | H A D | 03-Nov-2021 | 11.3 KiB | 348 | 233 |
| awt_ScrollPane.cpp | H A D | 03-Nov-2021 | 24 KiB | 813 | 569 |
| awt_ScrollPane.h | H A D | 03-Nov-2021 | 3.2 KiB | 100 | 41 |
| awt_Scrollbar.cpp | H A D | 03-Nov-2021 | 19.8 KiB | 663 | 413 |
| awt_Scrollbar.h | H A D | 03-Nov-2021 | 3.7 KiB | 116 | 52 |
| awt_Taskbar.cpp | H A D | 03-Nov-2021 | 4.2 KiB | 136 | 73 |
| awt_Taskbar.h | H A D | 03-Nov-2021 | 4.2 KiB | 109 | 66 |
| awt_TextArea.cpp | H A D | 03-Nov-2021 | 16.4 KiB | 542 | 325 |
| awt_TextArea.h | H A D | 03-Nov-2021 | 2.6 KiB | 86 | 34 |
| awt_TextComponent.cpp | H A D | 03-Nov-2021 | 35.8 KiB | 1,234 | 793 |
| awt_TextComponent.h | H A D | 03-Nov-2021 | 6.7 KiB | 201 | 96 |
| awt_TextField.cpp | H A D | 03-Nov-2021 | 9 KiB | 292 | 159 |
| awt_TextField.h | H A D | 03-Nov-2021 | 2 KiB | 65 | 20 |
| awt_Toolkit.cpp | H A D | 03-Nov-2021 | 99.3 KiB | 3,233 | 2,212 |
| awt_Toolkit.h | H A D | 03-Nov-2021 | 24 KiB | 732 | 423 |
| awt_TrayIcon.cpp | H A D | 03-Nov-2021 | 32.6 KiB | 1,093 | 810 |
| awt_TrayIcon.h | H A D | 03-Nov-2021 | 5.2 KiB | 159 | 84 |
| awt_Win32GraphicsConfig.cpp | H A D | 03-Nov-2021 | 4.2 KiB | 130 | 63 |
| awt_Win32GraphicsConfig.h | H A D | 03-Nov-2021 | 1.4 KiB | 38 | 8 |
| awt_Win32GraphicsDevice.cpp | H A D | 03-Nov-2021 | 45.6 KiB | 1,445 | 990 |
| awt_Win32GraphicsDevice.h | H A D | 03-Nov-2021 | 5.6 KiB | 126 | 91 |
| awt_Win32GraphicsEnv.cpp | H A D | 03-Nov-2021 | 10.4 KiB | 347 | 217 |
| awt_Window.cpp | H A D | 03-Nov-2021 | 116.3 KiB | 4,042 | 2,897 |
| awt_Window.h | H A D | 03-Nov-2021 | 15.3 KiB | 430 | 283 |
| awt_new.cpp | H A D | 03-Nov-2021 | 7.1 KiB | 246 | 149 |
| awt_new.h | H A D | 03-Nov-2021 | 1.6 KiB | 48 | 11 |
| awt_ole.cpp | H A D | 03-Nov-2021 | 3.2 KiB | 87 | 54 |
| awt_ole.h | H A D | 03-Nov-2021 | 5.3 KiB | 195 | 136 |
| awtmsg.h | H A D | 03-Nov-2021 | 7.2 KiB | 270 | 175 |
| colordata.h | H A D | 03-Nov-2021 | 1.5 KiB | 42 | 13 |
| img_util_md.h | H A D | 03-Nov-2021 | 3.9 KiB | 116 | 66 |
| initIDs.cpp | H A D | 03-Nov-2021 | 2.3 KiB | 86 | 20 |
| mlib_types_md.h | H A D | 03-Nov-2021 | 1.3 KiB | 33 | 5 |
| stdhdrs.h | H A D | 03-Nov-2021 | 1.8 KiB | 55 | 18 |
README.JNI
1[sl@eng 97/07/24]
2
3All the free-standing functions (those that are not JNI native
4methods) must not leak local references. Local references are
5automatically freed when the native method returns to Java. However,
6the free-standing functions are called from the event loop that never
7returns to Java. If these functions do not clean up the local
8references they create, the Java objects corresponding to the local
9references will never be garbage collected.
10
11This is caused by the fact that JNI does not clean up local refs
12until control returns to Java. However, this problem is somewhat
13unique to AWT code because AWT code has long-running native methods
14that never return.
15
16Local refs may be cleaned up manually *before* control returns to
17Java in one of the following two ways:
18
191. Use EnsureLocalCapacity at the beginning of the function to make
20sure the VM has enough memory to create the number of JNI local refs
21needed in the function. Use DeleteLocalRef to clean up any local ref
22created inside the function that are not returned as the result. For
23example:
24
25 void AwtComponent::MeasureListItem(JNIEnv *env,
26 MEASUREITEMSTRUCT far& measureInfo)
27 {
28 if (env->EnsureLocalCapacity(1) < 0) {
29 return;
30 }
31 jobject dimension = PreferredItemSize(env);
32
33 ... /* Use dimension */
34
35 env->DeleteLocalRef(dimension);
36 }
37
382. Use PushLocalFrame and PopLocalFrame to start a new local reference
39frame. All the local refs created in the new frame will be automatically
40freed when PopLocalFrame is called. For example, the above function can be
41rewritten as follows:
42
43 void AwtComponent::MeasureListItem(JNIEnv *env,
44 MEASUREITEMSTRUCT far& measureInfo)
45 {
46 if (env->PushLocalFrame(1) < 0) {
47 return;
48 }
49 jobject dimension = PreferredItemSize(env);
50
51 ... /* Use dimension */
52
53 env->PopLocalFrame(NULL);
54 }
55
56The second approach is easier to use when there are multiple local refs
57to manage. The first approach is more efficient when the function only
58needs to create a small number (3 or less) of local refs.
59
60Pay special attention to local refs created inside a loop. They must be
61deleted after every iteration, otherwise they accumulate very quickly:
62
63int AwtFont::getFontDescriptorNumber(JNIEnv *env, jobject font,
64 jobject fontDescriptor)
65{
66 ... /* other stuff */
67
68 jarray array = ...
69
70 for (i = 0; i < num; i++){
71 refFontDescriptor = env->GetObjectArrayElement(array, i);
72 if (env->IsSameObject(refFontDescriptor, fontDescriptor)) {
73 env->DeleteLocalRef(refFontDescriptor);
74 env->DeleteLocalRef(array);
75 return i;
76 }
77 env->DeleteLocalRef(refFontDescriptor);
78 }
79 env->DeleteLocalRef(array);
80 return 0; // Not found. Use default.
81}
82
83Note that we must make sure the local refs are cleaned up at every possible
84return branch. To reduce code duplication, many AWT functions use "goto"
85to jump to a common set of cleanup statements.
86
87Even if we use PushLocalFrame, we must still delete the local refs created
88in the loop:
89
90 if (env->PushLocalFrame(2) < 0)
91 return 0;
92 jarray array = ...
93 for (i = 0; i < num; i++){
94 refFontDescriptor = env->GetObjectArrayElement(array, i);
95 if (env->IsSameObject(refFontDescriptor, fontDescriptor)) {
96 env->PopLocalFrame(NULL);
97 return i;
98 }
99 env->DeleteLocalRef(refFontDescriptor);
100 }
101 env->PopLocalFrame(NULL);
102 return 0; // Not found. Use default.
103
104unless we ensure that we have space for all possible local refs we are
105going to create inside the loop (note the different argument passed
106to PushLocalFrame):
107
108// Maximum number of local refs we can create in this code segment is
109// num + 1.
110 if (env->PushLocalFrame(num + 1) < 0)
111 return 0;
112 jarray array = ...
113 for (i = 0; i < num; i++){
114 refFontDescriptor = env->GetObjectArrayElement(array, i);
115 if (env->IsSameObject(refFontDescriptor, fontDescriptor)) {
116 env->PopLocalFrame(NULL);
117 return i;
118 }
119// no longer necessary. env->DeleteLocalRef(refFontDescriptor);
120 }
121 env->PopLocalFrame(NULL);
122 return 0; // Not found. Use default.
123
124THINGS TO DO:
125
126 1. Investigate another possibility of dealing with local refs. Instead
127 of making sure every free-standing function does not leak local refs,
128 we could alternatively create a new local ref frame for each invocation
129 of callback functions. All local refs created during the execution of
130 the callback will then be automatically freed.
131
132 2. Handle exceptions properly. The current code lacks error checking
133 and recovery. This leads to random runtime crashes.
134