I was trying to use the rife continuations package to develop a simple
java example and came across a small problem.
I was trying to use a continuation to code a simple recursiveTower of
Hanoi program. Something akin to the wki example here
http://en.wikipedia.org/wiki/Tower_of_Hanoi.
I replaced the move with a pause() to break out of the recursion
hanoi(disks,...)
{
if(disks > 0)
{
hanoi(disks-1,...);
pause("Moving disk " ...);
hanoi(disks-1, ....);
}
}
When I do this it breaks out at the continuation, but upon reentry it
cauces a stack overflow problem. I am using an older version of the
rife continuaitons jar.
Any help would be greatly appreciated.
Cheers
first, which version of RIFE/Continuations are you using?
Also, would you mind attaching the actual source code that you're
using so that it can be run in a very easy fashion. If there is a
problem, this drastically reduces the time to figure it out.
Thanks,
Geert
--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com
I'll look at this later, but I strongly recommend that you try with
the latest version of RIFE/Continuations, and maybe even one of the
nightly builds. Most of RIFE's development lately has gone to the
standalone continuations lib.
Best regards,
Geert
> <jcon.jar.gz>
why are you not simply using the JDK 1.4 version of RIFE/Continuations?
You can download it here. This should just work, no need to do
retroweaver yourself or anything.
http://rifers.org/downloads/#rifecontinuations
Let me know how it goes.
Geert
On 08 Nov 2007, at 03:07, Frederick Isaac wrote:
> Hi Geert,
>
I just committed a fix for this and in my local testing it should
work. The JDK 1.4 jar was badly built. Please try this version and
tell me how it works out for you:
Best regards,
Geert
On 08 Nov 2007, at 10:17, Frederick Isaac wrote:
> I was originally using the 1.4 version of Rife with my JDK 1.4 and
> that was when the error I received was
>
> java.lang.NoSuchMethodError
> at
> com
> .uwyn
> .rife
> .continuations
> .ContinuationContext.clearActiveContext(ContinuationContext.java:114)
> at
> com
> .uwyn
> .rife
> .continuations
> .basic.BasicContinuableRunner.run(BasicContinuableRunner.java :227)
> at
> com
> .uwyn
> .rife
> .continuations
> .basic.BasicContinuableRunner.start(BasicContinuableRunner.java:87)
> at TestPause.testPause(TestPause.java:20)
> at mainTest.main(mainTest.java:13)
>
>
Hi Frederick,
I just committed a fix for this and in my local testing it should
work. The JDK 1.4 jar was badly built. Please try this version and
tell me how it works out for you:
http://rifers.org/downloads/rife/snapshots/rife-1.6.2-snapshot-20071108/rife-continuations-1.6.2-snapshot-jdk14-20071108.jar
Best regards,
Geert
On 08 Nov 2007, at 10:17, Frederick Isaac wrote:
> I was originally using the 1.4 version of Rife with my JDK 1.4 and
> that was when the error I received was
>
> java.lang.NoSuchMethodError
> at
> com
> .uwyn
> .rife
> .continuations
> .ContinuationContext.clearActiveContext(ContinuationContext.java:114)
> at
> com
> .uwyn
> .rife
> .continuations
> .basic.BasicContinuableRunner.run( BasicContinuableRunner.java :227)
> at
> com
> .uwyn
> .rife
> .continuations
> .basic.BasicContinuableRunner.start(BasicContinuableRunner.java:87)
> at TestPause.testPause (TestPause.java:20)
> > at TestPause.testPause (TestPause.java:20)
I wanted to be sure, but it looks to me actually that you have a
classpath issue. Are you sure that you have no classes lingering
around from the version that you compiled yourself, or maybe an older
RIFE/Continuations jar? Are you maybe mixing an old full RIFE jar with
a new RIFE/Continuations jar. I'm thinking this because the method
that is missing is really not there with that argument, and
BasicContinuableRunner doesn't call it with that at all.
> <fail.jar>
sorry for these problems, JDK 1.4 support is something that I haven't
really tested in a while since there wasn't much demand for it
anymore. I made some bugfixes and added a dedicated test run to the
ant build to ensure that the testsuite for RIFE/Continuations compiles
and runs without JDK 1.4.
You can download the latest jar here:
Let me know how it goes.
Take care,
Geert
On 10 Nov 2007, at 03:07, Frederick Isaac wrote:
> Hi,
>
> I just ran again with a different option and got the following error
>
> java.lang.NoSuchMethodError: java.lang.ThreadLocal: method remove()V
> not found
> at
> com
> .uwyn
> .rife
> .continuations
> .ContinuationContext.clearActiveContext(ContinuationContext.java:112)
> at
> com.uwyn.rife.continuations.basic.BasicContinuableRunner.run
> (BasicContinuableRunner.java:225)
> at
Thank you very much for looking into this and continuing to support 1.4.
I appreciate it very much.
Do you have any plans to post the source for 1.4 along with the 1.6 source?
Anyway I can now try my recursive tower of Hanoi with continuations.
I hope it works so I can try some more complicated recursive work.
I like the new features of the 1.6 api. I am looking forward to using them
Cheers again
Freddy
Cool, glad it worked this time.
> Do you have any plans to post the source for 1.4 along with the 1.6
> source?
It's all the same source repository. So yeah, it is now already
available from SVN.
> Anyway I can now try my recursive tower of Hanoi with continuations.
> I hope it works so I can try some more complicated recursive work.
Let me know how it works, I'll help you track down problems if you run
into them.
Take care,
Geert
> I have determined that it only works if I run under 1.4 with the -
> classic option, otherwise it crashes the jvm and forces a core
> dumped which is stopped in an infinite loop. Bug in the jvm or some
> other problem? I didn't experience this under the earlier rife 1.4
> always run with JDK1.4 hotspot no problems.
This is certainly a JDK bug, core dumps always are. However, it could
be that some byte-code instructions causes this bug to create a
segfault instead of having proper error messages for this. There are
several ways to track this down, the easiest is to try to run the same
code on another JDK or even a later version, just to see if that
works. you can also try to reproduce the segfault with the smallest
possible class. If you send me that, I can look at the byte code to
see what could be the cause and maybe figure out a workaround.
> How can the execute method of the class with the continuation be
> made anything other than static. It seems to throw an exception if
> this is the case.
What is the exception? The execute method should actually not be static.
> Can the execute method be passed parameters?
Yes it can, set this up with the http://rifers.org/docs/api/com/uwyn/rife/continuations/ContinuationConfigInstrument.htmlclass
. You'll have to write the proper runner logic to provide the
arguments to the entry method. The easiest way to do this is by
extending BasicContinuableRunner and overridding the
executeContinuable method.
Hope this helps,
Geert
Is it possible for you to upgrade?
Maybe search the bug database with more detailed information from the
core dump itself, there could be a similar issue with possibly a fix/
workaround.
On 22 Nov 2007, at 09:10, Frederick Isaac wrote:
> Hi again,
>
> The core dump is a SIGBUS. On my platform this generally means that
> there are too many mappings to a page.
> I do have access to another JDK 1.4 as it requires another platform
> which would be AIX. As soon as I have tested I will confirm with you.
>
> Sorry I didn't mean to gie the impression that the execute method
> was static. I meant to ask if the inner class which contains the
> execute method is required to be static. If not I get the exception
>
> java.lang.InstantiationException: TestPause$innerPauseInWhile
> at java.lang.Class.newInstance0(Class.java:291)
> at java.lang.Class.newInstance(Class.java:259)
> at
> com
> .uwyn
> .rife
> .continuations
> .basic.BasicContinuableRunner.run(BasicContinuableRunner.java :172)
> at
> com
> .uwyn
> .rife
> .continuations
> <simple_example.jar>
this is normal since the basic continuations runner uses the default
constructor to create a new instance of each continuation class. If
this is a non static inner class, this can't be done.
HTH,
Geert
> Sorry I didn't mean to gie the impression that the execute method
> was static. I meant to ask if the inner class which contains the
> execute method is required to be static. If not I get the exception
>
> java.lang.InstantiationException: TestPause$innerPauseInWhile
> at java.lang.Class.newInstance0(Class.java:291)
> at java.lang.Class.newInstance(Class.java:259)
> at
> com
> .uwyn
> .rife
> .continuations
> .basic.BasicContinuableRunner.run(BasicContinuableRunner.java :172)
> at
> com
> .uwyn
> .rife
> .continuations
> <simple_example.jar>