dynamic-code

Java Dynamic Code Generation with support for generics

妖精的绣舞 提交于 2020-01-01 09:58:20
问题 Is there any tool which provides Java dynamic code generation and that also supports generics? Javassist for example, is the kind of tool that I need, but it does not support generics. I wrote a small lib which uses the Java 6 Compiler API, however as far as I know it depends on JDK. Is there a way to specify another compiler? Or to ship with my application only the parts that I need to invoke with the Java Compiler API? 回答1: It seems you can manipulate and read generic info with Javaassist.

How can I calculate an expression parameter in run time?

ぐ巨炮叔叔 提交于 2019-12-23 05:15:12
问题 The problem I need to solve is to run data through IF statements. The IF statements are generated by a SQL table on run time. I've managed to do this by using expressions and Lambda expressions. My table has memberName; Operator; Target. So for example I get "Age", "GreaterThan" and "40" from the table, and I compile it. var rule = new Rule(rowRule["memberName"].ToString(), rowRule["Operator"].ToString(), rowRule["Target"].ToString()); Func<User, bool> compiledRule = CompileRule<User>(rule);

C++ dynamic code injection on an embedded system

核能气质少年 提交于 2019-12-20 04:48:32
问题 I am looking for a solution to the following problem: a C++ software module is developed that runs on an embedded device (no possibility to use the file based function "dlopen" to load shared libraries), while the module is running it shall be extendable by dynamic program code the dynamic code is written (realization of interface functions) and cross compiled (gcc) on a PC system before it is sent via a bus system to the previously described software module running on the embedded device the

Loading multiple versions of the same class

让人想犯罪 __ 提交于 2019-12-18 05:00:50
问题 Let's say I release a code library as a standalone PHP class. Someone then uses version 1.0 of that library in their application. Later, I release version 2.0 of the library and that same someone, for any reason, needs to use both 1.0 and 2.0 side-by-side in their application because either he or I broke backwards compatibility with the new release. If the class names are different, it's easy enough to include and instantiate both because there's no naming conflict. But if the class names are

Dynamic C code execution: memory references

∥☆過路亽.° 提交于 2019-12-10 10:39:20
问题 tl;dr : I'm trying to execute dynamically some code from another snippet. But I am stuck with handling memory reference (e.g. mov 40200b, %rdi ): can I patch my code or the snippet running code so that 0x40200b is resolved correctly (as the offset 200b from the code)? To generate the code to be executed dynamically I start from a (kernel) object and I resolve the references using ld. #!/usr/bin/python import os, subprocess if os.geteuid() != 0: print('Run this as root') exit(-1) with open("

Dynamic C code execution: memory references

烂漫一生 提交于 2019-12-06 08:29:21
tl;dr : I'm trying to execute dynamically some code from another snippet. But I am stuck with handling memory reference (e.g. mov 40200b, %rdi ): can I patch my code or the snippet running code so that 0x40200b is resolved correctly (as the offset 200b from the code)? To generate the code to be executed dynamically I start from a (kernel) object and I resolve the references using ld. #!/usr/bin/python import os, subprocess if os.geteuid() != 0: print('Run this as root') exit(-1) with open("/proc/kallsyms","r") as f: out=f.read() sym= subprocess.Popen( ['nm', 'ebbchar.ko', '-u' ,'--demangle', '

C++ dynamic code injection on an embedded system

为君一笑 提交于 2019-12-02 07:04:32
I am looking for a solution to the following problem: a C++ software module is developed that runs on an embedded device (no possibility to use the file based function "dlopen" to load shared libraries), while the module is running it shall be extendable by dynamic program code the dynamic code is written (realization of interface functions) and cross compiled (gcc) on a PC system before it is sent via a bus system to the previously described software module running on the embedded device the software module on the embedded device shall hold the received dynamic program code in memory and

Loading multiple versions of the same class

白昼怎懂夜的黑 提交于 2019-11-29 07:19:35
Let's say I release a code library as a standalone PHP class. Someone then uses version 1.0 of that library in their application. Later, I release version 2.0 of the library and that same someone, for any reason, needs to use both 1.0 and 2.0 side-by-side in their application because either he or I broke backwards compatibility with the new release. If the class names are different, it's easy enough to include and instantiate both because there's no naming conflict. But if the class names are kept the same, we run into problems: include /lib/api-1.0/library.php; $oldlibary = new Library();