Community
Participate
Working Groups
Reproducible with online Examples Demo: http://http://rap.eclipsesource.com Go to "File Upload", click on "Add Single File" or "Add Multiple Files" and in the dialog click on "Cancel". java.lang.IllegalAccessError: tried to access field org.eclipse.swt.widgets.Dialog.shell from class org.eclipse.swt.widgets.FileDialog$9 org.eclipse.swt.widgets.FileDialog$9.widgetSelected(FileDialog.java:605) org.eclipse.swt.events.SelectionEvent.dispatchToObserver(SelectionEvent.java:196) org.eclipse.rwt.internal.events.Event.processEvent(Event.java:44) org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.java:161) org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.java:201) org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1139) org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1129) org.eclipse.rap.examples.internal.MainUi.createUI(MainUi.java:56) org.eclipse.rap.examples.internal.Application.createUI(Application.java:19) org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:81) org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:205) org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:88) java.lang.Thread.run(Thread.java:619) org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:101)
With the fix for bug 351585 a protected field "shell" in introduced in org.eclipse.swt.widgets.Dialog. There is a field "shell" in the FileDialog too.
For some reason, direct access to the Dialog#shell field inside a selection listener throws IllegalAccessError. Moving the call in the private method FileDialog#closeShell fixes the problem. Changes are in CVS HEAD.
Well, this is a tricky problem. Here's the reason: 1) The inner class is not a subclass of Dialog, therefore it does not have access to protected fields of Dialog. So, but why does it compile then? 2) Since the inner class is in the same package as FileDialog and Dialog, it can access the protected fields of Dialog anyway. But now comes OSGi. 3) In OSGi, different bundles have a different class loader. As an effect, package private access does not work anymore.