Mohammed, What Yoav said is correct in general, but in this particular case, you have a method whose parameters are both accessible in all places (global), but you are invoking it as a local method on the current object. The compiler inserts a cast for you because it thinks that myPrint can only be invoked in the place where the object lives. Since you are not really accessing any local state in the object, you can make the myPrint method global (instead of static), and it should work too.
A good rule of thumb when you get ClassCastExceptions at runtime is to recompile your code with -STATIC_CALLS and let the compilation errors guide you to the fix. Hope this helps, Igor mohammed elsaeedy <mohammed.elsae...@kaust.edu.sa> wrote on 07/06/2010 09:28:44 AM: > Dear Yoav, > > > Thank you for your concern, here's the simple code I used: > * > public class Hello > { > > public static def main(var args: Rail[String]!) { > val h = new Hello(); > val R:Region= [0..10]; > val D:Dist(1)=Dist.makeBlock(R); > val a :DistArray[int](1) =DistArray.make[int](D, ((i):Point)=>i); > > Console.OUT.println("NUm of children " +Place.numChildren(here.id)); > finish ateach((i):Point in a.dist()) > { > h.myPrint(a,i); > } > } > > public static def myPrint(a:DistArray[int](1),i:Int) > { > Console.OUT.println("a("+i+"): " +a(i)+" at Place: "+here.id); > } > > }* > > So basically if I removed the static keyword in the method, and I ran the > application over only one process, it works just fine, > but if I increase the number of processes, for example 2 processes, > it would print those at place 0 but when it tries to print those at place 1 > it gives me the following exception > > *Uncaught exception at place 0: x10.lang.MultipleExceptions (home==1) > x10.lang.ClassCastException (home==1): Hello{self.home==here} > at x10::lang::Throwable::fillInStackTrace() > at x10aux::throwException(x10aux::ref<x10::lang::Throwable>) > at Hello__closure__2::apply() > at x10::lang::Activity::run() > at x10_lang_Runtime__Worker__closure__0::apply() > at x10::lang::Runtime::runAtLocal(int, > x10aux::ref<x10::lang::VoidFun_0_0>) > at > x10::lang::Runtime__Worker::loop(x10aux::ref<x10::lang::Runtime__Latch>, > bool) > at x10::lang::Runtime__Worker::apply() > at x10_lang_Runtime__Pool__closure__0::apply() > at x10::lang::Thread::thread_start_routine(void*) > at GC_inner_start_routine > at GC_call_with_stack_base > at GC_start_routine > at > at clone > > *I think* *because place 1 is trying to access the method which is at place > 0, am I correct? > > > Thank you again. > > On Mon, Jul 5, 2010 at 1:01 PM, Yoav Zibin <yoav.zi...@gmail.com> wrote: > > > could you email me the working version (with *static*), and then the > > non-working version if it is non-static? > > Feel free to also submit Jira items (http://jira.codehaus.org/) to the X10 > > project. > > > > On Sun, Jul 4, 2010 at 11:48 AM, mohammed elsaeedy < > > mohammed.elsae...@kaust.edu.sa> wrote: > > > > > Dear Yoav, > > > > > > > > > Thank you very much, you were right I forgot to put the braces in the > > > for loop (i:Point)--->(*(i)*:Point), when I ran it, I got thrown > > exceptions > > > so I guessed that was because of non-authorized memory accesses so I > > > changed > > > the definition of the function to *static*, and it worked pretty well. > > > Do you have a more detailed explanation? > > > > > > Thank you again Yoav. > > > > > > On Sun, Jul 4, 2010 at 11:21 AM, Yoav Zibin <yoav.zi...@gmail.com> > > wrote: > > > > > > > This error complains about the second Int parameter > > > > > > > > On Sunday, July 4, 2010, mohammed elsaeedy > > > > <mohammed.elsae...@kaust.edu.sa> wrote: > > > > > Dear Yoav, > > > > > > > > > > > > > > > The compiler should be able to infer that my array "a" is of one > > > > > dimension, and I tried your proposal, and it gave me an error too > > > > > > > > > > > > > > > "*Method myPrint(a: > > > > > x10.array.DistArray[x10.lang.Int]{self.dist.region.rank==1}, > > > > > i: x10.lang.Int) in Hello{self==h, h.home==_place17626731, h!=null} > > > > cannot > > > > > be called with arguments (x10.array.DistArray[x10.lang.Int]{self==a, > > > > > a.dist.region.rank==1}, x10.array.Point{self==i}); Invalid Parameter. > > > > > expected type: x10.lang.Int > > > > > found: x10.array.Point{self==i} *" > > > > > > > > > > I think the problem is in "*self==a*". Am I missing something? > > > > > > > > > > Thank you. > > > > > Regards, > > > > > Mohammed > > > > > > > > > > > > > > > On Sun, Jul 4, 2010 at 10:26 AM, Yoav Zibin <yoav.zi...@gmail.com> > > > > wrote: > > > > > > > > > >> The parameter is of type > > > > >> > > > > >> DistArray[int](1) > > > > >> While the argument is > > > > >> > > > > >> DistArray[int] > > > > >> > > > > >> Thanks, > > > > >> Yoav Zibin > > > > >> > > > > >> On 04/07/2010, at 09:14, mohammed elsaeedy < > > > > mohammed.elsae...@kaust.edu.sa > > > > >> > wrote: > > > > >> > > > > >> > DistArray[int](1) -- Igor Peshansky (note the spelling change!) IBM T.J. Watson Research Center X10: Parallel Productivity and Performance (http://x10-lang.org/) XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/) "I hear and I forget. I see and I remember. I do and I understand" -- Confucius ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users