package org.jboss.shamrock.deployment;

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.shamrock.runtime.RegisterForReflection;

public class RegisterForReflectionProcessor implements ResourceProcessor {
    @Override
    public void process(ArchiveContext archiveContext, ProcessorContext processorContext) throws Exception {
        for (AnnotationInstance i : archiveContext.getCombinedIndex().getAnnotations(DotName.createSimple(RegisterForReflection.class.getName()))) {
            ClassInfo target = i.target().asClass();
            boolean methods = i.value("methods") == null || i.value("methods").asBoolean();
            boolean fields = i.value("fields") == null || i.value("fields").asBoolean();
            processorContext.addReflectiveClass(methods, fields, target.name().toString());
        }
    }

    @Override
    public int getPriority() {
        return 0;
    }
}

@@ -885,16 +885,305 @@
        %7D
+%0A%0A        //TODO: where should stuff like this go?%0A        //this will hold a heap of memory when it is initialized, and is rarely used (but it generally on the analysis path)%0A        processorContext.addRuntimeInitializedClasses(%22com.sun.org.apache.xml.internal.serializer.ToHTMLStream%22);
 %0A    %7D%0A%0A

Mark class with memory intensive static init method as init at runtime