NitorCreations/nflow

Support generics in Mutable StateVars

eputtone opened this issue · 0 comments

If I use generics in Mutable StateVars:

      @StateVar(value = "hoplaa", readOnly = true) Mutable<Map<Integer, Integer>> hoplaa,

I get the following error in startup:

Caused by: java.lang.ClassCastException: class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to class java.lang.Class (sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl and java.lang.Class are in module java.base of loader 'bootstrap')
	at io.nflow.engine.internal.workflow.WorkflowDefinitionScanner.lambda$getStateMethods$0(WorkflowDefinitionScanner.java:72) ~[nflow-engine-7.4.0.jar:na]
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:367) ~[spring-core-5.3.20.jar:5.3.20]
	at io.nflow.engine.internal.workflow.WorkflowDefinitionScanner.getStateMethods(WorkflowDefinitionScanner.java:56) ~[nflow-engine-7.4.0.jar:na]
	at io.nflow.engine.workflow.definition.AbstractWorkflowDefinition.<init>(AbstractWorkflowDefinition.java:55) ~[nflow-engine-7.4.0.jar:na]
	at io.nflow.engine.workflow.definition.AbstractWorkflowDefinition.<init>(AbstractWorkflowDefinition.java:40) ~[nflow-engine-7.4.0.jar:na]
	at io.nflow.engine.workflow.definition.WorkflowDefinition.<init>(WorkflowDefinition.java:37) ~[nflow-engine-7.4.0.jar:na]
	at fi.mybusiness.workflow.MyWorkflow.<init>(MyWorkflow.java:105) ~[main/:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211) ~[spring-beans-5.3.20.jar:5.3.20]
	... 65 common frames omitted

Observed using OpenJDK 11.0.15.