.class-file

Why does compiling a class containing static nested classes create a new .class file named “EnclosingClass$1”? [duplicate]

跟風遠走 提交于 2019-12-18 11:46:08
问题 This question already has answers here : Why is an anonymous inner class containing nothing generated from this code? (5 answers) Closed 4 years ago . In the below code : class EnclosingClass { public static class BiNode extends Sub.IBiLink { } private static class Sub { private static class IBiLink { } } } On compiling along with other .class files, I also see a file named "EnclosingClass$1.class" .Why has this been automatically created? Whats going on? 回答1: First have a look at the class

Changing the compiled java .class files in JAR

前提是你 提交于 2019-12-13 22:34:30
问题 My requirement: I've unpacked a jar and then changed a .class file after de-compiling in to .java file. This .java file has few errors as it uses few stuffs like methods and variable from other places which is in the JAR . Now I want to change the .java file in to .class file and then want to add in the JAR and see my changes are working or not. Background : I've unpacked the ATU Jar file and the de-complied the ATUReportsListener.class . I've the ATUReportsListener.java file now and I made

Docker Error: Could not find or load Main class Main.Main

北慕城南 提交于 2019-12-13 04:40:42
问题 I have coded this Dockerfile that makes a runnable jar out of a project and it also builds but when i try to run it, it says "Error: Could not find or load Main class Main.Main" Dockerfile: RUN yum install -y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk- devel.x86_64 && yum clean all COPY resources /home/resources COPY elk_casino_server /home/elk_casino_server RUN /usr/bin/javac /home/elk_casino_server/src/Main/Main.java RUN jar vcmf /home/elk_casino_server/src/META-INF/MANIFEST.MF /home/elk

Loading custom class loader to load a transferred byte[] in java

时光总嘲笑我的痴心妄想 提交于 2019-12-13 00:48:55
问题 I transfer a whole .class file (and it's declared and anonymous classes) as a byte[] and want to be able to define it using the class loader on another computer that receives the byte[]. I have found a solution at Java: How to load Class stored as byte[] into the JVM?, however, I don't understand how to use this ByteClassLoader for my purpose. I just post the code here again: public class ByteClassLoader extends URLClassLoader { private final Map<String, byte[]> extraClassDefs; public

Java binary (.class) file format parser?

只愿长相守 提交于 2019-12-12 11:23:01
问题 I am looking for a tool (or chain of tools) that can parse a .class files to a Java object. Something like : JavaClass parsed = myTool.parse("/some_folder/SomeClassFile.class"); The parsed object would have methods like : List<JavaMethod> methods = parsed.getMethods(); List<JavaInterface> interfaces = parsed.getImplementedInterfaces(); List<JavaMethod> calls = someMethod.getCalls(); My constraints are : The aim is to parse all classes of a project, including jars, so performance does matter.

Edit a .jar library?

只谈情不闲聊 提交于 2019-12-12 02:01:40
问题 I've been asking to edit a .jar lib removing all the Log. I extracted the .class files and from there with a tool i managed to get the .java files. I guess all i need to do is create a new project in eclipse and copy the .java files, edit and the compile them in a new .jar. But when i copy the files in eclipse it give me a lot of error due to the build path. If I compile the .java file with all these aerror the library will work? 来源: https://stackoverflow.com/questions/28294256/edit-a-jar

How to correct a mess java .class file set or generate a proper .jar archive from a mess .class set?

☆樱花仙子☆ 提交于 2019-12-11 15:42:24
问题 Background I have to contact different kind of Java project with various of build system. Sometimes the directory structure is different from the package hierarchy. So it is difficult to package. Even if the build system like Maven and Gradle have its own function to pack .jar but it need a qualified internet connection and a giant size of local repository. Hence I usually build the library I need on the desktop in my office. However I spend more time on my laptop which doesn't have such good

Class file parser

白昼怎懂夜的黑 提交于 2019-12-11 09:28:24
问题 I have an assignment where i need to write a Java program that parses a .class file and retrieves things like : 1.name of the .java file 2.implemented interfaces 3.variables 4.constructors 5.methods I don't have any ideeas where to begin from? For example,what kind of Data I/O structure should I use? 回答1: There are already several libraries for classfile parsing out there. Objectweb ASM is the most popular. If you have to do it from scratch, that I'd recommend starting by the JVM

Java: .class file and java.lang.Class

限于喜欢 提交于 2019-12-10 15:46:25
问题 Is java.lang.Class the same as the actual .class file? i.e. is the content equivalent? I want to send the .class over socket, and was wondering if instead of trying to find and load the actual .class file, if I could just transmit the java.lang.Class instead? Elaboration (read if you want more info) Suppose I have a Java class called SomeObj. When this file is compiled, a file called SomeObj.class will be generated. We also know that if I have SomeObj as a type, we could get its java.lang

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

我们两清 提交于 2019-12-09 16:53:48
问题 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