Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-6588

error while execute java function node

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • None
    • 7.59.0.Final
    • dmn engine
    • None
    • Hide

      you can reproduce the problem by test code below.

       

      public static void main(String[] args) throws Exception {
      Class clazz = Person.class;
      Method method = clazz.getMethod("getName", null);

      JavaFunction javaFunction = new JavaFunction("person", new LinkedList<>(), clazz, method);
      EvaluationContext evaluationContext = new EvaluationContextImpl(clazz.getClassLoader(), new FEELEventListenersManager());

      Either<FEELEvent, Object> result = javaFunction.invoke(evaluationContext, new Object[]{});
      result.consume(System.out::println, System.out::println);
      }

      public static class Person {

      public String getName()

      { return "test"; }

      }

      Show
      you can reproduce the problem by test code below.   public static void main(String[] args) throws Exception { Class clazz = Person.class; Method method = clazz.getMethod("getName", null); JavaFunction javaFunction = new JavaFunction("person", new LinkedList<>(), clazz, method); EvaluationContext evaluationContext = new EvaluationContextImpl(clazz.getClassLoader(), new FEELEventListenersManager()); Either<FEELEvent, Object> result = javaFunction.invoke(evaluationContext, new Object[]{}); result.consume(System.out::println, System.out::println); } public static class Person { public String getName() { return "test"; } }
    • NEW
    • NEW

    Description

      I create a dmn by business modeler desktop. And got a "object is not an instance of declaring class" error while execute java function.

       

      Looking into org.kie.dmn.feel.runtime.functions.JavaFunction#invoke(EvaluationContext,Object[]), i think there may be some thing wrong  in line 68: 

      Object result = method.invoke( clazz, actualParams );

       

      I think,the first parameter of java.lang.reflect.Method#invoke(Object,Object...) may should be an instance of Class rather than the class it self?

      Attachments

        Activity

          People

            mmortari@redhat.com Matteo Mortari
            laining.ln ning lai (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: