bytecode

Bytecode features not available in the Java language

给你一囗甜甜゛ 提交于 2019-11-28 02:31:43
Are there currently (Java 6) things you can do in Java bytecode that you can't do from within the Java language? I know both are Turing complete, so read "can do" as "can do significantly faster/better, or just in a different way". I'm thinking of extra bytecodes like invokedynamic , which can't be generated using Java, except that specific one is for a future version. Joachim Sauer As far as I know there are no major features in the bytecodes supported by Java 6 that are not also accessible from Java source code. The main reason for this is obviously that the Java bytecode was designed with

ASM Get exact value from stack frame

*爱你&永不变心* 提交于 2019-11-28 01:39:05
I have some method, which contains instrustion like ILOAD, and I want in some way to get value of stack after this instruction. Not just type, but exact value. I know I need to emulate method execution in order to do that, but I don't know how to make this properly. I have such method for test called main : sipush 15649 istore_0 /* c */ getstatic java/lang/System.out:Ljava/io/PrintStream; bipush 45 bipush 11 iload_0 /* c */ ... I want to get value, loaded by iload_0 . I tried to make Analyzer and then see Frame values, but they only contains type of values, not exact what I want. ClassReader

how to find all methods called in a method?

旧街凉风 提交于 2019-11-27 22:31:01
how to take the methods of other classes invoked in a specific method? EXAMPLE method getItem1() public String getItem1() throws UnsupportedEncodingException{ String a = "2"; a.getBytes(); a.getBytes("we"); System.out.println(a); int t = Integer.parseInt(a); return a; } The methods called in getItem1() are: String.getBytes() String.getBytes(String) PrintStream.println(String) Integer.parseInt(String) I would do this with javassist . So let's say you have the following class accessible in your classpath and want to find all methods invoked from getItem1() : class MyClass { public String

Why are compiled Java class files smaller than C compiled files?

拥有回忆 提交于 2019-11-27 22:16:05
问题 I would like to know why the .o file that we get from compiling a .c file that prints "Hello, World!" is larger than a Java .class file that also prints "Hello, World!"? 回答1: Java uses Bytecode to be platform independent and "precompiled", but bytecode is used by interpreter and is served to be compact enough, so it is not the same that machine code which you can see in compiled C program. Just take a look at the full process of Java compilation: Java program -> Bytecode -> High-level

Is there a way to obtain the bytecode for a class at runtime?

拜拜、爱过 提交于 2019-11-27 22:09:12
In Java, is there a way (at runtime) to obtain the bytecode which defined a particular class? Put another way, is there a way to obtain the byte[] array passed to ClassLoader.defineClass(String name, byte[] b, int off, int len) when a particular class was loaded? I see that this method is declared final , so creating a custom ClassLoader to intercept class definitions seems out of the question. In the past, I have used the class's ClassLoader to obtain the bytecode via the getResourceAsStream(String) method, but I would prefer a more canonical solution. stacker Here is a description how to

Why are JSR/RET deprecated Java bytecode?

邮差的信 提交于 2019-11-27 21:51:30
问题 Does anyone know why the JSR/RET bytecode pair is deprecated in Java 6? The only meaningful explanation I found on the net was that they made code analysis by the runtime harder and slower to perform. Does anyone know another reason? 回答1: JSR and RET make bytecode verification a lot more difficult than it might otherwise be due to the relaxation of some normal bytecode constraints (such as having a consistent stack shape on entry to a JSR). The upside is very minor (potentially slightly

Is it possible to view a Java class files bytecode [duplicate]

戏子无情 提交于 2019-11-27 21:43:29
问题 This question already has answers here : Is it possible to view bytecode of Class file? [duplicate] (5 answers) Closed 4 years ago . I am working on a bytecode manipulation/generation in Java and I was just wondering if there is an easy way I could check the bytecode. I do not want to decompile the file, I would like to actually look at the compiled bytecode. I do not need to edit it. Any links or programs for doing this would be acceptable answers. 回答1: I've been working on a decompiler that

From C Source to Java Bytecode? [closed]

眉间皱痕 提交于 2019-11-27 20:35:04
问题 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 12 months ago . I'm looking for a way to compile C source code into high-performance Java bytecode. I've successfully used NestedVM, but the performance hit is not acceptable for a project I'm working on. I've also seen various open source projects aimed at this problem and a couple of commercial products. This SO question

Differences between MSIL and Java bytecode?

只谈情不闲聊 提交于 2019-11-27 19:13:55
问题 I'm new to .Net and I'm trying to understand the basics first. What is the difference between MSIL and Java bytecode? 回答1: First off let me say that I don't think that the subtle differences between Java bytecode and MSIL is something that should bother a novice .NET developer. They both serve the same purpose of defining an abstract target machine which is a layer above the physical machine being used in the end. MSIL and Java bytecode are very similar, in fact there is a tool called

Java: Getting Bytecode of Class at Runtime from within the Same JVM

两盒软妹~` 提交于 2019-11-27 17:50:57
问题 Related to: Is there a way to obtain the bytecode for a class at runtime? I'm adding durability to Clojure, and I'm finally at the point where I'm ready to add functions. In Clojure, functions are byte compiled into classes with invoke methods (among others). In this way, functions are first class. To make these durable, I need to serialize and deserialize these classes. How do I get the bytecode for the class without having access to the .class file? Please correct me if I'm mistaken, but