Bug 16970 - ClassCastException out of Launch history preference page
Summary: ClassCastException out of Launch history preference page
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 2.0   Edit
Hardware: PC other
: P1 critical (vote)
Target Milestone: 2.0 F2   Edit
Assignee: Darin Swanson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 17734 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-05-22 14:42 EDT by Darin Swanson CLA
Modified: 2002-05-28 21:11 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Swanson CLA 2002-05-22 14:42:58 EDT
Debug a launch to termination
Window->Preferences-->Launch History
Remove the recent debug launch
Hit Apply
Hit Restore Defaults
Hit Ok

java.lang.ClassCastException: java.lang.String
	at 
org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager.pr
opertyChange(LaunchConfigurationManager.java:813)
	at 
org.eclipse.ui.plugin.AbstractUIPlugin$CompatibilityPreferenceStore.fireProperty
ChangeEvent(AbstractUIPlugin.java:247)
	at org.eclipse.ui.plugin.AbstractUIPlugin$1.propertyChange
(AbstractUIPlugin.java:188)
	at org.eclipse.core.runtime.Preferences.firePropertyChangeEvent
(Preferences.java:505)
	at org.eclipse.core.runtime.Preferences.setToDefault
(Preferences.java:1189)
	at 
org.eclipse.ui.plugin.AbstractUIPlugin$CompatibilityPreferenceStore.setToDefault
(AbstractUIPlugin.java:415)
	at org.eclipse.jface.preference.FieldEditor.store(FieldEditor.java:573)
	at 
org.eclipse.debug.internal.ui.preferences.LaunchHistoryPreferencePage.performOk
(LaunchHistoryPreferencePage.java:192)
	at org.eclipse.jface.preference.PreferencePage.performApply
(PreferencePage.java:375)
	at org.eclipse.jface.preference.PreferencePage$2.widgetSelected
(PreferencePage.java:247)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
(Compiled Code))
	at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled 
Code))
	at org.eclipse.jface.window.Window.open(Window.java:538)
	at org.eclipse.ui.internal.OpenPreferencesAction.run
(OpenPreferencesAction.java:47)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:590)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:407)
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java(Compiled Code))
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java(Compiled Code))
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1068)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:739)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:200)
	at org.eclipse.core.launcher.Main.run(Main.java:643)
	at org.eclipse.core.launcher.Main.main(Main.java:476)
Comment 1 Darin Swanson CLA 2002-05-24 12:12:29 EDT
*** Bug 17734 has been marked as a duplicate of this bug. ***
Comment 2 Joe Szurszewski CLA 2002-05-24 15:13:17 EDT
This looks like a bug with IntegerFieldEditor.  
Test case:
Set breakpoint in 
LaunchConfigurationManager in propertyChange().
Key in change to max history size field, 
click Apply.
Note that 'new value' is an Integer, as expected.
Now, click 'Restore Defaults' 
button, then Apply.
Note that 'new value' is now a String, not expected.

Moving to UI.
Comment 3 Nick Edgar CLA 2002-05-26 21:54:02 EDT
This is the way the preferences work, although it is understandably confusing.
Since the preferences are not actually individually typed, the type of object 
in the callback depends on which call is used to change the value.  With 
setValue(String, int) the value is an Integer or null.  With setToDefault
(String) the value is a String or null.  See the method specs on Preferences.
Listeners need to be prepared to handle both Integer and String values (and 
null).  Alternatively, listeners can always ignore the values in the event and 
get the new value from the preferences.

There are several places that need fixing up:
Compare:
org.eclipse.compare.internal.Utilities.getValue(PropertyChangeEvent, boolean)

Debug:
org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager.p
ropertyChange(PropertyChangeEvent)

JDT Debug:
org.eclipse.jdt.internal.debug.ui.actions.ToggleStepFilterAction.propertyChange
(PropertyChangeEvent)
org.eclipse.jdt.internal.debug.ui.JavaDebugOptionsManager.propertyChange
(PropertyChangeEvent) (2 matches)

UI:
org.eclipse.ui.internal.WorkbenchActionBuilder.propertyChange
(PropertyChangeEvent)

Team:
org.eclipse.team.internal.ccvs.ui.CVSUIPlugin.propertyChange
(PropertyChangeEvent)

I'll file separate PRs for these.
Teams should double-check all senders of 
org.eclipse.jface.util.PropertyChangeEvent.getNewValue() and getOldValue().

Reassigning this one back to Debug.
Comment 4 Nick Edgar CLA 2002-05-26 22:05:43 EDT
The new runtime-level Preferences mechanism has the same pattern.
Should double-check refs to 
org.eclipse.core.runtime.Preferences.PropertyChangeEvent as well as the JFace 
one.
Comment 5 Nick Edgar CLA 2002-05-26 22:50:54 EDT
Filed the following bugs for each of the components above:
Compare: bug 17889
JDT-Debug: bug 17890
Team: bug 17891
Platform-UI: bug 17892
Comment 6 Darin Wright CLA 2002-05-27 20:48:38 EDT
Fixed.
Comment 7 Darin Wright CLA 2002-05-27 20:48:49 EDT
Please verify.
Comment 8 Darin Swanson CLA 2002-05-28 21:11:36 EDT
Verified.