`OS.beginSheetModalForWindow` is declared `void` in Java and `jlong` in the entry

未关闭 适合新手
#3,546 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
java, objective-c
领域
desktop

调研方向

对照 OS.java 中的 native 声明与 os_custom.c 中的 beginSheetModalForWindow 条目,从 DirectoryDialog、FileDialog 和 MessageBox 中的 Java wrapper 调用点入手。判断预期的返回类型,使两侧保持一致,并运行相关的 SWT Cocoa 测试或构建检查,以确认 native binding 仍可使用。

由索引模型根据 Issue 内容生成。

描述

OS.java declares:

public static native void beginSheetModalForWindow(long id, long sel, long window, long handler);

and the entry in os_custom.c declares and returns a jlong:

JNIEXPORT jlong JNICALL OS_NATIVE(beginSheetModalForWindow)
	(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, FunctionPointer arg3)
{
	jlong rc = 0;

	OS_NATIVE_ENTER(env, that, beginSheetModalForWindow_FUNC);

	rc = (jlong)((jlong (*)(jlong, jlong, jlong, void (^)(jlong)))objc_msgSend)(arg0, arg1, arg2, functionToBlock(arg3));

	OS_NATIVE_EXIT(env, that, beginSheetModalForWindow_FUNC);
	return rc;
}

The VM binds these by name and the mangled symbol carries no return type, so nothing on either side checks that they agree: javac sees only the Java declaration, the C compiler only the definition.

I have not observed any misbehaviour from this and would not expect to. On the ABIs SWT targets the callee writes a return register that a void caller ignores, and rc is unobservable from Java in any case, since DirectoryDialog, FileDialog and MessageBox all call the wrapper as a statement. So this is a JNI signature mismatch rather than a wrong value.

It seems worth mentioning because it looks unintentional and it is isolated: comparing every native declaration in the tree against the return type its own entry declares, this is the only pair that disagrees, out of 3110 comparable pairs at one commit I checked and 2957 at another.

The fix is presumably to declare the entry void and drop rc, unless the value is meant to reach Java, in which case the Java declaration is the side to change.

Checked against master at 3e3b24b4. Found as part of a research project.

主要语言
Java
星标
202
派生
206
平均合并
1 天 12 小时
30 天内合并 PR
115

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

eclipse-platform/eclipse.platform.swt 的其他 Issue

查看 eclipse-platform/eclipse.platform.swt 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。