So I have a possibly interesting issue. I'm using...
# spring
m
So I have a possibly interesting issue. I'm using @Around advice to call some legacy code which eventually ends up calling new functionality implemented in Kotlin. I use the proceeding join point in the advice to get an array of the args java classes. The method with the around advice is called with a non-nullable boolean but the java class of the argument in ProceedingJoinPoint is java.lang.Boolean. The legacy code then calls a service method written in Kotlin using Class.getMethod(String name, Class<?>... parameterTypes). The problem is that the Kotlin service method has a non-nullable Boolean in it's signature which means it's the primitive type in Java but in the aspect the Java class is java.lang.Boolean. This causes getMethod to fail since it can't find a method matching the signature. Anyone have any ideas on this one? Does this seem like something going on with Spring AOP or something entirely different?
Copy code
fun updateEnrollment(enroll: Boolean) {
  // The method with the around advice is called with what should be a primitive boolean since it's not nullable
  service.updateEnrollment(enroll)
}
Copy code
@Around(value = "@annotation(replicate)")
fun wrapCall(pjp: ProceedingJoinPoint, replicate: Replicate) {
  val args = pjp.args
  // it.javaClass returns java.lang.Boolean instead of the primitive type
  val argClass = pjp.args.map { it.javaClass }.toTypedArray()
  ...
}
Copy code
// getMethod fails because the type is java.lang.Boolean but the method signature is a boolean primitive
service.getClass().getMethod(methodName, types);