Uploaded image for project: 'Cocoon'
  1. Cocoon
  2. COCOON-1169

issue with javaflow continuations

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.5
    • None
    • Blocks: Java Flow
    • None
    • Operating System: All
      Platform: All
    • 29308

    Description

      hi,

      i rewrote SimpleFlow.java testcase to try out returning of objects in java
      continuations like below (attached). I am getting a exception when i execute the
      test case :

      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at
      org.apache.cocoon.components.flow.java.test.FlowTest.testSimple(FlowTest.java:117)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source)
      Caused by: java.lang.IllegalAccessError: tried to access class
      org.apache.cocoon.components.flow.java.test.FooInner from class
      org.apache.cocoon.components.flow.java.test.SimpleFlow
      at org.apache.cocoon.components.flow.java.test.SimpleFlow.foo(SimpleFlow.java:42)
      at org.apache.cocoon.components.flow.java.test.SimpleFlow.run(SimpleFlow.java:46)
      ... 23 more






      package org.apache.cocoon.components.flow.java.test;

      import org.apache.cocoon.components.flow.java.*;
      import org.apache.cocoon.forms.FormContext;
      import java.util.Locale;
      class FooInner {
          public FooInner(int i, int j) {

          }
      }

      public class SimpleFlow extends AbstractSimpleFlow {

          public SimpleFlow() {
              if (Continuation.currentContinuation() != null)
                  throw new RuntimeException("Conitnuation should not exist");
              //sendPageAndWait("should not stop");
          }
          public FooInner foo() {
              float a = 1;
              sendPageAndWait("getNumberA");
              System.out.println("old a=" + a);
              a = Float.parseFloat(getRequest().getParameter("a"));
              System.out.println("a=" + a);
              sendPage("result", new VarMap().add("result", a + 1));
              System.out.println("end of flow");
              return new FooInner(12,12);
          }
          public boolean run() {
              System.out.println("start of flow");
              Object res = foo();
              System.out.println("Result of foo is " + res);
              return true;
          }

          public void testNew(Locale locale) {
              FormContext formContext = new FormContext(getRequest(), locale);
          }

          public void testCatch() {
              try {
                  sendPageAndWait("getNumberA");
                  float a = Float.parseFloat(getRequest().getParameter("a"));
              } catch (NumberFormatException nfe) {
                  sendPageAndWait("error");
              }
              sendPage("result");
          }

          public void testFinally() {
              try {
                  sendPageAndWait("getNumberA");
                  float a = Float.parseFloat(getRequest().getParameter("a"));
              } finally {
                  sendPageAndWait("result");
              }
          }

          public void testEmpty() {
              //nothing
          }

          public void testAbstract() {
              super.parent();
          }

          public void testDelegate() {
              CalculatorFlow flow = new CalculatorFlow();
              flow.run();
          }
      }



      I checked the sourcecode generated out of the continuationclassloader and it
      seems to be ok. not sure why it is giving this error. The sourcecode (decompiled
      using jad tool) says

              System.out.println("end of flow");
              12;
              continuationstack.pushInt(12);
              continuationstack;
              JVM INSTR swap ;
              pushInt();
              return new FooInner(continuationstack.popInt(), continuationstack.popInt());

      Attachments

        Activity

          People

            Unassigned Unassigned
            dustbin777@yahoo.com tester
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: