Repository: quarkusio/quarkus
Issue: Native build fails for JWT

### Describe the bug

Error while building natively for quarkus-smallrye-jwt-build when present as dependency with error: 

```
io.quarkus.smallrye.jwt.build.runtime.graalvm.Target_org_jose4j_jwk_OctetKeyPairJsonWebKey is not loaded. 


Error: Substitution target for io.quarkus.smallrye.jwt.build.runtime.graalvm.Target_org_jose4j_jwk_OctetKeyPairJsonWebKey is not loaded. Use field `onlyWith` in the `TargetClass` annotation to make substitution only active when needed.
com.oracle.svm.core.util.UserError$UserException: Substitution target for io.quarkus.smallrye.jwt.build.runtime.graalvm.Target_org_jose4j_jwk_OctetKeyPairJsonWebKey is not loaded. Use field `onlyWith` in the `TargetClass` annotation to make substitution only active when needed.
```

### Expected behavior

Native build to pass

### Actual behavior

Build fails on graalvm-ce-java11-22.3.0/bin/native-image for quarkus version 2.16.4

### How to Reproduce?

_No response_

### Output of `uname -a` or `ver`

Linux quarkus-native-postgres-1sr26 4.18.0-305.72.1.el8_4.x86_64 #1 SMP Thu Nov 17 09:15:11 EST 2022 x86_64 x86_64 x86_64 GNU/Linux

### Output of `java -version`

 graalvm-ce-java11-22.3.0

### GraalVM version (if different from Java)

graalvm-ce-java11-22.3.0

### Quarkus version or git rev

2.16.4

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Apache Maven 3.6.2 (Red Hat 3.6.2-7)


### Additional information

_No response_

Changed files:
extensions/smallrye-jwt-build/runtime/src/main/java/io/quarkus/smallrye/jwt/build/runtime/graalvm/Substitutions.java

diff --git a/extensions/smallrye-jwt-build/runtime/src/main/java/io/quarkus/smallrye/jwt/build/runtime/graalvm/Substitutions.java b/extensions/smallrye-jwt-build/runtime/src/main/java/io/quarkus/smallrye/jwt/build/runtime/graalvm/Substitutions.java
index 4d09817c95d..c7e868d0b0a 100644
--- a/extensions/smallrye-jwt-build/runtime/src/main/java/io/quarkus/smallrye/jwt/build/runtime/graalvm/Substitutions.java
+++ b/extensions/smallrye-jwt-build/runtime/src/main/java/io/quarkus/smallrye/jwt/build/runtime/graalvm/Substitutions.java
@@ -5,25 +5,34 @@
 import com.oracle.svm.core.annotate.Substitute;
 import com.oracle.svm.core.annotate.TargetClass;
 
-@TargetClass(className = "org.jose4j.jwk.OctetKeyPairJsonWebKey", onlyWith = JavaVersionLessThan17.class)
+@TargetClass(className = "org.jose4j.jwk.OctetKeyPairJsonWebKey", onlyWith = JavaVersionLessThan17andOctetKeyPairOnClasspath.class)
 final class Target_org_jose4j_jwk_OctetKeyPairJsonWebKey {
     @Substitute
     public Target_org_jose4j_jwk_OctetKeyPairJsonWebKey(java.security.PublicKey publicKey) {
+        throw new UnsupportedOperationException(
+                "OctetKeyPairJsonWebKey depends on EdECPrivateKeySpec which is not available in Java < 15");
     }
 
     @Substitute
     Target_org_jose4j_jwk_OctetKeyPairUtil subtypeKeyUtil() {
-        return null;
+        throw new UnsupportedOperationException(
+                "OctetKeyPairJsonWebKey depends on EdECPrivateKeySpec which is not available in Java < 15");
     }
 }
 
-@TargetClass(className = "org.jose4j.keys.OctetKeyPairUtil", onlyWith = JavaVersionLessThan17.class)
+@TargetClass(className = "org.jose4j.keys.OctetKeyPairUtil", onlyWith = JavaVersionLessThan17andOctetKeyPairOnClasspath.class)
 final class Target_org_jose4j_jwk_OctetKeyPairUtil {
 }
 
-class JavaVersionLessThan17 implements BooleanSupplier {
+class JavaVersionLessThan17andOctetKeyPairOnClasspath implements BooleanSupplier {
     @Override
     public boolean getAsBoolean() {
-        return Runtime.version().version().get(0) < 17;
+        try {
+            Class.forName("org.jose4j.jwk.OctetKeyPairJsonWebKey");
+            Class.forName("org.jose4j.jwk.OctetKeyPairUtil");
+            return Runtime.version().version().get(0) < 17;
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
     }
 }