Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93A7996A7 for ; Thu, 7 Jun 2012 04:59:00 +0000 (UTC) Received: (qmail 84357 invoked by uid 500); 7 Jun 2012 04:58:59 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 84253 invoked by uid 500); 7 Jun 2012 04:58:59 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 84235 invoked by uid 99); 7 Jun 2012 04:58:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 04:58:59 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rsankarx@gmail.com designates 209.85.161.171 as permitted sender) Received: from [209.85.161.171] (HELO mail-gg0-f171.google.com) (209.85.161.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 04:58:53 +0000 Received: by ggmi1 with SMTP id i1so166208ggm.30 for ; Wed, 06 Jun 2012 21:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=SeQxgaziFUajgTk0qclrx4HrAZWEtnW9nr/mu3NvPl0=; b=ZR2EnEu3ZZ9GsShafFnzZOHGbLF405NDayvY0DJHaS/iiWXXT18m7mWV3/GiUNBuGw +5/6KqBP5Jp52IBfRkUHwVEH8i+C/zJfbcDu5yfh3VupGm35YhrFGzg0lntIFfXW4HTu cAtR79qWZ9mZYAFeC5x3WWZA2HfcvuJXwAklbQlKFbrc8vPGU9R/L5i9m2dBicPxFDdq ps0TA6rLT+/P/sZ3bRt+tnMTVD/3ARhEaZoAhazwa6PnFM/AGSVRovLRO7aK4E5YfV2n qAcrEQwkzGTFePWYyKpqj0W9s5df4Id3Ww4M1ogvjHKc8zL7Tc3StV9jHYELT08Vqokq 4aXw== MIME-Version: 1.0 Received: by 10.101.143.32 with SMTP id v32mr219984ann.42.1339045112646; Wed, 06 Jun 2012 21:58:32 -0700 (PDT) Received: by 10.100.129.18 with HTTP; Wed, 6 Jun 2012 21:58:32 -0700 (PDT) Date: Thu, 7 Jun 2012 10:28:32 +0530 Message-ID: Subject: [javaflow] Need help in fixing a problem in javaflow From: Raji Sankar To: dev@commons.apache.org Content-Type: multipart/alternative; boundary=0016e68e802b470be804c1dabcfe X-Virus-Checked: Checked by ClamAV on apache.org --0016e68e802b470be804c1dabcfe Content-Type: text/plain; charset=ISO-8859-1 > Hi, > > I am using javaflow in one of my project to get the continuation > functionality. I have hit a situation in which I need to call a function > using reflection which potentially can call suspend. (changing this, removes > a few functionality that is already present, hence before changing I want to > be sure I have tried everything). I have attached a sample test that > fails(compilerun.sh runs it, jar paths have to be changed here). > > On a high level, I have some fn which has a code as below: > > private void callsomeshared() > throws Exception > { > Method mthd = _someShared.getDeclaredMethod("doSomething"); > int cnt = 0; > while (cnt < 10) > { > mthd.invoke(_shared); > //Continuation.suspend(); > cnt++; > } > } > > The doSomething does this: > public boolean doSomething() > throws Exception > { > if (_shared.value() < 10) > { > _shared.echo(); > Continuation.suspend(); > } > > return (_shared.value() < 10); > } > > Doing this, fails with a ClassCastException, since when it hits the > Method.invoke, it is potentially popping out the AnotherLoader class and > does not have the Method class pushed. I am wondering is it possible that in > the push and pops added in the callsomeshared method, if the call is a > Method.invoke along with the pushReference for this object, we also push the > reference and the parameters of the Method.invoke, so that when the > method.invoke is called again, it potentially acts as if it is a new call to > the reflection method, but the reflection method has the push/pop BCI'ed and > hence will get handled correctly?? > > I have tried the following:- (I am using asm for BCI) > In the ContinuationMethodAdapter, in the function visitMethodInsn I have > added the following code: > //RS: > if (name.equals("invoke") && > owner.startsWith("java/lang/reflect/Method")) > { > System.out.println("method:" + stackRecorderVar + ":" + > name + ":" + owner + ":" + desc + ":"); > mv.visitVarInsn(ALOAD, stackRecorderVar); > mv.visitVarInsn(ALOAD, 1); > mv.visitMethodInsn(INVOKEVIRTUAL, STACK_RECORDER, > PUSH_METHOD + "Reference", "(Ljava/lang/Object;)V"); > } > //RS: > before the existing pushReference call. Seems to pop and work, but, > obviously there are problems here: > 1) Currently I have hardcoded the method variable as ALOAD_1, how can I get > which one is this? > 2) The arguments are not pushed and hence when the method invoke is called > during continuation, it is giving me a NullPointerException. > > Can you help me how these two can be got, so I can try if this idea will > work for reflection calls? > > Thanx > Rgds > Raji .S. > > --0016e68e802b470be804c1dabcfe--