Skip to content

Stop using Color constructors with Display#5002

Merged
akurtakov merged 1 commit intoeclipse-jdt:masterfrom
akurtakov:master
Apr 16, 2026
Merged

Stop using Color constructors with Display#5002
akurtakov merged 1 commit intoeclipse-jdt:masterfrom
akurtakov:master

Conversation

@akurtakov
Copy link
Copy Markdown
Contributor

Simplifies the code and reduces chances for problems. Contributes to eclipse-platform/eclipse.platform.swt#3233 .

Author checklist

Simplifies the code and reduces chances for problems. Contributes to
eclipse-platform/eclipse.platform.swt#3233 .
@akurtakov akurtakov merged commit a0dec6f into eclipse-jdt:master Apr 16, 2026
8 checks passed
@fedejeanne
Copy link
Copy Markdown
Contributor

This PR broke the I-BUILD test: https://download.eclipse.org/eclipse/downloads/drops4/I20260416-1800/testresults/html/org.eclipse.jdt.core.tests.model_ep440I-unit-linux-x86_64-java21_linux.gtk.x86_64_21.html

Different number of length. ----------- Expected ------------ package test.wksp.eclipse;\n \n /**\n * A ControlEditor is a manager for a Control that appears above a composite and\n * tracks with the moving and resizing of that composite. It can be used to\n * display one control above another control. This could be used when editing a\n * control that does not have editing capabilities by using a text editor or for\n * launching a dialog by placing a button above a control.\n * <p>\n * Here is an example of using a ControlEditor: <code><pre>\n * Canvas canvas = new Canvas(shell, SWT.BORDER);\n * canvas.setBounds(10, 10, 300, 300); \n * Color color = new Color(null, 255, 0, 0);\n * canvas.setBackground(color);\n * ControlEditor editor = new ControlEditor (canvas);\n * // The editor will be a button in the bottom right corner of the canvas.\n * // When selected, it will launch a Color dialog that will change the background \n * // of the canvas.\n * Button button = new Button(canvas, SWT.PUSH);\n * button.setText("Select Color...");\n * button.addSelectionListener (new SelectionAdapter() {\n * public void widgetSelected(SelectionEvent e) {\n * ColorDialog dialog = new ColorDialog(shell);\n * dialog.open();\n * RGB rgb = dialog.getRGB();\n * if (rgb != null) {\n * if (color != null) color.dispose();\n * color = new Color(null, rgb);\n * canvas.setBackground(color);\n * }\n * \n * }\n * });\n *\n * editor.horizontalAlignment = SWT.RIGHT;\n * editor.verticalAlignment = SWT.BOTTOM;\n * editor.grabHorizontal = false;\n * editor.grabVertical = false;\n * Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);\n * editor.minimumWidth = size.x;\n * editor.minimumHeight = size.y;\n * editor.setEditor (button);\n * </pre></code>\n */\n public class X26 {\n \n }\n ------------ but was ------------ package test.wksp.eclipse;\n \n /**\n * A ControlEditor is a manager for a Control that appears above a composite and\n * tracks with the moving and resizing of that composite. It can be used to\n * display one control above another control. This could be used when editing a\n * control that does not have editing capabilities by using a text editor or for\n * launching a dialog by placing a button above a control.\n * <p>\n * Here is an example of using a ControlEditor: <code><pre>\n * Canvas canvas = new Canvas(shell, SWT.BORDER);\n * canvas.setBounds(10, 10, 300, 300); \n * Color color = new Color(255, 0, 0);\n * canvas.setBackground(color);\n * ControlEditor editor = new ControlEditor (canvas);\n * // The editor will be a button in the bottom right corner of the canvas.\n * // When selected, it will launch a Color dialog that will change the background \n * // of the canvas.\n * Button button = new Button(canvas, SWT.PUSH);\n * button.setText("Select Color...");\n * button.addSelectionListener (new SelectionAdapter() {\n * public void widgetSelected(SelectionEvent e) {\n * ColorDialog dialog = new ColorDialog(shell);\n * dialog.open();\n * RGB rgb = dialog.getRGB();\n * if (rgb != null) {\n * if (color != null) color.dispose();\n * color = new Color(rgb);\n * canvas.setBackground(color);\n * }\n * \n * }\n * });\n *\n * editor.horizontalAlignment = SWT.RIGHT;\n * editor.verticalAlignment = SWT.BOTTOM;\n * editor.grabHorizontal = false;\n * editor.grabVertical = false;\n * Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);\n * editor.minimumWidth = size.x;\n * editor.minimumHeight = size.y;\n * editor.setEditor (button);\n * </pre></code>\n */\n public class X26 {\n \n }\n ---------------------- ---------- expected:<...r color = new Color([null, 255, 0, 0);\n * canvas.setBackground(color);\n * ControlEditor editor = new ControlEditor (canvas);\n * // The editor will be a button in the bottom right corner of the canvas.\n * // When selected, it will launch a Color dialog that will change the background \n * // of the canvas.\n * Button button = new Button(canvas, SWT.PUSH);\n * button.setText("Select Color...");\n * button.addSelectionListener (new SelectionAdapter() {\n * public void widgetSelected(SelectionEvent e) {\n * ColorDialog dialog = new ColorDialog(shell);\n * dialog.open();\n * RGB rgb = dialog.getRGB();\n * if (rgb != null) {\n * if (color != null) color.dispose();\n * color = new Color(null, ]rgb);\n * canvas....> but was:<...r color = new Color([255, 0, 0);\n * canvas.setBackground(color);\n * ControlEditor editor = new ControlEditor (canvas);\n * // The editor will be a button in the bottom right corner of the canvas.\n * // When selected, it will launch a Color dialog that will change the background \n * // of the canvas.\n * Button button = new Button(canvas, SWT.PUSH);\n * button.setText("Select Color...");\n * button.addSelectionListener (new SelectionAdapter() {\n * public void widgetSelected(SelectionEvent e) {\n * ColorDialog dialog = new ColorDialog(shell);\n * dialog.open();\n * RGB rgb = dialog.getRGB();\n * if (rgb != null) {\n * if (color != null) color.dispose();\n * color = new Color(]rgb);\n * canvas....>

junit.framework.ComparisonFailure: Different number of length.
----------- Expected ------------
package test.wksp.eclipse;\n
\n
/**\n
* A ControlEditor is a manager for a Control that appears above a composite and\n
* tracks with the moving and resizing of that composite. It can be used to\n
* display one control above another control. This could be used when editing a\n
* control that does not have editing capabilities by using a text editor or for\n
* launching a dialog by placing a button above a control.\n
* <p>\n
* Here is an example of using a ControlEditor: <code><pre>\n
* Canvas canvas = new Canvas(shell, SWT.BORDER);\n
* canvas.setBounds(10, 10, 300, 300); \n
* Color color = new Color(null, 255, 0, 0);\n
* canvas.setBackground(color);\n
* ControlEditor editor = new ControlEditor (canvas);\n
* // The editor will be a button in the bottom right corner of the canvas.\n
* // When selected, it will launch a Color dialog that will change the background \n
* // of the canvas.\n
* Button button = new Button(canvas, SWT.PUSH);\n
* button.setText("Select Color...");\n
* button.addSelectionListener (new SelectionAdapter() {\n
* public void widgetSelected(SelectionEvent e) {\n
* ColorDialog dialog = new ColorDialog(shell);\n
* dialog.open();\n
* RGB rgb = dialog.getRGB();\n
* if (rgb != null) {\n
* if (color != null) color.dispose();\n
* color = new Color(null, rgb);\n
* canvas.setBackground(color);\n
* }\n
* \n
* }\n
* });\n
*\n
* editor.horizontalAlignment = SWT.RIGHT;\n
* editor.verticalAlignment = SWT.BOTTOM;\n
* editor.grabHorizontal = false;\n
* editor.grabVertical = false;\n
* Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);\n
* editor.minimumWidth = size.x;\n
* editor.minimumHeight = size.y;\n
* editor.setEditor (button);\n
* </pre></code>\n
*/\n
public class X26 {\n
\n
}\n

------------ but was ------------
package test.wksp.eclipse;\n
\n
/**\n
* A ControlEditor is a manager for a Control that appears above a composite and\n
* tracks with the moving and resizing of that composite. It can be used to\n
* display one control above another control. This could be used when editing a\n
* control that does not have editing capabilities by using a text editor or for\n
* launching a dialog by placing a button above a control.\n
* <p>\n
* Here is an example of using a ControlEditor: <code><pre>\n
* Canvas canvas = new Canvas(shell, SWT.BORDER);\n
* canvas.setBounds(10, 10, 300, 300); \n
* Color color = new Color(255, 0, 0);\n
* canvas.setBackground(color);\n
* ControlEditor editor = new ControlEditor (canvas);\n
* // The editor will be a button in the bottom right corner of the canvas.\n
* // When selected, it will launch a Color dialog that will change the background \n
* // of the canvas.\n
* Button button = new Button(canvas, SWT.PUSH);\n
* button.setText("Select Color...");\n
* button.addSelectionListener (new SelectionAdapter() {\n
* public void widgetSelected(SelectionEvent e) {\n
* ColorDialog dialog = new ColorDialog(shell);\n
* dialog.open();\n
* RGB rgb = dialog.getRGB();\n
* if (rgb != null) {\n
* if (color != null) color.dispose();\n
* color = new Color(rgb);\n
* canvas.setBackground(color);\n
* }\n
* \n
* }\n
* });\n
*\n
* editor.horizontalAlignment = SWT.RIGHT;\n
* editor.verticalAlignment = SWT.BOTTOM;\n
* editor.grabHorizontal = false;\n
* editor.grabVertical = false;\n
* Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);\n
* editor.minimumWidth = size.x;\n
* editor.minimumHeight = size.y;\n
* editor.setEditor (button);\n
* </pre></code>\n
*/\n
public class X26 {\n
\n
}\n

---------------------- ----------
expected:<...r color = new Color([null, 255, 0, 0);\n
* canvas.setBackground(color);\n
* ControlEditor editor = new ControlEditor (canvas);\n
* // The editor will be a button in the bottom right corner of the canvas.\n
* // When selected, it will launch a Color dialog that will change the background \n
* // of the canvas.\n
* Button button = new Button(canvas, SWT.PUSH);\n
* button.setText("Select Color...");\n
* button.addSelectionListener (new SelectionAdapter() {\n
* public void widgetSelected(SelectionEvent e) {\n
* ColorDialog dialog = new ColorDialog(shell);\n
* dialog.open();\n
* RGB rgb = dialog.getRGB();\n
* if (rgb != null) {\n
* if (color != null) color.dispose();\n
* color = new Color(null, ]rgb);\n
* canvas....> but was:<...r color = new Color([255, 0, 0);\n
* canvas.setBackground(color);\n
* ControlEditor editor = new ControlEditor (canvas);\n
* // The editor will be a button in the bottom right corner of the canvas.\n
* // When selected, it will launch a Color dialog that will change the background \n
* // of the canvas.\n
* Button button = new Button(canvas, SWT.PUSH);\n
* button.setText("Select Color...");\n
* button.addSelectionListener (new SelectionAdapter() {\n
* public void widgetSelected(SelectionEvent e) {\n
* ColorDialog dialog = new ColorDialog(shell);\n
* dialog.open();\n
* RGB rgb = dialog.getRGB();\n
* if (rgb != null) {\n
* if (color != null) color.dispose();\n
* color = new Color(]rgb);\n
* canvas....>
at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertStringEquals(TestCase.java:265)
at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertEquals(TestCase.java:240)
at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.assertSourceEquals(AbstractJavaModelTests.java:1145)
at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.assertSourceEquals(AbstractJavaModelTests.java:1125)
at org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.assertLineEquals(FormatterRegressionTests.java:272)
at org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.assertLineEquals(FormatterRegressionTests.java:277)
at org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.formatSource(FormatterRegressionTests.java:346)
at org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests.formatUnit(FormatterCommentsTests.java:261)
at org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests.formatUnit(FormatterCommentsTests.java:247)
at org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests.testWkspEclipse26(FormatterCommentsTests.java:1167)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at junit.framework.TestCase.runTest(TestCase.java:177)
at org.eclipse.jdt.core.tests.junit.extension.TestCase.runTest(TestCase.java:970)
at junit.framework.TestCase.runBare(TestCase.java:142)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:130)
at junit.framework.TestSuite.runTest(TestSuite.java:241)
at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.runTest(SuiteOfTestCases.java:114)
at junit.framework.TestSuite.run(TestSuite.java:236)
at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.superRun(SuiteOfTestCases.java:97)
at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite$1.protect(SuiteOfTestCases.java:85)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.run(SuiteOfTestCases.java:94)
at junit.framework.TestSuite.runTest(TestSuite.java:241)
at junit.framework.TestSuite.run(TestSuite.java:236)
Suppressed: java.lang.RuntimeException: Happend when formating:
"/FormatterJavadoc/test/wksp/eclipse/X26.java"
Expected output:
"/home/jenkins/agent/workspace/AutomatedTests/ep440I-unit-linux-x86_64-java21/workarea/I20260416-1800/eclipse-testing/test-eclipse/eclipse/formatter-folder/FormatterJavadoc/test/wksp/eclipse/out/clear_blank_lines/X26.java"
at org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests.formatUnit(FormatterCommentsTests.java:265)
... 19 more 

... I can't figure out how exactly though. The error message is quite noisy.

@akurtakov
Copy link
Copy Markdown
Contributor Author

Why hasn't this failed in the verification build?

akurtakov added a commit to akurtakov/eclipse.jdt.core that referenced this pull request Apr 17, 2026
Should fix I-build test failure as pointed in
eclipse-jdt#5002 (comment)
@fedejeanne
Copy link
Copy Markdown
Contributor

No idea but I found the error. PR follows

fedejeanne added a commit to fedejeanne/eclipse.jdt.core that referenced this pull request Apr 17, 2026
The test is:
org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests.testWkspEclipse26

It was broken in the I-BUILDs by
eclipse-jdt#5002.

Contributes to
eclipse-platform/eclipse.platform.swt#3233
akurtakov pushed a commit that referenced this pull request Apr 17, 2026
The test is:
org.eclipse.jdt.core.tests.formatter.FormatterCommentsTests.testWkspEclipse26

It was broken in the I-BUILDs by
#5002.

Contributes to
eclipse-platform/eclipse.platform.swt#3233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants