Merge pull request #99 from rmpestano/method-handles

Disable method handles in quarkus native mode
diff --git a/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java b/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java
index f78259d..1e9cee2 100644
--- a/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java
+++ b/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java
@@ -38,6 +38,7 @@
 import javax.faces.view.facelets.FaceletsResourceResolver;
 import javax.faces.webapp.FacesServlet;
 
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
 import org.apache.myfaces.cdi.FacesScoped;
 import org.apache.myfaces.cdi.JsfApplicationArtifactHolder;
 import org.apache.myfaces.cdi.JsfArtifactProducer;
@@ -49,6 +50,7 @@
 import org.apache.myfaces.config.annotation.CdiAnnotationProviderExtension;
 import org.apache.myfaces.config.element.NamedEvent;
 import org.apache.myfaces.core.extensions.quarkus.runtime.exception.QuarkusExceptionHandlerFactory;
+import org.apache.myfaces.el.resolver.MethodHandleBeanELResolver;
 import org.apache.myfaces.flow.cdi.FlowBuilderFactoryBean;
 import org.apache.myfaces.flow.cdi.FlowScopeBeanHolder;
 import org.apache.myfaces.push.cdi.PushContextFactoryBean;
@@ -56,6 +58,8 @@
 import org.apache.myfaces.push.cdi.WebsocketChannelTokenBuilderBean;
 import org.apache.myfaces.push.cdi.WebsocketSessionBean;
 import org.apache.myfaces.push.cdi.WebsocketViewBean;
+import org.apache.myfaces.util.lang.MethodHandleUtils;
+import org.apache.myfaces.view.facelets.tag.MethodHandleMetadataTargetImpl;
 import org.apache.myfaces.webapp.StartupServletContextListener;
 import org.eclipse.microprofile.config.Config;
 import org.eclipse.microprofile.config.ConfigProvider;
@@ -426,6 +430,7 @@
         classNames.addAll(collectSubclasses(combinedIndex, DocumentBuilderFactory.class.getName()));
         classNames.add("com.sun.org.apache.xpath.internal.functions.FuncLocalPart");
         classNames.add("com.sun.org.apache.xpath.internal.functions.FuncNot");
+        classNames.add("com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
         
         for (String factory : FACTORIES)
         {
@@ -746,15 +751,7 @@
         }
     }
     
-    
-    
-    
-    
-    
-    
-    
-    
-    
+
     @BuildStep
     void buildPrimeFacesRecommendedInitParams(BuildProducer<ServletInitParamBuildItem> initParam) throws IOException
     {
@@ -800,6 +797,17 @@
                 "org.primefaces.util.MessageFactory",
                 "com.lowagie.text.pdf.MappedRandomAccessFile"));
     }
+
+    @BuildStep
+    void registerRuntimeInitialization(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitClassBuildItem)
+    {
+        runtimeInitClassBuildItem.produce(
+                new RuntimeInitializedClassBuildItem(MethodHandleBeanELResolver.class.getCanonicalName()));
+        runtimeInitClassBuildItem.produce(
+                new RuntimeInitializedClassBuildItem(MethodHandleMetadataTargetImpl.class.getCanonicalName()));
+        runtimeInitClassBuildItem.produce(
+                new RuntimeInitializedClassBuildItem(MethodHandleUtils.class.getCanonicalName()));
+    }
     
     
 }
diff --git a/extensions/quarkus/runtime/pom.xml b/extensions/quarkus/runtime/pom.xml
index 8a85bb3..ca0271e 100644
--- a/extensions/quarkus/runtime/pom.xml
+++ b/extensions/quarkus/runtime/pom.xml
@@ -129,6 +129,16 @@
             <artifactId>openpdf</artifactId>
             <version>1.2.21</version>
         </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.9.10</version>
+        </dependency>
+        <dependency>
+            <groupId>org.graalvm.nativeimage</groupId>
+            <artifactId>svm</artifactId>
+            <version>20.0.0</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/extensions/quarkus/runtime/src/main/java/org/apache/myfaces/core/extensions/quarkus/runtime/graal/NativeMyFacesConfig.java b/extensions/quarkus/runtime/src/main/java/org/apache/myfaces/core/extensions/quarkus/runtime/graal/NativeMyFacesConfig.java
new file mode 100644
index 0000000..52d5c60
--- /dev/null
+++ b/extensions/quarkus/runtime/src/main/java/org/apache/myfaces/core/extensions/quarkus/runtime/graal/NativeMyFacesConfig.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.core.extensions.quarkus.runtime.graal;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.myfaces.config.MyfacesConfig;
+
+
+@TargetClass(MyfacesConfig.class)
+public final class NativeMyFacesConfig
+{
+    @Substitute
+    public boolean isUseMethodHandles()
+    {
+        return false;
+    }
+
+}
diff --git a/extensions/quarkus/showcase/pom.xml b/extensions/quarkus/showcase/pom.xml
index 63f1f78..4781cbc 100644
--- a/extensions/quarkus/showcase/pom.xml
+++ b/extensions/quarkus/showcase/pom.xml
@@ -64,6 +64,11 @@
             <artifactId>validation-api</artifactId>
             <version>2.0.1.Final</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.10</version>
+        </dependency>
 
         <dependency> <!-- workaround for https://github.com/quarkusio/quarkus/issues/7359 -->
             <groupId>com.fasterxml.woodstox</groupId>
@@ -138,6 +143,7 @@
                                 </goals>
                                 <configuration>
                                     <enableHttpUrlHandler>true</enableHttpUrlHandler>
+                                    <additionalBuildArgs>--report-unsupported-elements-at-runtime</additionalBuildArgs>
                                 </configuration>
                             </execution>
                         </executions>