Skip to content

Commit 25b48e3

Browse files
committed
Remove unused (native) code in Win32Natives for Win32RefreshProvider
Unicode support was assumed to be present if the Windows-OS version is greater or equal five, which corresponds to Windows 2000 or later [1]. Because parts of the removed and remaining native code call methods that are only available on Windows XP/Server 2003 or later, for example 'FindFirstChangeNotificationA()' respectively 'FindFirstChangeNotificationW()', it is save to assume Unicode is always supported. All methods that check it or handle an alternative encoding are effectively dead code and can be removed. Furthermore only 64-bit artifacts are provided now and 64-bit CPU are not supported before Windows XP, too. [1] - https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfow
1 parent cd4ccff commit 25b48e3

File tree

4 files changed

+17
-253
lines changed

4 files changed

+17
-253
lines changed

resources/bundles/org.eclipse.core.resources/natives/make.bat

+9-11
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,20 @@
1111
@rem Contributors:
1212
@rem IBM Corporation - initial API and implementation
1313
@rem ***************************************************************************
14+
@echo off
1415
REM build JNI header file
15-
cd ..\bin
16-
"C:\Program Files\Java\jdk1.8.0_65\bin\javah.exe" org.eclipse.core.internal.resources.refresh.win32.Win32Natives
17-
move org_eclipse_core_internal_resources_refresh_win32_Win32Natives.h ..\natives\ref2.h
16+
cd %~dp0\..\src
17+
18+
"%JAVA_HOME%\bin\javac" -h . org\eclipse\core\internal\resources\refresh\win32\Win32Natives.java
19+
del org\eclipse\core\internal\resources\refresh\win32\Win32Natives.class
20+
move org_eclipse_core_internal_resources_refresh_win32_Win32Natives.h ..\natives\ref.h
1821

1922
REM compile and link
23+
if "%MSVC_HOME%"=="" set MSVC_HOME=C:\Program Files\Microsoft Visual Studio\2022\Community
2024
cd ..\natives
21-
set win_include="C:\Program Files\Microsoft Visual Studio 14.0\VC\include"
22-
set jdk_include="C:\Program Files\Java\jdk1.8.0_65\include"
2325

2426
set dll_name=win32refresh.dll
2527

26-
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64_x86
27-
"cl.exe" -I%win_include% -I%jdk_include% -I%jdk_include%\win32 -LD ref.c -Fe%dll_name%
28-
move %dll_name% ..\..\org.eclipse.core.resources.win32.x86\os\win32\x86\%dll_name%
29-
30-
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
31-
"cl.exe" -I%win_include% -I%jdk_include% -I%jdk_include%\win32 -LD ref.c -Fe%dll_name%
28+
call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" amd64
29+
"cl.exe" -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32 -LD ref.c -Fe%dll_name%
3230
move %dll_name% ..\..\org.eclipse.core.resources.win32.x86_64\os\win32\x86_64\%dll_name%

resources/bundles/org.eclipse.core.resources/natives/ref.c

-85
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,6 @@ JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_W
5252
return result;
5353
}
5454

55-
/*
56-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
57-
* Method: FindFirstChangeNotificationA
58-
* Signature: ([BZI)J
59-
*/
60-
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FindFirstChangeNotificationA
61-
(JNIEnv * env, jclass this, jbyteArray lpPathName, jboolean bWatchSubtree, jint dwNotifyFilter) {
62-
jlong result;
63-
jsize numberOfChars;
64-
jbyte *path, *temp;
65-
66-
// create a new byte array to hold the null terminated path
67-
numberOfChars = (*env)->GetArrayLength(env, lpPathName);
68-
path = malloc((numberOfChars + 1) * sizeof(jbyte));
69-
70-
// get the path bytes from the vm, copy them, and release them
71-
temp = (*env)->GetByteArrayElements(env, lpPathName, 0);
72-
memcpy(path, temp, numberOfChars * sizeof(jbyte));
73-
(*env)->ReleaseByteArrayElements(env, lpPathName, temp, 0);
74-
75-
// null terminate the path, make the request, and release the path memory
76-
path[numberOfChars] = '\0';
77-
result = (jlong) FindFirstChangeNotificationA(path, bWatchSubtree, dwNotifyFilter);
78-
free(path);
79-
80-
return result;
81-
}
82-
8355
/*
8456
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
8557
* Method: FindCloseChangeNotification
@@ -122,23 +94,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Wi
12294
return result;
12395
}
12496

125-
/*
126-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
127-
* Method: IsUnicode
128-
* Signature: ()Z
129-
*/
130-
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_IsUnicode
131-
(JNIEnv *env, jclass this) {
132-
OSVERSIONINFO osvi;
133-
memset(&osvi, 0, sizeof(OSVERSIONINFO));
134-
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
135-
if (! GetVersionEx (&osvi) )
136-
return JNI_FALSE;
137-
if (osvi.dwMajorVersion >= 5)
138-
return JNI_TRUE;
139-
return JNI_FALSE;
140-
}
141-
14297
/*
14398
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
14499
* Method: GetLastError
@@ -169,16 +124,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Wi
169124
return FILE_NOTIFY_CHANGE_DIR_NAME;
170125
}
171126

172-
/*
173-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
174-
* Method: FILE_NOTIFY_CHANGE_ATTRIBUTES
175-
* Signature: ()I
176-
*/
177-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1ATTRIBUTES
178-
(JNIEnv *env, jclass this) {
179-
return FILE_NOTIFY_CHANGE_ATTRIBUTES;
180-
}
181-
182127
/*
183128
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
184129
* Method: FILE_NOTIFY_CHANGE_SIZE
@@ -200,16 +145,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Wi
200145
}
201146

202147

203-
/*
204-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
205-
* Method: FILE_NOTIFY_CHANGE_SECURITY
206-
* Signature: ()I
207-
*/
208-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1SECURITY
209-
(JNIEnv *env, jclass this) {
210-
return FILE_NOTIFY_CHANGE_SECURITY;
211-
}
212-
213148
/*
214149
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
215150
* Method: MAXIMUM_WAIT_OBJECTS
@@ -220,26 +155,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Wi
220155
return MAXIMUM_WAIT_OBJECTS;
221156
}
222157

223-
/*
224-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
225-
* Method: MAX_PATH
226-
* Signature: ()I
227-
*/
228-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_MAX_1PATH
229-
(JNIEnv *env, jclass this) {
230-
return MAX_PATH;
231-
}
232-
233-
/*
234-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
235-
* Method: INFINITE
236-
* Signature: ()I
237-
*/
238-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_INFINITE
239-
(JNIEnv *env, jclass this) {
240-
return INFINITE;
241-
}
242-
243158
/*
244159
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
245160
* Method: WAIT_OBJECT_0

resources/bundles/org.eclipse.core.resources/natives/ref.h

+3-66
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2016 IBM Corporation and others.
2+
* Copyright (c) 2004, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,23 +17,8 @@
1717
#ifdef __cplusplus
1818
extern "C" {
1919
#endif
20-
/* Inaccessible static: INVALID_HANDLE_VALUE */
21-
/* Inaccessible static: ERROR_SUCCESS */
22-
/* Inaccessible static: ERROR_INVALID_HANDLE */
23-
/* Inaccessible static: FILE_NOTIFY_ALL */
24-
/* Inaccessible static: MAXIMUM_WAIT_OBJECTS */
25-
/* Inaccessible static: MAX_PATH */
26-
/* Inaccessible static: INFINITE */
27-
/* Inaccessible static: WAIT_TIMEOUT */
28-
/* Inaccessible static: WAIT_OBJECT_0 */
29-
/* Inaccessible static: WAIT_FAILED */
30-
/* Inaccessible static: FILE_NOTIFY_CHANGE_FILE_NAME */
31-
/* Inaccessible static: FILE_NOTIFY_CHANGE_DIR_NAME */
32-
/* Inaccessible static: FILE_NOTIFY_CHANGE_ATTRIBUTES */
33-
/* Inaccessible static: FILE_NOTIFY_CHANGE_SIZE */
34-
/* Inaccessible static: FILE_NOTIFY_CHANGE_LAST_WRITE */
35-
/* Inaccessible static: FILE_NOTIFY_CHANGE_SECURITY */
36-
/* Inaccessible static: UNICODE */
20+
#undef org_eclipse_core_internal_resources_refresh_win32_Win32Natives_ERROR_ACCESS_DENIED
21+
#define org_eclipse_core_internal_resources_refresh_win32_Win32Natives_ERROR_ACCESS_DENIED 5L
3722
/*
3823
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
3924
* Method: FindFirstChangeNotificationW
@@ -42,14 +27,6 @@ extern "C" {
4227
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FindFirstChangeNotificationW
4328
(JNIEnv *, jclass, jstring, jboolean, jint);
4429

45-
/*
46-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
47-
* Method: FindFirstChangeNotificationA
48-
* Signature: ([BZI)J
49-
*/
50-
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FindFirstChangeNotificationA
51-
(JNIEnv *, jclass, jbyteArray, jboolean, jint);
52-
5330
/*
5431
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
5532
* Method: FindCloseChangeNotification
@@ -74,14 +51,6 @@ JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_resources_refresh_win3
7451
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_WaitForMultipleObjects
7552
(JNIEnv *, jclass, jint, jlongArray, jboolean, jint);
7653

77-
/*
78-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
79-
* Method: IsUnicode
80-
* Signature: ()Z
81-
*/
82-
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_IsUnicode
83-
(JNIEnv *, jclass);
84-
8554
/*
8655
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
8756
* Method: GetLastError
@@ -106,14 +75,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Wi
10675
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1DIR_1NAME
10776
(JNIEnv *, jclass);
10877

109-
/*
110-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
111-
* Method: FILE_NOTIFY_CHANGE_ATTRIBUTES
112-
* Signature: ()I
113-
*/
114-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1ATTRIBUTES
115-
(JNIEnv *, jclass);
116-
11778
/*
11879
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
11980
* Method: FILE_NOTIFY_CHANGE_SIZE
@@ -130,14 +91,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Wi
13091
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1FILE_1NAME
13192
(JNIEnv *, jclass);
13293

133-
/*
134-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
135-
* Method: FILE_NOTIFY_CHANGE_SECURITY
136-
* Signature: ()I
137-
*/
138-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1SECURITY
139-
(JNIEnv *, jclass);
140-
14194
/*
14295
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
14396
* Method: MAXIMUM_WAIT_OBJECTS
@@ -146,22 +99,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Wi
14699
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_MAXIMUM_1WAIT_1OBJECTS
147100
(JNIEnv *, jclass);
148101

149-
/*
150-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
151-
* Method: MAX_PATH
152-
* Signature: ()I
153-
*/
154-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_MAX_1PATH
155-
(JNIEnv *, jclass);
156-
157-
/*
158-
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
159-
* Method: INFINITE
160-
* Signature: ()I
161-
*/
162-
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_INFINITE
163-
(JNIEnv *, jclass);
164-
165102
/*
166103
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
167104
* Method: WAIT_OBJECT_0

0 commit comments

Comments
 (0)