java/eclipse port

From: Jonathan Chen <jonc_at_chen.org.nz>
Date: Mon, 30 May 2022 21:21:56 UTC
Hi,

I'm the maintainer for java/eclipse. If you're a user, you've probably 
been wondering why it hasn't been updated for nearly 2 years. 
Unfortunately, I had been stuck on 2 critical issues that prevented any 
updates.

The first was a change in the build-packaging. This has finally been 
resolved, thanks to Patrick Mackinlay; and the port finally generates a 
binary.

However, the 2nd issue is that the JNI interface to SWT is not working. 
 From version 4.17 onwards, Eclipse will crash when it attempts to use 
SWT widgets to display HTML text. This is especially noticeable with the 
"Tip of the Day", or hovering over methods (at which point Eclipse 
attempts to display the Javadoc associated with the method and crashes).

Current thread (0x000000080328a000):  JavaThread "main" 
[_thread_in_native, id=476771, stack(0x00007fffdfefd000,0x00007fffdfffd000)]

Stack: [0x00007fffdfefd000,0x00007fffdfffd000],  sp=0x00007fffdfff9438, 
  free space=1009k
Native frames: (J=compiled Java code, A=aot compiled Java code, 
j=interpreted, Vv=VM code, C=native code)
C  [libc.so.7+0x157f74]  short+0x54
J 2379  org.eclipse.swt.internal.C.strlen(J)I (0 bytes) @ 
0x000000081379320c [0x0000000813793140+0x00000000000000cc]
j 
org.eclipse.swt.internal.Converter.cCharPtrToJavaString(JZ)Ljava/lang/String;+1
j 
org.eclipse.swt.browser.WebKit$WebKitExtension.initializeWebExtensions_callback(JJ)V+178
v  ~StubRoutines::call_stub
V  [libjvm.so+0xa638b5]  AsyncGetCallTrace+0xf0ef5
V  [libjvm.so+0xaba315]  AsyncGetCallTrace+0x147955
V  [libjvm.so+0xabd109]  AsyncGetCallTrace+0x14a749
C  [libswt-gtk-4946r21.so+0x6d910]  char+0x1f0
C  [libswt-gtk-4946r21.so+0x72186]  float+0x16
C  [libgobject-2.0.so.0+0x2c066]  __float128+0x116
C  [libgobject-2.0.so.0+0x41c6d]  __float128+0xb0d
C  [libgobject-2.0.so.0+0x42d69]  __float128+0xae9
C  [libgobject-2.0.so.0+0x431a6]  __float128+0x86
C  [libwebkit2gtk-4.0.so.37+0x1378778]  wchar_t+0x348

I suspect that there's some magic flag that I've missed when building 
the JNI interface to SWT. In the build logs, there is a section with the 
current build flags, ie:

[INFO]      [exec] Cairo found, compiling SWT support for the cairo 
graphics library.
[INFO]      [exec] libjawt.so found, the SWT/AWT integration library 
will be compiled.
[INFO]      [exec] Building SWT/GTK+ for Architectures: freebsd amd64
[INFO]      [exec] Building GTK3 bindings:
[INFO]      [exec] cc -O -Wall -fPIC -DSWT_VERSION=4946r21    -DFREEBSD 
-DGTK -I`pkg-config --variable=prefix gtk+-3.0`/include 
-I/usr/local/openjdk11/include -I/usr/local/openjdk11/include/freebsd 
-DJNI64 -m64 -Werror -c swt.c
[INFO]      [exec] cc -O -Wall -fPIC -DSWT_VERSION=4946r21    -DFREEBSD 
-DGTK -I`pkg-config --variable=prefix gtk+-3.0`/include 
-I/usr/local/openjdk11/include -I/usr/local/openjdk11/include/freebsd 
-DJNI64 -m64 -Werror   -c -o c.o c.c
...

I've played around with possible flags, the most recent being 
"-mstack-alignment=16". Any help/insights from anyone on the list would 
be most appreciated.

Cheers.
-- 
Jonathan Chen <jonc@chen.org.nz>