Workaround for https://github.com/oracle/graal/issues/1971
diff --git a/extensions/bean/runtime/pom.xml b/extensions/bean/runtime/pom.xml
index d59254d..5935a7e 100644
--- a/extensions/bean/runtime/pom.xml
+++ b/extensions/bean/runtime/pom.xml
@@ -50,6 +50,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.oracle.substratevm</groupId>
+ <artifactId>svm</artifactId>
+ </dependency>
<!-- camel -->
<dependency>
diff --git a/extensions/bean/runtime/src/main/java/org/apache/camel/quarkus/component/bean/graal/ExcludeMethodList.java b/extensions/bean/runtime/src/main/java/org/apache/camel/quarkus/component/bean/graal/ExcludeMethodList.java
new file mode 100644
index 0000000..353006a
--- /dev/null
+++ b/extensions/bean/runtime/src/main/java/org/apache/camel/quarkus/component/bean/graal/ExcludeMethodList.java
@@ -0,0 +1,72 @@
+/*
+ * 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.camel.quarkus.component.bean.graal;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is a workaround for https://github.com/oracle/graal/issues/1971. An instance of lazily initialized list is set
+ * to {@code org.apache.camel.component.bean.BeanInfo.EXCLUDED_METHODS}.
+ *
+ * @see SubstituteBeanInfo
+ */
+class ExcludeMethodList extends AbstractList<Method> {
+
+ private volatile List<Method> delegate;
+
+ @Override
+ public Method get(int index) {
+ return delegate().get(index);
+ }
+
+ @Override
+ public int size() {
+ return delegate().size();
+ }
+
+ List<Method> delegate() {
+ if (delegate == null) {
+ synchronized (this) {
+ if (delegate == null) {
+ // The logic is taken from the static initializer of BeanInfo
+ delegate = new ArrayList<>();
+ // exclude all java.lang.Object methods as we dont want to invoke them
+ delegate.addAll(Arrays.asList(Object.class.getDeclaredMethods()));
+ // exclude all java.lang.reflect.Proxy methods as we dont want to invoke them
+ delegate.addAll(Arrays.asList(Proxy.class.getDeclaredMethods()));
+ // Remove private methods
+ delegate.removeIf(m -> Modifier.isPrivate(m.getModifiers()));
+ try {
+ // but keep toString as this method is okay
+ delegate.remove(Object.class.getDeclaredMethod("toString"));
+ delegate.remove(Proxy.class.getDeclaredMethod("toString"));
+ } catch (Throwable e) {
+ // ignore
+ }
+ }
+ }
+ }
+ return delegate;
+ }
+
+}
diff --git a/extensions/bean/runtime/src/main/java/org/apache/camel/quarkus/component/bean/graal/SubstituteBeanInfo.java b/extensions/bean/runtime/src/main/java/org/apache/camel/quarkus/component/bean/graal/SubstituteBeanInfo.java
new file mode 100644
index 0000000..ff966f4
--- /dev/null
+++ b/extensions/bean/runtime/src/main/java/org/apache/camel/quarkus/component/bean/graal/SubstituteBeanInfo.java
@@ -0,0 +1,32 @@
+/*
+ * 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.camel.quarkus.component.bean.graal;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import com.oracle.svm.core.annotate.Alias;
+import com.oracle.svm.core.annotate.RecomputeFieldValue;
+import com.oracle.svm.core.annotate.TargetClass;
+
+@TargetClass(className = "org.apache.camel.component.bean.BeanInfo")
+final class SubstituteBeanInfo {
+
+ @Alias
+ @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ExcludeMethodList.class)
+ private static List<Method> EXCLUDED_METHODS;
+}