JDK-8289396 : Fix warnings: Null pointer access: The variable instance can only be null at this location
  • Type: Bug
  • Component: javafx
  • Sub-Component: build
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-06-28
  • Updated: 2022-07-09
  • Resolved: 2022-07-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx19Fixed
Related Reports
Blocks :  
Description
Eclipse Version 2022-06 (4.24.0) reports this warning in the following places:

```
Null pointer access: The variable instance can only be null at this location	RuleTest.java	line 175	/graphics/src/test/java/test/javafx/css
```

This code cannot be right:

    @Ignore("JDK-8234154")
    @Test
    public void testToString() {
        System.out.println("toString");
        Rule instance = null;
        String expResult = "";
        String result = instance.toString(); // <---- NPE
        assertEquals(expResult, result);
        fail("The test case is a prototype.");
    }

Comments
Changeset: 704baa31 Author: Andy Goryachev <andy.goryachev@oracle.com> Committer: Kevin Rushforth <kcr@openjdk.org> Date: 2022-07-06 17:04:18 +0000 URL: https://git.openjdk.org/jfx/commit/704baa31abb87025241feecfb4474efd33775d9d
06-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/813 Date: 2022-07-06 15:14:03 +0000
06-07-2022

Yes, the test looks like a placeholder. I believe that JDK-8234154 was filed (long after the fact) so that all `@Ignored` tests would have an associated bug ID.
05-07-2022

The test in question does nothing and ignored. The referenced ticket https://bugs.openjdk.org/browse/JDK-8234154 feels like a template. Removing the test case.
05-07-2022