Hi,

X10 code only runs with X10 thread, so you need to set up X10
environment before calling it.

Currently we don't have public APIs to do that. Only way to call X10
from Java is implementing main class in X10 and call Java main method
with reflection.  You can find some examples in
samples/java.interop/{runjava,javatox10} directories.

Your code may run as expect with this technique, however there should
be many X10 and Java code which interact badly. This is due to the
difference of concurrency model in the both languages, so we basically
don't recommend calling parallel X10 code from Java (and vice versa).

Also please understand that Java interoperability feature in Managed
X10 is still in technical preview state and thus subject to change in
future releases.

Regards,

Mikio Takeuchi
IBM Research - Tokyo

2012/4/11 天上最亮的星 <sixiangma0...@foxmail.com>:
> x10 class A:
> public class A{
>       public static def funA(args: Array[String](1)) {
>           x10.io.Console.OUT.println("A");
>      }
>  }
>
> x10 class B:
> public class B{
>      public static def funB(args: Array[String](1)) {
>        async x10.io.Console.OUT.println("B");
>    }
> }
>
> I jar the two X10 classes as A.jar and B.jar, and then I added these two
> jars into a Java program.Also,I added x10.runtime.xxx.jar.
> I called the method A.funA(), it is ok.
> But when I called the method B.funB(), it cannot work. The following is what
> the console showed.
>
> Unable to load x10rt_sockets. Forcing single place execution
> Exception in thread "main" java.lang.StackOverflowError
> at x10.runtime.impl.java.Thread$1.initialValue(Thread.java:1)
> at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:160)
> at java.lang.ThreadLocal.get(ThreadLocal.java:150)
> at x10.runtime.impl.java.Thread.currentThread(Thread.java:46)
> at x10.lang.Runtime.home(Runtime.java:1809)
> at x10.lang.Runtime.hereInt$O(Runtime.java:1819)
> at
> x10.lang.FinishState.getInitialized$UNCOUNTED_FINISH(FinishState.java:9095)
> at x10.lang.Runtime$Worker.<init>(Runtime.java:774)
> at x10.lang.Runtime$Pool.wrapNativeThread(Runtime.java:1441)
> at x10.lang.Runtime.wrapNativeThread(Runtime.java:2934)
> at x10.runtime.impl.java.Thread$1.initialValue(Thread.java:41)
> .
> .  (it's very long , and it is a loop of a same problem)
> .
> .
> at x10.runtime.impl.java.Thread$1.initialValue(Thread.java:1)
> at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:160)
> at java.lang.ThreadLocal.get(ThreadLocal.java:150)
> at x10.runtime.impl.java.Thread.currentThread(Thread.java:46)
> at x10.lang.Runtime.home(Runtime.java:1809)
> at x10.lang.Runtime.hereInt$O(Runtime.java:1819)
> at
> x10.lang.FinishState.getInitialized$UNCOUNTED_FINISH(FinishState.java:9095)
> at x10.lang.Runtime$Worker.<init>(Runtime.java:774)
> at x10.lang.Runtime$Pool.wrapNativeThread(Runtime.java:1441)
> at x10.lang.Runtime.wrapNativeThread(Runtime.java:2934)
> at x10.runtime.impl.java.Thread$1.initialValue(Thread.java:41)
>
> It seems it's ok to call X10 code from java without x10's
> concurrency feature , but when using X10's concurrency feature , it cannot
> work.
> Or is there any configuration i missed?
> Can you give me some advices, Or is it impossible to call X10 from Java
> project?
>
>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to