Inspectopedia Help

Reflective access to non-existent or not visible class member

Reports reflective access to fields and methods that don't exist or aren't visible.

Example:

Field stringHashField() throws NoSuchFieldException { return String.class.getField("hash"); }

After the quick-fix is applied:

Field stringHashField() throws NoSuchFieldException { return String.class.getDeclaredField("hash"); }

With a final class, it's clear if there is a field or method with the specified name in the class.

With non-final classes, it's possible that a subclass has a field or method with that name, so there could be false positives. Use the inspection's settings to get rid of such false positives everywhere or with specific classes.

New in 2017.2

Inspection options

Option

Type

Default

Exclude classes

StringList

[java.lang.Object, java.lang.Throwable]

Check that field/method exists in non-final classes

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023