Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`SWT_AWT.initFrame` takes `(long, String)` in Java; the GTK native declares no `className` and the Cocoa native types it `const char *`

Đang mở Phù hợp với người mới
#3,665 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@GreenFuze đang làm issue này rồi.

Từ ngày 12/10/2026.

  • #3719 của @GreenFuze — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, java
Lĩnh vực
desktop

Hướng nghiên cứu

Bắt đầu với bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/library/swt_awt.c và cocoa/library/swt_awt.c, sau đó so sánh các khai báo initFrame của chúng với các khai báo Java và phần triển khai win32 tương ứng. Kiểm tra các vị trí gọi GTK và Cocoa tại SWT_AWT.java:171 và :161. Công việc hoàn tất khi cả hai chữ ký native đều nhận tham số className nhất quán và không có cảnh báo của trình biên dịch.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

All three ports declare the same native:

// bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java:62
static native final Object initFrame (long handle, String className);

(cocoa SWT_AWT.java:68, win32 SWT_AWT.java:57, identical.) The win32 implementation matches
it — (JNIEnv *env, jclass that, jlong handle, jstring className). The other two do not:

// bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/library/swt_awt.c:79
JNIEXPORT jobject JNICALL Java_org_eclipse_swt_awt_SWT_1AWT_initFrame
	(JNIEnv *env, jclass that, jlong handle)
// bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c:22
JNIEXPORT jobject JNICALL Java_org_eclipse_swt_awt_SWT_1AWT_initFrame
	(JNIEnv *env, jclass that, jlong handle, const char *className)

The VM binds the native by its short name, which carries no argument descriptor, so javac,
the C compiler and the linker all accept both.

What it can cause

On GTK the VM passes className and the implementation does not declare it; on Cocoa the VM
passes a jstring — a JNI reference — where the implementation declares a C string. Neither
body reads className, so on the calling conventions SWT ships nothing goes wrong today: this
is a mismatch in the declarations, not an observed failure, and I am not claiming a crash. It is
worth closing because nothing in the toolchain would catch it if a body ever started using the
parameter — on Cocoa, reading it as const char * would read the reference as character data.

Called at gtk/.../SWT_AWT.java:171 and cocoa/.../SWT_AWT.java:161.

Fix

Declare jstring className in both, as the win32 port does, with (void)className; to keep the
unreferenced-parameter warning quiet. I am happy to open the PR.

Ngôn ngữ chính
Java
Star
202
Fork
206
Merge trung bình
16 giờ 56 phút
Pull request đã merge (30 ngày)
110

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của eclipse-platform/eclipse.platform.swt

Tất cả issue của eclipse-platform/eclipse.platform.swt

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.