Problem
The AP fast-path for active LDM calls forceReconnect() on an ApConnection instance. forceReconnect() is a public method — it is declared on the Connection interface in jnats and is fully public. The problem is not the method visibility.
The actual problem is that ApConnection lives in io.nats.client.impl, a package with no public export. It cannot be imported or referenced as a named type from outside that package. Because of this, calling any method on an ApConnection — including the already-public forceReconnect() — from external code is not possible without resorting to split-package access, which works on the classic classpath but is incompatible with the Java Module System (JPMS).
Proposed resolution
Either:
Option A — Expose ApConnection via a narrow public interface in io.nats.client:
// New public interface in io.nats.client
public interface ApConnectionSupport {
/**
* Forces the active connection to immediately reconnect using the pre-warmed passive socket.
* Triggers the fast-path socket-steal failover (client-side thread swap only —
* no network call, expected low single-digit to ~20ms).
* Intended to be called from the active connection's LDM listener.
*/
void activeForceReconnect() throws IOException, InterruptedException;
}
// ApConnection implements ApConnectionSupport
Option B — Move ApConnection to io.nats.client (or add a public marker) so it is importable as a named type.
Option A is preferred — it provides a narrow, stable, JPMS-compatible public contract.
Current workaround
We use the split-package pattern — placing a helper class in the same io.nats.client.impl package as ApConnection across JAR boundaries. This lets us hold a typed reference to ApConnection and call its methods. It works today on the classic classpath but is fragile: any addition of a module-info.java to either library would immediately break it without any warning at compile time.
Problem
The AP fast-path for active LDM calls
forceReconnect()on anApConnectioninstance.forceReconnect()is a public method — it is declared on theConnectioninterface in jnats and is fully public. The problem is not the method visibility.The actual problem is that
ApConnectionlives inio.nats.client.impl, a package with no public export. It cannot be imported or referenced as a named type from outside that package. Because of this, calling any method on anApConnection— including the already-publicforceReconnect()— from external code is not possible without resorting to split-package access, which works on the classic classpath but is incompatible with the Java Module System (JPMS).Proposed resolution
Either:
Option A — Expose
ApConnectionvia a narrow public interface inio.nats.client:Option B — Move
ApConnectiontoio.nats.client(or add a public marker) so it is importable as a named type.Option A is preferred — it provides a narrow, stable, JPMS-compatible public contract.
Current workaround
We use the split-package pattern — placing a helper class in the same
io.nats.client.implpackage asApConnectionacross JAR boundaries. This lets us hold a typed reference toApConnectionand call its methods. It works today on the classic classpath but is fragile: any addition of amodule-info.javato either library would immediately break it without any warning at compile time.