| | |
| | | |
| | | |
| | | public void testJava() throws CannotCompileException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
| | | String javaCode = "public static void testJava2() { System.out.println(\"123213\");\n}\n"; |
| | | String javaCode2 ="public static void testJava1() { testJava2(); System.out.println(\"223213\");\n}"; |
| | | String javaCode = "public static void testJava2() { DataQuery dataQuery = new DataQuery();\n dataQuery.setServiceCode(\"服务编码\"); System.out.println(dataQuery.getServiceCode());\n}\n"; |
| | | String javaCode2 ="public static void testJava1() { testJava2(); ServiceSql serviceSql = new ServiceSql(); System.out.println(\"623213\");\n}"; |
| | | ClassPool classPool = ClassPool.getDefault(); |
| | | classPool.importPackage("com.java110.entity.service.DataQuery"); |
| | | classPool.importPackage("com.java110.entity.service.ServiceSql"); |
| | | CtClass ctClass = classPool.makeClass("com.java110.service.smo.WuxwTest"); |
| | | CtMethod helloM = CtNewMethod.make(javaCode, ctClass); |
| | | ctClass.addMethod(helloM); |
| | |
| | | Constructor<?> con=pc.getConstructor(new Class[]{}); |
| | | |
| | | move.invoke(con); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |