Community
Participate
Working Groups
Created attachment 286827 [details] Special font definitions for Windows 10 platform org.eclipse.jface*.jar contains properties files in /org/eclipse/jface/resource listing default fonts per platform for specific needs. Attached properties file is from bundle org.eclipse.jface_3.22.100.v20210126-0831.jar (Eclipse 4.21). This file lists two fonts, Consolas and Courier New, for key org.eclipse.jface.textfont (resp. TEXT_FONT). This file is read on demand by org.eclipse.jface.resource.FontRegistry#readResourceBundle(ResourceBundle, String) into an FontData array with a minimum of eight entries, resulting in two entries having values set and six entries with a value null (code snippet with relevant command): FontData[] elements = stringToFontData.get(name); if (elements == null) { elements = new FontData[8]; stringToFontData.put(name, elements); } These unneccessary null values result in a NullPointerException in case this FontData array needs to be copied by the o.e.j.r.ArrayFontDescriptor returned by JFaceResources.getTextFontDescriptor(). NPE happens in o.e.j.r.FontDescriptor#copy(FontData[]) function, where null entries are not captured. I tried this code to get a smaller TEXT_FONT for my control. NPE is thrown in line 2 when a copy of that FontData array is to be created internally: FontDescriptor descriptor = JFaceResources.getTextFontDescriptor(); descriptor = descriptor.increaseHeight(-2); Font smallFont = descriptor.createFont(display); One could argue that NPE should be avoided in FontDescriptor#copy() methods, but having them at all is the result of an FontData array created too big in readResourceBundle, I'd say.
Thanks for report. Do you want to provide a patch? https://wiki.eclipse.org/Platform/How_to_Contribute
Have tried to contribute my first patch, but I feel lost. My commits contains/contained a file not changed by me and not shown in staging but after sending to Gerrit! How can that be? Tried to revert first commit and recommit another, but it feels I messed up everything. :-( I have two commits for eclipse.platform.ui now and no clue how to fix that: - Commit 888b643cf1a272a9bfaaf4306fe6dc69a436056e - Commit 4331170c6212db607aeb122a086857b96749e65c Files changed by myself: bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontDescriptor.java bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/FontRegistryTest.java File not changed by myself but in one of the commits automagically: bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ContentTypeDecorator.java
(In reply to Guido Schnepp from comment #2) > Have tried to contribute my first patch, but I feel lost. My commits > contains/contained a file not changed by me and not shown in staging but > after sending to Gerrit! How can that be? Tried to revert first commit and > recommit another, but it feels I messed up everything. :-( > > I have two commits for eclipse.platform.ui now and no clue how to fix that: > - Commit 888b643cf1a272a9bfaaf4306fe6dc69a436056e > - Commit 4331170c6212db607aeb122a086857b96749e65c > > Files changed by myself: > bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontDescriptor.java > bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java > tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/resources/ > FontRegistryTest.java > > File not changed by myself but in one of the commits automagically: > > bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ > ContentTypeDecorator.java You can use interactive rebase to combine the changes. See https://www.vogella.com/tutorials/EclipseGit/article.html#eclipsegit_interactiverebase If you want to recreate the whole commit and re-select the files, you can use a soft or mixed reset using the History view.