Skip to content

Commit

Permalink
Merge pull request #31984 from zakkak/2023-03-20-fix-31930
Browse files Browse the repository at this point in the history
Only substitute OctetKeyPair* classes when on the classpath
  • Loading branch information
sberyozkin authored Mar 20, 2023
2 parents ba53ed3 + 1b143e9 commit 016389f
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

0 comments on commit 016389f

Please sign in to comment.