java复制类mytool_MyTools

软件简介

该 jar 包对 java 调用 Groovy 、JavaScript、Clojure 脚本语言的接口进行封装,方便在java程序中进行多语言混合编程

在jar中增加对URLClassLoader类进行继承重写实现动态加载和拆卸jar,使用Message类进行jar插件间的解耦调用。

包管理工具采用 Gradle 进行管理

使用示例:

@Test

public void testJava() throws Exception {

JavaHepler jh = new JavaHepler();

//jh.putPath("Test", "test.Test");

//IMethod d = jh.newInstance("Test");

//or

IMethod d = jh.newInstance("test.Test");

IInvoke i = d.getMethod("p");

i.invoke();

i = d.getMethod("p2");

i.invoke("MyTools");

}

//@Test

public void javaScript() {

long b = System.currentTimeMillis();

String[] s = new String[] { "test/test.js" };

JSHelper js = new JSHelper(s);

js.addField("ca").javaToJs(System.out);

System.out.println(js.getMethod("test").invoke());

js.exit();

long e = System.currentTimeMillis();

System.out.println("js :" + (e - b));

}

//@Test

public void groovy() throws Exception {

String file = "test/Test.groovy";

long b = System.currentTimeMillis();

GroovyHelper gh = new GroovyHelper();

//gh.putPath("Test", file);

//gh.newInstance("Test").getMethod("t").invoke();

//or

gh.newInstance(file).getMethod("t").invoke();

long e = System.currentTimeMillis();

System.out.println("Groovy :" + (e - b));

}

//@Test

public void clojure() throws Exception {

String file = "test/test_t.clj";

long b = System.currentTimeMillis();

ClojureHelper cl = new ClojureHelper();

//cl.putPath("test", file);

//IMethod c = cl.newInstance("test");

//or

IMethod c = cl.newInstance(file);

IInvoke i = c.getMethod("t3");

System.out.println(i.invoke(4));

long e = System.currentTimeMillis();

System.out.println("clojure :" + (e - b));

}

//@Test

public void jython() throws Exception {

String file = "test/Test.py";

long b = System.currentTimeMillis();

JythonHelper jy = new JythonHelper();

//jy.putPath("Test", file);

//jy.newInstance("Test").getMethod("t").invoke();

//or

jy.newInstance(file).getMethod("t").invoke();

long e = System.currentTimeMillis();

System.out.println("jython :" + (e - b));

}

//@Test

public void jruby() throws Exception {

String file = "test/Rr.rb";

long b = System.currentTimeMillis();

JRubyHelper jr = new JRubyHelper();

//jr.putPath("Rr", file);

//Object obj = jr.newInstance("Rr").getMethod("c2f").invoke(100);

//or

Object obj = jr.newInstance(file).getMethod("c2f").invoke(100);

System.out.println(obj);

long e = System.currentTimeMillis();

System.out.println("jruby :" + (e - b));

}

//@Test

public void beanShell() throws EvalError, IOException{

long b = System.currentTimeMillis();

BeanShellHelper bsh = new BeanShellHelper();

bsh.getFied("a").set("Hello World");

bsh.load("test/test.bsh");

System.out.println(bsh.getFied("b").get());

long e = System.currentTimeMillis();

System.out.println("jruby :" + (e - b));

}

增加对beanShell调用的支持

实验六 Linux开发工具的使用(二) 班级: 姓名: 学号: 上机时间: 任课教师: 实验教师: 实验成绩: 一、实验目的 理解makefile文件,学会make工具的使用。 二、实验注意事项 实验室内的实验环境与系统是共用设施,请不要在系统内做对系统或对其他用户不安全的事情。 要求每个同学登录后系统后,要在自己的家目录下创建一个属于自己的子目录(以自己(拼音)名字或学号)。以后所有工作都要在自己的目录内进行。建议以后的实验都在同台计算机上做,这样可以保持连续性。 用户要按通常实验要认真书写实验报告。 三、实验内容及步骤 1.假设我们有一个程序由5个文件组成,源代码如下所示,根据以下步骤,熟悉makefile编程。 /*main.c*/ #include "mytool1.h" #include "mytool2.h" int main() { mytool1_print("hello mytool1!"); mytool2_print("hello mytool2!"); return 0; } /*mytool1.c*/ #include "mytool1.h" #include <stdio.h> void mytool1_print(char *print_str) { printf("This is mytool1 print : %s ",print_str); } /*mytool1.h*/ #ifndef _MYTOOL_1_H #define _MYTOOL_1_H void mytool1_print(char *print_str); #endif /*mytool2.c*/ #include "mytool2.h" #include <stdio.h> void mytool2_print(char *print_str) { printf("This is mytool2 print : %s ",print_str); } /*mytool2.h*/ #ifndef _MYTOOL_2_H #define _MYTOOL_2_H void mytool2_print(char *print_str); #endif 根据实验要求,写出第一个Makefile如下: main:main.o mytool1.o mytool2.o gcc -o main main.o mytool1.o mytool2.o main.o:main.c mytool1.h mytool2.h gcc -c main.c mytool1.o:mytool1.c mytool1.h gcc -c mytool1.c mytool2.o:mytool2.c mytool2.h gcc -c mytool2.c clean: rm -f *.o 在shell提示符下输入make,执行显示: gcc -c main.c gcc -c mytool1.c gcc -c mytool2.c gcc -o main main.o mytool1.o mytool2.o 执行结果如下: [armlinux@lqm makefile-easy]$ ./main This is mytool1 print : hello mytool1! This is mytool2 print : hello mytool2! 这只是最为初级的Makefile,现在来对这个Makefile进行改进。 改进一:使用变量 一般在书写Makefile时,各部分变量引用的格式如下: 1. make变量(Makefile中定义的或者是make的环境变量)的引用使用“$(VAR)”格式,无论“VAR”是单字符变量名还是多字符变量名。 2. 出现在规则命令行中shell变量(一般为执行命令过程中的临时变量,它不属于Makefile变量,而是一个shell变量)引用使用shell的“$tmp”格式。 3. 对出现在命令行中的make变量同样使用“$(CMDVAR)” 格式来引用。 OBJ=main.o mytool1.o mytool2.o main:$(OBJ)
最新发布
05-09
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值