SWT FileDialog does not work correctly on Mac OSX with Oracle Java 7

It seems file selection dialogs do not work properly with SWT on Mac OSX 64-bit, with Oracle Java 7:

FileDialog dlg = new FileDialog(shell, SWT.OPEN); dlg.open(); 

One of the main problems is that the file preview (the rightmost panel that appears when you select the file) does not work: the counter does not stop, the CPU usage increases. In random order, another problem is that the contents of the folder look empty.

Everything works fine with the official Apple Java 6 package. I tried several versions of SWT (4.2.1, 4.2.2, 4.3, beta 4.4).

Does anyone know of a workaround? Could this be fixed at the SWT level, or is it a Java 7 issue?

+4
source share
2 answers

I also ran into this problem. This seems to be a direct combination of the following (Java 7, Eclipse 3.7.2, and OSX 10.9)

I found this explanation: https://bugs.eclipse.org/bugs/show_bug.cgi?id=420682 (Error 420682 - in Indigo, the Open File dialog appears only once in OS X Mavericks (10.9))

Hope this helps you, but the main message is as follows:

  • either upgrade the RCP packages to 4.x, or at least 3.8.x
  • Do not use Java 7 (I do not recommend this)
+2
source

The core of the problem seems to be the -XstartOnFirstThread Java flag. One hack is to avoid using this flag and independently implement the behavior associated with it (i.e., launching SWT in the first thread).

Fortunately, a very useful Eclipse contributor - Silenio Quarti - did this, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=389486#c5 . Warning. To integrate into the non-Mac IDE, this source needs to be reorganized, and all links to org.eclipse.swt.internal. ** must be performed using reflection.

Until Oracle and / or Apple fix the SDK version 7, this is the best and only solution I have found so far.

+1
source

Source: https://habr.com/ru/post/1492845/


All Articles