bytecode

Python bytecode and .pyc file format specification

百般思念 提交于 2019-12-05 05:36:55
问题 I'm looking for pyc file format specification, I found this link that provides bytecode instructions without the opcodes but I need alot more detailed file that includes the file structure of the .pyc, Can anyone provide me a link to it? Thanks. 回答1: The structure of .pyc files is explained here: http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html Cilyan already posted a link to the actual documentation for the bytecodes in the standard library (https://docs.python.org/3.5

Where does bytecode injection happen?

為{幸葍}努か 提交于 2019-12-05 04:43:14
问题 Motivation I have a SomeObject.java file: class SomeObject { String name; } Compiling it creates a bytecode-containing SomeObject.class file. 0xCAFEBABE... If we use SomeObject on the JVM, it is loaded by the current classloader and all works fine. Now let's assume that I'd like to have some dynamic code generation. I can write my custom annotation @Target(ElementType.TYPE) public @interface Data { ... } and add it as a modifier to the class declaration: @Data class SomeObject { String name;

Is it possible to access inner functions and classes via code objects?

爱⌒轻易说出口 提交于 2019-12-05 02:27:19
问题 Say there's a function func def func(): class a: def method(self): return 'method' def a(): return 'function' lambda x: 'lambda' that I need to examine. As a part of the examination I want to "retrieve" source code or objects of all nested classes and functions (if any). However I do realize that they don't exist yet and there's no direct/clean way of accessing them without running func or defining them outside (before) func . Unfortunately, the most I can do is import a module containing

Any C/C++ to non-native bytecode compiler/interpreters?

时间秒杀一切 提交于 2019-12-05 02:01:57
As the title indicates, are there any C/C++ bytecode compilers/interpreters? I'm writing an application in an interpreted language that depends on certain libraries that are fully cross-compilable (there are no special flags to indicate code changes during compilation for a certain platform) but are written in C and C++. Rather than shipping n-platform-specific-libs with each platform, it would be nice to ship one set of libs which are interpreted by one platform specific interpreter. Possible and/or available? EDIT1: The interpreted language in question is Python, though I may also use Ruby.

Is it possible to track down which expression caused an NPE?

怎甘沉沦 提交于 2019-12-05 01:37:29
When I get an NPE, I'll get a stack trace with line number. That's helpful, but if the line is very dense and/or contains nested expression, it's still impossible to figure out which reference was null. Surely, this information must've been available somewhere. Is there a way to figure this out? (If not java expression, then at least the bytecode instruction that caused NPE would be helpful as well) Edit #1: I've seen a few comments suggesting breaking up the line, etc, which, no offence, is really non-constructive and irrelevant. If I could do that, I would have ! Let just say this modifying

Using JRuby/Jython for Ruby/Python interoperability?

£可爱£侵袭症+ 提交于 2019-12-05 01:12:19
Quite-probably a silly question, as I don't know much about Java/Jython/JRuby/bytecode, but.. I stumbled across _why's unholy again today.. It allows you to output Python bytecode from Ruby code.. Basically allowing them to produce the same bytecode.. Jython outputs Java bytecode, as does JRuby.. Since these both compile to the same bytecode, does this mean you could potentially use any Python library from Ruby, and Ruby libraries from Python? No, that won't work. At least not the way you think it would. Interoperability between Jython and JRuby works the same way as between CPython and YARV:

Why does the same JAR file have different hash every time I build it?

别等时光非礼了梦想. 提交于 2019-12-05 00:06:49
I've been thinking about checking jar file's hash value to determine if it has changed or not, but as it turns out the same jar file has different hashes every time I build it (export as jar file from eclipse, or build it using maven). I've removed manifest file's date values and stuff but it still is different. Is there something in bytecode generation which includes a timestamp or something? A JAR file is a ZIP file and it contains a last modified date in its local file headers and central directory file header. This will lead to different hashes of your builds. If you run the JAR command on

How does Google App Engine precompile Java?

假装没事ソ 提交于 2019-12-04 23:59:23
问题 App Engine uses a "precompilation" process with the Java bytecode of an app to enhance the performance of the app in the Java runtime environment. Precompiled code functions identically to the original bytecode. Is there any detailed information what this does? 回答1: I found this in a googlegroups message: Yes, pre-compilation reduces the time to load an application. This will benefit you on your first request after a deploy, after you've been cycled out or if more application instances are

Interpret something, and run the generated bytecode in Java?

只谈情不闲聊 提交于 2019-12-04 23:10:08
问题 I'm writing a toy interpreter with a REPL in Java. I'd like to generate bytecode from the language and run that, instead of interpreting an AST and running that instead. Since my Java is a bit rusty, is it possible to run generated bytecode on the fly on the JVM? 回答1: You can use java.lang.Classloader.defineClass(), which turns bytecode into a Class object. You can the call newInstance() on the resulting Class object, and off you go. 回答2: Have a look at Javassist which contains a snippet

Custom Class Loader In Java [closed]

冷暖自知 提交于 2019-12-04 22:10:31
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Is it possible to make my own Custom Class Loader In java. If Yes Then Please Guide me. Instead of class obfuscation I want to change in class file so that it cant be reversed by any tool You can use some obfuscation tools, like ProGuard. A self written ClassLoader, must be placed in a standard .class file, that the JVM can load it. And then you secure loader can be reverse engineered. Don't do it by yourself.