I'm trying to understand how is it possible to have a runtime-only dependency in Java. I understand the concept of compile-time-only dependencies, for example when your code uses an Annotation library, and the annotations are consumed by the compiler to enforce some policies, but this library isn't used on runtime.
But regarding runtime-only dependencies, I can't understand how is possible.
Let's say my code contains Class A:
class A {
void someMethod() {
B b = new B();
b.foo();
{
}
So my code depends on class B, which is obviously a compile-time and runtime dependency. A runtime-only dependency implies that the dependency is not needed at compile time, which implies that my code doesn't directly refer to it, so why is it a dependency at all?
Would love some concrete example.