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

Bug 29290

Summary: [Widgets] NumberFormatException getting FontMetrics on Solaris
Product: [Eclipse Project] Platform Reporter: Tod Creasey <Tod_Creasey>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WONTFIX QA Contact: Grant Gayed <grant_gayed>
Severity: normal    
Priority: P3 CC: ahobson
Version: 2.1Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Solaris   
Whiteboard:
Bug Depends on:    
Bug Blocks: 28780    
Attachments:
Description Flags
Andrew Hobsons font test file
none
FontData test that should show the problem for Andrews machine
none
Results of running FontDataTest none

Description Tod Creasey CLA 2003-01-10 08:48:30 EST
20021218

I have not been able to reproduce this but a client (cc'ed here) is getting a 
NumberFormat exception whenever we try and get FontMetrics.

Here are all of the stats and the exception

$JAVA_HOME/bin/java -version
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)

!ENTRY org.eclipse.ui 4 0 Jan 09, 2003 10:20:17.181
!MESSAGE [9.00 0.00 0.00 9.00]
!STACK 0
java.lang.NumberFormatException: [9.00 0.00 0.00 9.00]
        at java.lang.Integer.parseInt(Integer.java:414)
        at java.lang.Integer.parseInt(Integer.java:463)
        at org.eclipse.swt.graphics.FontData.setXlfd(FontData.java:477)
        at org.eclipse.swt.graphics.FontData.motif_new(FontData.java:337)
        at org.eclipse.swt.graphics.GC.getFontMetrics(GC.java:1922)
        at org.eclipse.jdt.internal.ui.preferences.ColorEditor.computeImageSize
(
ColorEditor.java:111)
        at org.eclipse.jdt.internal.ui.preferences.ColorEditor.<init>
(ColorEdito
r.java:40)
        at 
org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage.crea
teAppearancePage(JavaEditorPreferencePage.java:652)
        at 
org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage.crea
teContents(JavaEditorPreferencePage.java:938)
        at org.eclipse.jface.preference.PreferencePage.createControl
(PreferenceP
age.java:209)
        at 
org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage.crea
teControl(JavaEditorPreferencePage.java:322)
        at org.eclipse.jface.preference.PreferenceDialog.showPage
(PreferenceDial
og.java:963)
        at org.eclipse.jface.preference.PreferenceDialog$7.run
(PreferenceDialog.
java:456)
        at org.eclipse.swt.custom.BusyIndicator.showWhile
(BusyIndicator.java:65)
        at org.eclipse.jface.preference.PreferenceDialog$6.widgetSelected
(Prefer
enceDialog.java:449)
        at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent
(OpenStrate
gy.java:192)
        at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:187)
        at org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:327)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:31)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages
(Synchronizer.ja
va:94)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1803)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1619)
        at org.eclipse.jface.window.Window.runEventLoop(Window.java:561)
        at org.eclipse.jface.window.Window.open(Window.java:541)
        at org.eclipse.ui.internal.OpenPreferencesAction.run
(OpenPreferencesActi
on.java:47)
        at org.eclipse.jface.action.Action.runWithEvent(Action.java:769)
        at 
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:411)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent
(Act
ionContributionItem.java:365)
        at org.eclipse.jface.action.ActionContributionItem.access$0
(ActionContri
butionItem.java:356)
        at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handle
Event(ActionContributionItem.java:48)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:855)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1825)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1616)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1446)
        at org.eclipse.ui.internal.Workbench.run(Workbench.java:1429)
        at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoa
der.java:845)
        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:247)
        at org.eclipse.core.launcher.Main.run(Main.java:703)
        at org.eclipse.core.launcher.Main.main(Main.java:539)
Comment 1 Tod Creasey CLA 2003-01-10 09:26:48 EST
Andrew Hobson has also found this in an SWT example. Andrew please let us know 
which example you found it in.
Comment 2 Tod Creasey CLA 2003-01-10 09:27:28 EST
Also see an example at http://bugs.eclipse.org/bugs/attachment.cgi?
id=2946&action=view
Comment 3 Andrew Hobson CLA 2003-01-10 10:58:34 EST
I'm having a bad morning creating coherent communication.  I didn't find the
exact code in the sample articles, but I was able to use the sample article to
build a sample application.  I then used the CVS repository to replicate the
code that did a getFontMetric call.

I'm sorry for writing such confusing comments.
Comment 4 Felipe Heidrich CLA 2003-01-10 19:28:53 EST
More info would be appreciate:
Which is the locale you're running ?
What is the font that you are trying to get the metric ? It maybe a font name 
does not have  a good xlfd.

Grant to investigate.


Comment 5 Andrew Hobson CLA 2003-01-22 14:15:43 EST
I don't know much about this, but the test case does

JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);

If it is a problem with the font, it's a problem with the default.
Comment 6 Tod Creasey CLA 2003-01-23 10:18:46 EST
Andrew I am moving our conversation to this PR so that the SWT guys get
notifications as well.

Andrew has discovered that 

JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT) causes this
error 

but 

JFaceResources.getDefaultFont() does not.

The difference between the two calls is that the first one loads a font from a
FontData definition and the second one asks an SWT shell for its font.

Andrew could you please also try


JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT)
JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)
JFaceResources.getFontRegistry().get(JFaceResources.HEADER_FONT)
JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)
JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT)

Comment 7 Tod Creasey CLA 2003-01-23 10:19:36 EST
Created attachment 3101 [details]
Andrew Hobsons font test file
Comment 8 Tod Creasey CLA 2003-01-23 11:25:37 EST
I am attaching anotehr test file. Andrew please run this and let me know if you
get those Number format exceptions. If you could also paste the output from it
into the PR that would be helpful as well.

Comment 9 Tod Creasey CLA 2003-01-23 11:27:02 EST
Created attachment 3105 [details]
FontData test that should show the problem for Andrews machine

This test case creates all of the FontDatas JFace uses using the same API.
Requires JFace
Comment 10 Andrew Hobson CLA 2003-01-23 11:39:18 EST
Created attachment 3106 [details]
Results of running FontDataTest

FontDataTest ran successfully.	I've attached the results.
Comment 11 Grant Gayed CLA 2009-08-26 12:57:40 EDT
Moving report to triage, see http://www.eclipse.org/swt/triage.php
for more info about bug handling.
Comment 12 Lakshmi P Shanmugam CLA 2017-06-20 02:38:14 EDT
Solaris is no longer a supported platform.