From: Sara S. <sar...@gm...> - 2014-05-16 08:50:51
|
Thanks a lot Mikio for informing me with this work around that solved my problem. Best Regards, Sara On Fri, May 16, 2014 at 6:09 PM, Mikio Takeuchi <mik...@gm...>wrote: > Hi, > > I understand the problem. > It looks like the compiler front-end is not strong enough to understand > that this.parentEntryGR at current place is same as this.parentEntryGR at > remote place. > I am not sure but it may due to the field is mutable (var) rather than > val. > GlobalRef can be dereferenced only at the home place. Making it explicit > by using a local variable of different name, we can work around the issue. > > -- Mikio > > package x10.lang; > > public class Entry { > private var name:String; > private var parentEntryGR:GlobalRef[Entry]; > > //constructor for the parent:only the parent has a name > public def this(name:String) { > > this.name = name; > } > > //constructor for the children, just pointing at the parent entry > public def this(parentEntry:GlobalRef[Entry]) { > this.parentEntryGR = parentEntry; > } > > public def printParentEntryName() { > val parentGR = parentEntryGR; > at (parentGR) { > Console.OUT.println(parentGR().name); > } > // or even better > //Console.OUT.println(parentEntryGR.getLocalOrCopy().name); > > } > > public def getParentEntryGR():GlobalRef[Entry] = parentEntryGR; > public def setParentEntryGR(parentGR:GlobalRef[Entry]) > {this.parentEntryGR = parentGR;} > } > > > > 2014-05-16 15:16 GMT+09:00 Sara Salem <sar...@gm...>: > > Thanks a lot Mikio, but I'm afraid that this doesn't solve my problem. I >> get the same result as you when I use x10c++ to compile that code, but my >> problem is that when I add the Entry class to X10's runtime code in this >> path (<X10-SRC-DIR>/x10.runtime/src-x10/x10/lang/Entry.x10) and then try >> to compile X10's source by these commands (*cd **<X10-SRC-DIR>/x10.dist* >> then *ant dist*) I get the mentioned error. >> >> Thank you, >> Sara >> >> >> On Fri, May 16, 2014 at 2:27 PM, Mikio Takeuchi <mik...@gm... >> > wrote: >> >>> Hi, >>> >>> You may need to make Entry class public so that it can be accessible >>> from other packages. >>> Following is the result with trunk r27694. >>> >>> -- Mikio >>> >>> [mtake@mtakex10 sara]$ cat x10/lang/Entry.x10 >>> package x10.lang; >>> >>> public class Entry { >>> >>> private var name:String; >>> private var parentEntryGR:GlobalRef[Entry]; >>> >>> //constructor for the parent:only the parent has a name >>> public def this(var name:String) { >>> this.name = name; >>> } >>> >>> //constructor for the children, just pointing at the parent entry >>> public def this(parentEntry:GlobalRef[Entry]) { >>> this.parentEntryGR = parentEntry; >>> } >>> >>> public def printParentEntryName() { >>> at (parentEntryGR) { >>> Console.OUT.println(parentEntryGR().name); /*Error: Method >>> or static constructor not found for given call.*/ >>> } >>> } >>> >>> public def getParentEntryGR():GlobalRef[Entry] = parentEntryGR; >>> public def setParentEntryGR(var parentGR:GlobalRef[Entry]) >>> {this.parentEntryGR = parentGR;} >>> } >>> [mtake@mtakex10 sara]$ cat TestGlobalRef.x10 >>> >>> //Test class >>> public class TestGlobalRef { >>> public static def main(val args:Rail[String]) { >>> //create the parent entry at place 0 >>> val parentEnt:Entry = new Entry("parent name"); >>> val parentEntGR = GlobalRef[Entry](parentEnt); >>> parentEnt.setParentEntryGR(parentEntGR); >>> for (p in Place.places()) { >>> at (p) { >>> val entry:Entry; >>> if (p.id != parentEntGR.home.id) >>> entry = new Entry(parentEntGR); //create children >>> Entries on other places >>> else >>> entry = at (parentEntGR) {parentEntGR()}; >>> entry.printParentEntryName(); >>> } >>> } >>> } >>> } >>> [mtake@mtakex10 sara]$ x10c TestGlobalRef.x10 >>> x10c: 1 dynamically checked calls or field accesses, run with >>> -VERBOSE_CHECKS for more details. >>> [mtake@mtakex10 sara]$ x10c++ TestGlobalRef.x10 >>> x10c++: 1 dynamically checked calls or field accesses, run with >>> -VERBOSE_CHECKS for more details. >>> [mtake@mtakex10 sara]$ >>> >>> >>> 2014-05-16 12:03 GMT+09:00 Sara Salem <sar...@gm...>: >>> >>>> Hello, >>>> I have a problem with the below Entry class. It compiles correctly >>>> using x10c++, but when I add it to the x10.lang package >>>> (<X10-SRC-DIR>/x10.runtime/src-x10/x10/lang) and try to compile X10 using *ant >>>> dist*, I get an error at the statement when I use the GlobalRef to >>>> access a remote Entry object. *The error is: Method or static >>>> constructor not found for given call.* >>>> >>>> Below is the Entry class, and a main method describing how I use it. >>>> How can I fix this error to get the class compiling as part of x10.lang >>>> package? >>>> >>>> class Entry{ >>>> private var name:String; >>>> private var parentEntryGR:GlobalRef[Entry]; >>>> >>>> //constructor for the parent:only the parent has a name >>>> public def this(var name:String){ >>>> this.name = name; >>>> } >>>> >>>> //constructor for the children, just pointing at the parent entry >>>> public def this(parentEntry:GlobalRef[Entry]){ >>>> this.parentEntryGR = parentEntry; >>>> } >>>> >>>> public def printParentEntryName(){ >>>> at(parentEntryGR) >>>> { >>>> Console.OUT.println(parentEntryGR().name); /*Error: Method or >>>> static constructor not found for given call.*/ >>>> } >>>> } >>>> public def getParentEntryGR():GlobalRef[Entry] = parentEntryGR; >>>> public def setParentEntryGR(var parentGR:GlobalRef[Entry]) >>>> {this.parentEntryGR = parentGR;} >>>> >>>> } >>>> >>>> >>>> //Test class >>>> public class TestGlobalRef { >>>> public static def main(val args:Rail[String]){ >>>> //create the parent entry at place 0 >>>> val parentEnt:Entry = new Entry("parent name"); >>>> val parentEntGR = GlobalRef[Entry](parentEnt); >>>> parentEnt.setParentEntryGR(parentEntGR); >>>> >>>> for (p in Place.places()) >>>> { >>>> at(p) >>>> { >>>> val entry:Entry; >>>> if (p.id != parentEntGR.home.id) >>>> entry = new Entry(parentEntGR); //create children >>>> Entries on other places >>>> else >>>> entry = at (parentEntGR) {parentEntGR()}; >>>> >>>> entry.printParentEntryName(); >>>> } >>>> } >>>> } >>>> } >>>> >>>> Thank you, >>>> Sara >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >>>> Instantly run your Selenium tests across 300+ browser/OS combos. >>>> Get unparalleled scalability from the best Selenium testing platform >>>> available >>>> Simple to use. Nothing to install. Get started now for free." >>>> http://p.sf.net/sfu/SauceLabs >>>> _______________________________________________ >>>> X10-core mailing list >>>> X10...@li... >>>> https://lists.sourceforge.net/lists/listinfo/x10-core >>>> >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >>> Instantly run your Selenium tests across 300+ browser/OS combos. >>> Get unparalleled scalability from the best Selenium testing platform >>> available >>> Simple to use. Nothing to install. Get started now for free." >>> http://p.sf.net/sfu/SauceLabs >>> _______________________________________________ >>> X10-core mailing list >>> X10...@li... >>> https://lists.sourceforge.net/lists/listinfo/x10-core >>> >>> >> >> >> ------------------------------------------------------------------------------ >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> Instantly run your Selenium tests across 300+ browser/OS combos. >> Get unparalleled scalability from the best Selenium testing platform >> available >> Simple to use. Nothing to install. Get started now for free." >> http://p.sf.net/sfu/SauceLabs >> _______________________________________________ >> X10-core mailing list >> X10...@li... >> https://lists.sourceforge.net/lists/listinfo/x10-core >> >> > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. > Get unparalleled scalability from the best Selenium testing platform > available > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > X10-core mailing list > X10...@li... > https://lists.sourceforge.net/lists/listinfo/x10-core > > |