This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.eclipse.jetty:jetty-webapp:9.3.0.M1') | |
@Grab('net.servicegrid:jp.go.nict.langrid.servicecontainer:1.0.6') | |
import jp.go.nict.langrid.servicecontainer.handler.annotation.Service; | |
import jp.go.nict.langrid.servicecontainer.handler.jsonrpc.servlet.JsonRpcServlet; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.webapp.WebAppContext; | |
public interface TestService{ | |
int f(int n); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.arnx.jsonic.JSON; | |
import org.jsonman.Node; | |
import org.jsonman.NodeFactory; | |
import org.jsonman.NodeFinder; | |
import org.jsonman.node.MapNode; | |
import org.junit.Assert; | |
import org.junit.Test; | |
public class NodeFinderTest{ | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.fluentd.logger.FluentLogger; | |
public class FluentLoggerTest { | |
public static class Log{ | |
public Log(String name, String msg){ | |
this.name = name; | |
this.msg = msg; | |
} | |
public String getName() { | |
return name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MethodInvoker{ | |
public static Object invoke( | |
Object instance, String methodName, Object... args) | |
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException{ | |
Class<?> clazz = instance.getClass(); | |
Class<?>[] argTypes = new Class<?>[args.length]; | |
for(int i = 0; i < args.length; i++){ | |
argTypes[i] = args[i].getClass(); | |
} | |
try{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Method; | |
public class InvokeSafely{ | |
public static Object invokeSafely(Object obj, String method) throws Throwable{ | |
Class<?> c = obj.getClass(); | |
Method m = c.getMethod(method); | |
try{ | |
return m.invoke(obj); | |
} catch(IllegalAccessException e){ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pkg2; | |
public class Invoker{ | |
public static void invoke(Runnable instance) throws Exception{ | |
instance.run(); // ok | |
instance.getClass().getMethod("run").invoke(instance); // ng, IllegalAccessException | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kawa.standard.Scheme; | |
public class InvokeJavaFromScheme { | |
public static void main(String[] args) throws Throwable{ | |
Scheme s = Scheme.getInstance(); | |
// objにRunnableを実装した匿名クラスのインスタンスを設定。 | |
// runメソッドはRunnableインタフェースのメソッドだから、問題なく呼べるはず。 | |
s.define("obj", new Runnable(){ | |
public void run() { | |
System.out.println("hello"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* tp は Executors.newCachedThreadPool 等を使って生成 | |
*/ | |
// Rhino(JavaScript) | |
tp.submit(new Callable({call: function(){ return 1;}})); | |
// Groovy | |
tp.submit({1} as Callable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scalatest; | |
import java.io.File; | |
import scala.tools.nsc.Settings; | |
import scala.tools.nsc.interpreter.IMain; | |
import scala.tools.nsc.interpreter.NamedParamClass; | |
public class ScalaInvoke { | |
public static void main(String[] args) throws Exception{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LZEnd { | |
static class Phrase{ | |
public Phrase() { | |
} | |
public Phrase(int phraseNum, int ref, int len, char nonMatchedChar) { | |
this.phraseNum = phraseNum; | |
this.ref = ref; | |
this.len = len; | |
this.nonMatchedChar = nonMatchedChar; | |
} |