From fee232a8656ebbab2433cc1b8eb7adfac566ee5f Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Fri, 12 Aug 2022 10:23:28 +0300 Subject: [PATCH] Drop getRequiredFeatures method from io.quarkus.runner.Feature In https://github.com/quarkusio/quarkus/pull/25976 we switched from using the @AutomaticFeature annotation to explicitly passing the required features using the --features parameter. Given that `@AutomaticFeature`s (including the `SerializationFeature`) are always registered before non-automatic ones there is no longer the need to have an explicit dependency on `SerializationFeture`. --- .../steps/NativeImageFeatureStep.java | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java index acd4642e20dd5..87c5a555557d1 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java @@ -43,8 +43,6 @@ import io.quarkus.deployment.builditem.nativeimage.UnsafeAccessedFieldBuildItem; import io.quarkus.deployment.pkg.steps.GraalVM; import io.quarkus.gizmo.AssignableResultHandle; -import io.quarkus.gizmo.BranchResult; -import io.quarkus.gizmo.BytecodeCreator; import io.quarkus.gizmo.CatchBlockCreator; import io.quarkus.gizmo.ClassCreator; import io.quarkus.gizmo.ClassOutput; @@ -59,8 +57,6 @@ public class NativeImageFeatureStep { public static final String GRAAL_FEATURE = "io.quarkus.runner.Feature"; - private static final MethodDescriptor VERSION_CURRENT = ofMethod(Version.class, "getCurrent", Version.class); - private static final MethodDescriptor VERSION_COMPARE_TO = ofMethod(Version.class, "compareTo", int.class, int[].class); private static final MethodDescriptor IMAGE_SINGLETONS_LOOKUP = ofMethod(ImageSingletons.class, "lookup", Object.class, Class.class); @@ -589,36 +585,6 @@ public void write(String s, byte[] bytes) { } private MethodDescriptor createRegisterSerializationForClassMethod(ClassCreator file) { - //register serialization feature as requested - MethodCreator requiredFeatures = file.getMethodCreator("getRequiredFeatures", "java.util.List"); - - TryBlock requiredTryCatch = requiredFeatures.tryBlock(); - - AssignableResultHandle serializationFeatureClass = requiredTryCatch.createVariable(Class.class); - - BranchResult graalVm22_3Test = requiredTryCatch.ifGreaterEqualZero( - requiredTryCatch.invokeVirtualMethod(VERSION_COMPARE_TO, - requiredTryCatch.invokeStaticMethod(VERSION_CURRENT), - requiredTryCatch.marshalAsArray(int.class, requiredTryCatch.load(22), requiredTryCatch.load(3)))); - /* GraalVM >= 22.3 */ - BytecodeCreator greaterThan22_2 = graalVm22_3Test.trueBranch(); - greaterThan22_2.assign(serializationFeatureClass, - greaterThan22_2.loadClassFromTCCL("com.oracle.svm.hosted.reflect.serialize.SerializationFeature")); - /* GraalVM < 22.3 */ - BytecodeCreator smallerThan22_3 = graalVm22_3Test.falseBranch(); - smallerThan22_3.assign(serializationFeatureClass, - smallerThan22_3.loadClassFromTCCL("com.oracle.svm.reflect.serialize.hosted.SerializationFeature")); - - ResultHandle requiredFeaturesList = requiredTryCatch.invokeStaticMethod( - ofMethod("java.util.Collections", "singletonList", List.class, Object.class), - serializationFeatureClass); - - requiredTryCatch.returnValue(requiredFeaturesList); - - CatchBlockCreator cc = requiredTryCatch.addCatch(Throwable.class); - cc.invokeVirtualMethod(ofMethod(Throwable.class, "printStackTrace", void.class), cc.getCaughtException()); - cc.throwException(cc.getCaughtException()); - // method to register class for registration MethodCreator addSerializationForClass = file.getMethodCreator("registerSerializationForClass", "V", Class.class); addSerializationForClass.setModifiers(Modifier.PRIVATE | Modifier.STATIC);