package io.micronaut.http.netty.graal;
import com.oracle.svm.core.annotate.AutomaticFeature;
import io.micronaut.core.annotation.Internal;
import io.micronaut.core.graal.AutomaticFeatureUtils;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
@Internal
@AutomaticFeature
public class HttpNettyFeature implements Feature {
@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
RuntimeClassInitialization.initializeAtRunTime(
"io.netty.channel.epoll",
"io.netty.channel.kqueue",
"io.netty.channel.unix"
);
registerClasses(access,
"io.netty.channel.kqueue.KQueueChannelOption", "io.netty.channel.epoll.EpollChannelOption");
}
private void registerClasses(BeforeAnalysisAccess access, String... classes) {
for (String clazz : classes) {
AutomaticFeatureUtils.registerClassForRuntimeReflection(access, clazz);
AutomaticFeatureUtils.registerFieldsForRuntimeReflection(access, clazz);
}
}
}