From bf9f51e106c2ac854a7b4024d90cc3ad1baae38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 8 Feb 2022 16:43:09 +0100 Subject: [PATCH] HV-1882 Fix a few previously undetected uses of methods deprecated in JDK 17 Not sure why this wasn't detected before; probably because we were running compiling tests to Java 8 bytecode. --- .../test/internal/engine/ValidatorFactoryNoELBootstrapTest.java | 1 + .../internal/engine/valueextraction/JavaFXClassLoadingTest.java | 2 ++ .../test/internal/metadata/bytebuddy/ByteBuddyWrapperTest.java | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/src/test/java/org/hibernate/validator/test/internal/engine/ValidatorFactoryNoELBootstrapTest.java b/engine/src/test/java/org/hibernate/validator/test/internal/engine/ValidatorFactoryNoELBootstrapTest.java index 869915b1b9..a90dff04b6 100644 --- a/engine/src/test/java/org/hibernate/validator/test/internal/engine/ValidatorFactoryNoELBootstrapTest.java +++ b/engine/src/test/java/org/hibernate/validator/test/internal/engine/ValidatorFactoryNoELBootstrapTest.java @@ -250,6 +250,7 @@ private void runWithoutElLibs(Class delegateType, String packageMissing) thro * NOTE: This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ + @IgnoreForbiddenApisErrors(reason = "SecurityManager is deprecated in JDK17") private T run(PrivilegedAction action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } diff --git a/engine/src/test/java/org/hibernate/validator/test/internal/engine/valueextraction/JavaFXClassLoadingTest.java b/engine/src/test/java/org/hibernate/validator/test/internal/engine/valueextraction/JavaFXClassLoadingTest.java index d9e95139cb..1e0b750153 100644 --- a/engine/src/test/java/org/hibernate/validator/test/internal/engine/valueextraction/JavaFXClassLoadingTest.java +++ b/engine/src/test/java/org/hibernate/validator/test/internal/engine/valueextraction/JavaFXClassLoadingTest.java @@ -13,6 +13,7 @@ import javax.validation.ValidationException; +import org.hibernate.validator.internal.IgnoreForbiddenApisErrors; import org.hibernate.validator.internal.util.privilegedactions.LoadClass; import org.hibernate.validator.testutil.TestForIssue; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -61,6 +62,7 @@ private static boolean isClassPresent(String className, ClassLoader classLoader, * NOTE: This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ + @IgnoreForbiddenApisErrors(reason = "SecurityManager is deprecated in JDK17") private static T run(PrivilegedAction action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } diff --git a/engine/src/test/java/org/hibernate/validator/test/internal/metadata/bytebuddy/ByteBuddyWrapperTest.java b/engine/src/test/java/org/hibernate/validator/test/internal/metadata/bytebuddy/ByteBuddyWrapperTest.java index 41bdc52424..fb2f1b69d2 100644 --- a/engine/src/test/java/org/hibernate/validator/test/internal/metadata/bytebuddy/ByteBuddyWrapperTest.java +++ b/engine/src/test/java/org/hibernate/validator/test/internal/metadata/bytebuddy/ByteBuddyWrapperTest.java @@ -71,7 +71,7 @@ public void testByteBuddy() throws Exception { .load( classLoader, ClassLoadingStrategy.Default.INJECTION ) .getLoaded(); - Object object = aClass.newInstance(); + Object object = aClass.getConstructor().newInstance(); Method getFieldValue = aClass.getMethod( HibernateValidatorEnhancedBean.GET_FIELD_VALUE_METHOD_NAME, String.class );