Skip to content

Commit

Permalink
Fix Spring 6.1.x native support
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Dec 5, 2023
1 parent 4cad7b7 commit 72ff45d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ void generateKotlinReflectClasses(
createClass(generatedClass, "kotlin.reflect.KParameter", Object.class.getName(), true);
createClass(generatedClass, "kotlin.reflect.KCallable", Object.class.getName(), false);
createClass(generatedClass, "kotlin.reflect.KFunction", "kotlin.reflect.KCallable", false);
createClass(generatedClass, "kotlin.reflect.KAnnotatedElement", Object.class.getName(), false);
createClass(generatedClass, "kotlin.reflect.KClass", "kotlin.reflect.KAnnotatedElement", false);
createClass(generatedClass, "kotlin.text.Regex", Object.class.getName(), false);
createClass(generatedClass, "kotlin.coroutines.CoroutineContext$Key", Object.class.getName(), false);
createClass(generatedClass, "kotlinx.coroutines.Job$Key", "kotlin.coroutines.CoroutineContext$Key", false);
}

private boolean isKotlinStdlibAvailable(ApplicationModel applicationModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
package org.apache.camel.quarkus.support.spring.graal;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.function.BooleanSupplier;

import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.Substitute;
Expand All @@ -44,13 +47,32 @@ public static boolean isKotlinReflectPresent() {
public static boolean isKotlinType(Class<?> clazz) {
return false;
}

@Substitute
public static boolean isSuspendingFunction(Method method) {
return false;
}
}

@TargetClass(className = "org.springframework.core.KotlinReflectionParameterNameDiscoverer")
@Delete
final class SubstituteKotlinReflectionParameterNameDiscoverer {
}

@TargetClass(className = "org.springframework.beans.BeanUtils$KotlinDelegate")
final class SubstituteBeanUtilsKotlinDelegate {
@Substitute
public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz) {
throw new UnsupportedOperationException("Kotlin is not supported");
}

@Substitute
public static <T> T instantiateClass(Constructor<T> ctor, Object... args)
throws IllegalAccessException, InvocationTargetException, InstantiationException {
throw new UnsupportedOperationException("Kotlin is not supported");
}
}

@TargetClass(className = "org.springframework.core.MethodParameter$KotlinDelegate")
final class SubstituteMethodParameterKotlinDelegate {
@Substitute
Expand All @@ -68,3 +90,23 @@ private static Class<?> getReturnType(Method method) {
throw new UnsupportedOperationException("Kotlin is not supported");
}
}

@TargetClass(className = "org.springframework.aop.support.AopUtils$KotlinDelegate", onlyWith = SpringAopPresent.class)
final class SubstituteAopUtilsKotlinDelegate {
@Substitute
public static Object invokeSuspendingFunction(Method method, Object target, Object... args) {
throw new UnsupportedOperationException("Kotlin is not supported");
}
}

final class SpringAopPresent implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
try {
Thread.currentThread().getContextClassLoader().loadClass("org.springframework.aop.support.AopUtils");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}
1 change: 0 additions & 1 deletion extensions-support/spring/shade/beans/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
</includes>
<excludes>
<exclude>org/springframework/beans/factory/groovy/**</exclude>
<exclude>org/springframework/beans/BeanUtils$Kotlin*</exclude>
</excludes>
</filter>
</filters>
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/jta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@


<profiles>
<!-- https://github.com/apache/camel-quarkus/issues/5583 -->
<!--<profile>
<profile>
<id>native</id>
<activation>
<property>
Expand All @@ -115,7 +114,7 @@
</plugin>
</plugins>
</build>
</profile> -->
</profile>
<profile>
<id>virtualDependencies</id>
<activation>
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/spring-rabbitmq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@
</dependencies>

<profiles>
<!-- https://github.com/apache/camel-quarkus/issues/5583 -->
<!--<profile>
<profile>
<id>native</id>
<activation>
<property>
Expand All @@ -106,7 +105,7 @@
</plugin>
</plugins>
</build>
</profile> -->
</profile>
<profile>
<id>virtualDependencies</id>
<activation>
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/sql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@


<profiles>
<!-- https://github.com/apache/camel-quarkus/issues/5583 -->
<!--<profile>
<profile>
<id>native</id>
<activation>
<property>
Expand Down Expand Up @@ -137,7 +136,7 @@
</plugin>
</plugins>
</build>
</profile> -->
</profile>
<profile>
<id>virtualDependencies</id>
<activation>
Expand Down

0 comments on commit 72ff45d

Please sign in to comment.