.class-file

What does the visitLocalVariable() method of the MethodVisitor class in the ASM bytecode engineering library do?

心已入冬 提交于 2021-02-09 05:38:23
问题 I am using ASM (for the first time) in an application to create Java class files. This is for the backend of a compiler I am writing. I read the relevant parts of the ASM documentation and have a question about stack map frames. ASM says it can automatically compute those frames if the class writer is initialized with the appropriate flags. My question is, does that mean I will not ever have to call the visitLocalVariable() method on the method visitors myself? I am not sure what that method

Java ByteCode arithmetic operation

守給你的承諾、 提交于 2021-01-29 18:19:54
问题 I'm going to make a simple compiler for a school project, i want generate .class file, i read the file format but to understand better the .class file format and the java bytecode i have this class: public class Me { public void myMethod() { int a = 5 * 4 + 3 - 2 + 1 / 7 + 28; } } with javap command i get this(for 'myMethod'): public void myMethod(); flags: ACC_PUBLIC Code: stack=1, locals=2, args_size=1 0: bipush 49 2: istore_1 3: return LineNumberTable: line 3: 0 line 4: 3

What are CONSTANT_MethodHandle, CONSTANT_MethodType, and CONSTANT_InvokeDynamic?

巧了我就是萌 提交于 2020-05-11 21:17:51
问题 I was looking into how the Java bytecode worked, and I started on Wikipedia. On the page focusing on the .class file, it mentions 11 constant types that appear in the Constant Pool. However, in The Java Virtual Machine Specifications (JVMS) it mentions 3 more: CONSTANT_MethodHandle CONSTANT_MethodType CONSTANT_InvokeDynamic The 11 mentioned on the Wikipedia page seem fairly self-explanatory, and I understand their purpose and use. However, I'm confused by the 3 extra described in the JVMS.

How can get an instance from .class file in java

痴心易碎 提交于 2020-02-03 12:23:13
问题 Frankly, I do not know even it is possible or not. But what I am trying to do is just like below. I made a class file from ClassFile.java via javac command in terminal. Then I want to get an instance from .java file or .class file. Next, I made another project in eclipse, As you guess this project path and upper file path are completely different. For instance, ClassFile.java/class file can be located in '~/Downloads' folder, the other hand, new eclipse project can be in '~/workspace/'. So I

Gradle reports BUILD SUCCESSFUL, however I can not locate any .class files

ぐ巨炮叔叔 提交于 2020-01-05 04:41:12
问题 I am attempting to use Gradle (for the first time) for a multiproject java build. I have created a settings.gradle file with all the project names. I have also create a very basic build.gradle file. To my surprise when I run gradle build. It returns BUILD SUCCESSFUL. Jars are created in the build\libs folder. What is puzzling to me is that no .class files exists. Also I have been unable to get any kind of Junit results or xml output. I'm wondering if this is really building correctly. For now

Any Java counterpart for `/usr/bin/strip`?

笑着哭i 提交于 2019-12-23 12:07:00
问题 Is there any tool that can remove debug info from Java .class files, just like /usr/bin/strip can from C/C++ object files on Linux? EDIT: I liked both Thilo's and Peter Mmm's answers: Peter's was short and to the point exposing my ignorance of what ships with JDK; Thilo's ProGuard suggestion is something I'll definitely be checking out anyway for all those extra features it appears to provide. Thank you Thilo and Peter! 回答1: ProGuard (which the Android SDK for example ships with to reduce

How to programmatically generate .class files?

一曲冷凌霜 提交于 2019-12-21 04:12:19
问题 I would like to write a compiler for a toy-language for Java. I would like to generate runnable .class files. I was wondering what is the best library or tool available for doing this? I know I could learn the binary format for all the instructions and build my own constant pool etc, but that seems like work that ought to have been already done: no point reinventing the wheel, right? Searching online I've found two different Java Assembly languages, Jasmin and Jamaica, however only Jasmin

How to programmatically generate .class files?

南楼画角 提交于 2019-12-21 04:12:06
问题 I would like to write a compiler for a toy-language for Java. I would like to generate runnable .class files. I was wondering what is the best library or tool available for doing this? I know I could learn the binary format for all the instructions and build my own constant pool etc, but that seems like work that ought to have been already done: no point reinventing the wheel, right? Searching online I've found two different Java Assembly languages, Jasmin and Jamaica, however only Jasmin

Why different class files are created for each enum type if they have constant-specific method?

无人久伴 提交于 2019-12-20 02:28:15
问题 i have one enum as enum OperationsType { ADD("+"), SUB("-"), DIV("/"), MUL("*"); private String opcodes; private OperationsType(String opcodes) { this.opcodes = opcodes; } public String toString() { return this.opcodes; } } Here all enum type doesn't have any constant Specific method so javac is creating only one class file for enum as OperationsType.class but if i add constant Specific method in same code for all enum type then javac is creating 5 class files. Operations.class Operations$1

The code of method … is exceeding the 65535 bytes limit

房东的猫 提交于 2019-12-19 08:14:17
问题 Inside a jsp I have a small header : <%@ page import="java.util.*"%> <% HttpSession CurrentSession = request.getSession(); ... %> ...and a big html <html> ... </html> If I try to read it as is I get an error of "...is exceeding the 65535 bytes limit".I have to break it up.Since I am new to java I cannot figure it out how to do it.Could you please indicate me the way? 回答1: The JSP is converted into a normal Servlet java source, and some generated method is too large, as there is a 64 KB limit