From: Mikio T. <mik...@gm...> - 2014-05-16 04:27:54
|
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 > > |