.class-file

When is the JVM bytecode access modifier flag 0x1000 (hex) “synthetic” set?

懵懂的女人 提交于 2019-12-09 15:41:57
问题 For some Java byte code parser project I read the JVM spec and figured out that the bit mask values of the Java virtual machine class file format access modifier fields are ACC_PUBLIC = 0x0001 ACC_FINAL = 0x0010 ACC_SUPER = 0x0020 # old invokespecial instruction semantics (Java 1.0x?) ACC_INTERFACE = 0x0200 ACC_ABSTRACT = 0x0400 ACC_SYNTHETIC = 0x1000 ACC_ANNOTATION = 0x2000 ACC_ENUM = 0x4000 Somehow I have no idea what 0x1000 is for. I saw it once in an inner class, but for all inner classes

How to create a runnable jar file from source code programmatically?

﹥>﹥吖頭↗ 提交于 2019-12-09 03:05:59
问题 I need to create runnable .jar file programmatically from a string. My decision is to create a .class file from string and add it to the .jar using JarOutputStream. What API must I use to create the .class file? Are there any other solutions to create a .jar from the source code? 回答1: In order to do that, you can use the Java Compiler API. There is this excellent tutorial that can walk you through. 回答2: To compile code, you need a compiler. You can either use the Sun Oracle compiler or the

Tool to check package name and class name of the class within a .class file

浪子不回头ぞ 提交于 2019-12-08 04:50:39
问题 Is there some tool or technique to let me query the contents of a Java .class file? I want to know the fully qualified name of the class and what method it defines. I thought that perhaps javap could help me with this but I can't figure out how. 回答1: Is the class contained in the .class file always the same as the file name (excluding .class) In practice, yes. Every Java implementation I've come across relies on class file pathnames to locate classes to be loaded, etc. In theory, a

Tool to check package name and class name of the class within a .class file

江枫思渺然 提交于 2019-12-07 22:42:26
Is there some tool or technique to let me query the contents of a Java .class file? I want to know the fully qualified name of the class and what method it defines. I thought that perhaps javap could help me with this but I can't figure out how. Is the class contained in the .class file always the same as the file name (excluding .class) In practice, yes. Every Java implementation I've come across relies on class file pathnames to locate classes to be loaded, etc. In theory, a classloader could use some other mechanism, and therefore could store classes in files that bear no relation to the

Change string constant in a compiled class

…衆ロ難τιáo~ 提交于 2019-12-06 18:45:18
问题 I need to change a string constant in a deployed Java program, i.e. the value inside the compiled .class -files. It can be restarted, but not easily recompiled (though it's an inconvenient option if this question yields no answers). Is this possible? Update: I just looked at the file with a hex editor and it looks like I can easily change the string there. Would that work, i.e. won't that invalidate some kind of signature of the file? The old and new string are both alphanumeric, and can be

Why is a .class file not human readable? [closed]

。_饼干妹妹 提交于 2019-12-04 07:05:58
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . When a java file is compiled, it generates a .class file. Now this .class file has the bytecode which the JVM interprets. when we open the .class file in a text editor, it is not human readable. Now to view the bytecode a disassembler like javap can be used. My question is, why do

Java inner class inconsistency between descriptor and signature attribute? (class file)

瘦欲@ 提交于 2019-12-04 04:09:18
I'm trying to understand if there's a reason in the spec for the discrepany between java descriptors and signatures for inner classes. (I'm looking directly at the content of the class files here, but I use javap to illustrate). ( n.b. I have tried this on JDK 1.6.0_33 and 1.7.0_05, both have the same issue when viewed with javap from Java 7 - java 6's javap doesn't seem to show any generic signature info, as per Sean's answer below. ) Update : Thanks to those discussing - my take is The descriptor (which doesn't contain generic information) is correct. The signature (which is an attribute of

Conversion of .class to jar and .class to exe

时光总嘲笑我的痴心妄想 提交于 2019-12-03 09:43:07
问题 How do I convert: class file to jar file using cmd? class file to exe file? jar file to exe? Can I convert exe file to jar file? 回答1: Class files to jar files Usage: jar {ctxu}[vfm0M][jar-file] [manifest-file] [-C dir] files ... Options: -c create new archive -t list table of contents for archive -x extract named (or all) files from archive -u update existing archive -v generate verbose output on standard output -f specify archive file name -m include manifest information from specified

Conversion of .class to jar and .class to exe

有些话、适合烂在心里 提交于 2019-12-03 01:15:21
How do I convert: class file to jar file using cmd? class file to exe file? jar file to exe? Can I convert exe file to jar file? Class files to jar files Usage: jar {ctxu}[vfm0M][jar-file] [manifest-file] [-C dir] files ... Options: -c create new archive -t list table of contents for archive -x extract named (or all) files from archive -u update existing archive -v generate verbose output on standard output -f specify archive file name -m include manifest information from specified manifest file -0 store only; use no ZIP compression -M do not create a manifest file for the entries -i generate

Why is a .class file not human readable? [closed]

梦想与她 提交于 2019-12-02 14:12:32
When a java file is compiled, it generates a .class file. Now this .class file has the bytecode which the JVM interprets. when we open the .class file in a text editor, it is not human readable. Now to view the bytecode a disassembler like javap can be used. My question is, why do we need to disassemble bytecode in order to view the bytecode itself? What does the disassembler actually do, to convert the .class file into human readable format? The Java virtual machine simulates a machine. This is why it is called a machine , despite it being a virtual one that does not exist in hardware. Thus,