添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

JNA fails to get resolved in Eclipse for Windows on Arm64 (WoA) #1465

Closed
@chirontt

Description

    Version of JNA and related jars: 5.8.0

    Version and vendor of the java virtual machine: JDK 11 & 17 provided by Microsoft for WoA

    Operating system: Windows 11 on Arm64

    System architecture (CPU type, bitness of the JVM): Arm64, 64-bit JVM

    Complete description of the problem

    I've built an Eclipse SDK package for Windows 11 on Arm64 platform (WoA), but I've encountered a problem when starting it up: the JNA library (called a bundle in OSGi parlance) can't be resolved at runtime by Eclipse's OSGi container in WoA. After opening up the jna-5.8.0.jar file and looking closely at the OSGi entries in its MANIFEST.MF file, especially at the Bundle-NativeCode attribute, I think the attribute is missing the value for the Windows on Arm64 platform, hence failing to get resolved and thus aborting the Eclipse startup sequence.

    Currently in the jna-5.8.0.jar 's manifest the Bundle-NativeCode attribute's value closest to the WoA environment is:

    Bundle-NativeCode: com/sun/jna/win32-aarch64/jnidispatch.dll; processor=aarch64; osname=win,
     ...<other values>...
    

    The above attribute value is closest but not quite matching; the osname used in Eclipse is win32, not win, so this results in the JNA library (bundle) failing to be resolved by the OSGi container at runtime, and thus is considered 'missing' from its classpath.

  1. Steps to reproduce
  2. build a (custom) Eclipse SDK distribution for WoA, using the eclipse-platform repo, to get a zip package of the Eclipse SDK (amongst other SDKs artifacts)
  3. unzip the package to a folder, and start up Eclipse SDK by invoking its eclipse.exe executable
  4. the startup would fail with an error message and a pointer to the log file. The log file is big, so here's just some exceptions at the very top of the log file:
  5. !SESSION 2022-09-19 20:13:53.761 -----------------------------------------------
    eclipse.buildId=4.26.0.I20220919-2250
    java.version=11.0.16.1
    java.vendor=Microsoft
    BootLoader constants: OS=win32, ARCH=aarch64, WS=win32, NL=en_US
    Command-line arguments:  -os win32 -ws win32 -arch aarch64
    !ENTRY com.sun.jna 4 0 2022-09-19 20:13:58.770
    !MESSAGE FrameworkEvent ERROR
    !STACK 0
    org.osgi.framework.BundleException: Could not resolve module: com.sun.jna [7]
      Unresolved requirement: Require-Capability: osgi.native; native.paths.8:List<String>="com/sun/jna/sunos-sparc/libjnidispatch.so"; native.paths.17:List<String>="com/sun/jna/linux-arm/libjnidispatch.so"; native.paths.7:List<String>="com/sun/jna/sunos-x86-64/libjnidispatch.so"; native.paths.16:List<String>="com/sun/jna/linux-x86-64/libjnidispatch.so"; native.paths.19:List<String>="com/sun/jna/linux-armel/libjnidispatch.so"; native.paths.9:List<String>="com/sun/jna/sunos-sparcv9/libjnidispatch.so"; native.paths.18:List<String>="com/sun/jna/linux-arm/libjnidispatch.so"; native.paths.13:List<String>="com/sun/jna/linux-ppc64/libjnidispatch.so"; native.paths.12:List<String>="com/sun/jna/linux-ppc/libjnidispatch.so"; native.paths.34:List<String>="com/sun/jna/darwin-aarch64/libjnidispatch.jnilib"; native.paths.15:List<String>="com/sun/jna/linux-x86/libjnidispatch.so"; native.paths.14:List<String>="com/sun/jna/linux-ppc64le/libjnidispatch.so"; native.paths.31:List<String>="com/sun/jna/darwin-ppc64/libjnidispatch.jnilib"; native.paths.30:List<String>="com/sun/jna/darwin-ppc/libjnidispatch.jnilib"; native.paths.11:List<String>="com/sun/jna/aix-ppc64/libjnidispatch.a"; native.paths.33:List<String>="com/sun/jna/darwin-x86-64/libjnidispatch.jnilib"; native.paths.10:List<String>="com/sun/jna/aix-ppc/libjnidispatch.a"; native.paths.32:List<String>="com/sun/jna/darwin-x86/libjnidispatch.jnilib"; native.paths.28:List<String>="com/sun/jna/openbsd-x86/libjnidispatch.so"; native.paths.27:List<String>="com/sun/jna/freebsd-x86-64/libjnidispatch.so"; native.paths.29:List<String>="com/sun/jna/openbsd-x86-64/libjnidispatch.so"; native.paths.24:List<String>="com/sun/jna/linux-s390x/libjnidispatch.so"; native.paths.23:List<String>="com/sun/jna/linux-mips64el/libjnidispatch.so"; native.paths.26:List<String>="com/sun/jna/freebsd-x86/libjnidispatch.so"; native.paths.25:List<String>="com/sun/jna/linux-loongarch64/libjnidispatch.so"; native.paths.20:List<String>="com/sun/jna/linux-aarch64/libjnidispatch.so"; native.paths.22:List<String>="com/sun/jna/linux-sparcv9/libjnidispatch.so"; native.paths.21:List<String>="com/sun/jna/linux-ia64/libjnidispatch.so"; native.paths.0:List<String>="com/sun/jna/win32-x86/jnidispatch.dll"; native.paths.2:List<String>="com/sun/jna/win32-x86/jnidispatch.dll"; native.paths.1:List<String>="com/sun/jna/win32-x86-64/jnidispatch.dll"; native.paths.4:List<String>="com/sun/jna/win32-aarch64/jnidispatch.dll"; native.paths.3:List<String>="com/sun/jna/win32-x86-64/jnidispatch.dll"; native.paths.6:List<String>="com/sun/jna/sunos-x86/libjnidispatch.so"; native.paths.5:List<String>="com/sun/jna/w32ce-arm/jnidispatch.dll"; filter:="(|(&(osgi.native.osname~=win32)(osgi.native.processor~=x86))(&(osgi.native.osname~=win32)(osgi.native.processor~=x86-64))(&(osgi.native.osname~=win)(osgi.native.processor~=x86))(&(osgi.native.osname~=win)(osgi.native.processor~=x86-64))(&(osgi.native.osname~=win)(osgi.native.processor~=aarch64))(&(osgi.native.osname~=wince)(osgi.native.processor~=arm))(&(osgi.native.osname~=sunos)(osgi.native.processor~=x86))(&(osgi.native.osname~=sunos)(osgi.native.processor~=x86-64))(&(osgi.native.osname~=sunos)(osgi.native.processor~=sparc))(&(osgi.native.osname~=sunos)(osgi.native.processor~=sparcv9))(&(osgi.native.osname~=aix)(osgi.native.processor~=ppc))(&(osgi.native.osname~=aix)(osgi.native.processor~=ppc64))(&(osgi.native.osname~=linux)(osgi.native.processor~=ppc))(&(osgi.native.osname~=linux)(osgi.native.processor~=ppc64))(&(osgi.native.osname~=linux)(osgi.native.processor~=ppc64le))(&(osgi.native.osname~=linux)(osgi.native.processor~=x86))(&(osgi.native.osname~=linux)(osgi.native.processor~=x86-64))(&(osgi.native.osname~=linux)(osgi.native.processor~=arm))(&(osgi.native.osname~=linux)(osgi.native.processor~=arm_le))(&(osgi.native.osname~=linux)(osgi.native.processor~=armel))(&(osgi.native.osname~=linux)(osgi.native.processor~=aarch64))(&(osgi.native.osname~=linux)(osgi.native.processor~=ia64))(&(osgi.native.osname~=linux)(osgi.native.processor~=sparcv9))(&(osgi.native.osname~=linux)(osgi.native.processor~=mips64el))(&(osgi.native.osname~=linux)(osgi.native.processor~=S390x))(&(osgi.native.osname~=linux)(osgi.native.processor~=loongarch64))(&(osgi.native.osname~=freebsd)(osgi.native.processor~=x86))(&(osgi.native.osname~=freebsd)(osgi.native.processor~=x86-64))(&(osgi.native.osname~=openbsd)(osgi.native.processor~=x86))(&(osgi.native.osname~=openbsd)(osgi.native.processor~=x86-64))(&(osgi.native.osname~=macosx)(osgi.native.processor~=ppc))(&(osgi.native.osname~=macosx)(osgi.native.processor~=ppc64))(&(osgi.native.osname~=macosx)(osgi.native.processor~=x86))(&(osgi.native.osname~=macosx)(osgi.native.processor~=x86-64))(&(osgi.native.osname~=macosx)(osgi.native.processor~=aarch64)))"
    	at org.eclipse.osgi.container.Module.start(Module.java:463)
    	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1852)
    	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
    	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1845)
    	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1786)
    	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1750)
    	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1672)
    	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
    

    com.sun.jna is the bundle symbolic name (specified in MANIFEST.MF) of the jna-5.8.0.jar, and this bundle can't be resolved, as indicated in the above log messages.

    If I modify the jna-5.8.0.jar's manifest and add the following value to its Bundle-NativeCode attribute:

    com/sun/jna/win32-aarch64/jnidispatch.dll; processor=aarch64; osname=win32
    

    then the Eclipse startup would work.

    If needed, I can create a PR to add the above value to the build.xml of this repo (at line 491).