Inspectopedia Help

Accessor call that can be replaced with property access syntax

Reports Java get and set method calls that can be replaced with the Kotlin synthetic properties.

Use property access syntax quick-fix can be used to amend the code automatically.

Example:

// Java: public class JavaClassWithGetter { private final String expr = "result"; // ... public String getExpr() { return expr; } }
// Kotlin: fun test(j: JavaClassWithGetter) { // ... j.getExpr() // <== The quick-fix simplifies the expression to 'j.expr' }

Inspection options

Option

Type

Default

Report non-trivial accessors

Checkbox

false

Excluded methods

StringList

[java.net.Socket.getInputStream, java.net.Socket.getOutputStream, java.net.URLConnection.getInputStream, java.net.URLConnection.getOutputStream, java.util.concurrent.atomic.AtomicInteger.getAndIncrement, java.util.concurrent.atomic.AtomicInteger.getAndDecrement, java.util.concurrent.atomic.AtomicInteger.getAcquire, java.util.concurrent.atomic.AtomicInteger.getOpaque, java.util.concurrent.atomic.AtomicInteger.getPlain, java.util.concurrent.atomic.AtomicLong.getAndIncrement, java.util.concurrent.atomic.AtomicLong.getAndDecrement, java.util.concurrent.atomic.AtomicLong.getAcquire, java.util.concurrent.atomic.AtomicLong.getOpaque, java.util.concurrent.atomic.AtomicLong.getPlain, java.nio.ByteBuffer.getChar, java.nio.ByteBuffer.getDouble, java.nio.ByteBuffer.getFloat, java.nio.ByteBuffer.getInt, java.nio.ByteBuffer.getLong, java.nio.ByteBuffer.getShort]

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023