Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353818

Summary: [FileDialog] IllegalAccessError when pressing on cancel button
Product: [RT] RAP Reporter: Ivan Furnadjiev <ivan>
Component: IncubatorAssignee: Project Inbox <rap.incubator-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1    
Version: 1.5   
Target Milestone: 1.5 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Ivan Furnadjiev CLA 2011-08-03 15:27:26 EDT
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)
Comment 1 Ivan Furnadjiev CLA 2011-08-03 15:35:54 EDT
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.
Comment 2 Ivan Furnadjiev CLA 2011-08-04 08:59:56 EDT
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.
Comment 3 Ralf Sternberg CLA 2011-08-05 10:34:06 EDT
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.