Skip to content

Commit

Permalink
Merge pull request #27263 from zakkak/drop-serializationfeature-featu…
Browse files Browse the repository at this point in the history
…re-dependency

Drop getRequiredFeatures method from io.quarkus.runner.Feature
  • Loading branch information
gsmet authored Aug 17, 2022
2 parents d7e25d5 + fee232a commit c3d6891
Showing 1 changed file with 0 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c3d6891

Please sign in to comment.