我想跑 AWTAccessor.getCursorAccessor().setPData(this, cursor);
用于类的游标相关操作 sun.awt.AWTAccessor
.
我得到了一个错误:
Exception in thread "main" java.lang.IllegalAccessError: class xawtcursor.XImageCursor (in unnamed module @0x3d3fcdb0) cannot access class sun.awt.AWTAccessor (in module java.desktop) because module java.desktop does not export sun.awt to unnamed module @0x3d3fcdb0
at xawtcursor.XImageCursor.createNativeCursor(XImageCursor.java:25)
...
一些测试代码( 1
在这里是无效的,但这只是为了简化测试代码,以便可以复制):
package xawtcursor;
import sun.awt.AWTAccessor;
import sun.awt.X11.XCustomCursor;
import sun.awt.X11.XToolkit;
import java.awt.*;
public class XImageCursor extends XCustomCursor {
public XImageCursor(Image cursor, Point hotSpot, String name) throws IndexOutOfBoundsException {
super(cursor, hotSpot, name);
}
protected void createNativeCursor(Image im, int[] pixels, int width, int height, int xHotSpot, int yHotSpot) {
XToolkit.awtLock();
try {
AWTAccessor.getCursorAccessor().setPData(this, 1);
} finally {
XToolkit.awtUnlock();
}
}
}
我试过了 --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED
修正了一个错误。有什么编译选项可以让我访问这个?
1条答案
按热度按时间whlutmcx1#
结果我只需要添加多个
--add-exports
选项。增加以下工作: