What happens if I mislay the qualified path name information for a "third party" .class file?

StackOverflow https://stackoverflow.com/questions/23675490

  •  23-07-2023
  •  | 
  •  

質問

Suppose I buy a .class file from a "third party" developer. They send me the .class file, but not the source code. In their accompanying documentation, they tell me what the qualified path name for the .class file is, what the class is called, and what its public members are.

Suppose I use their class in my program, like so:

class Main {
    public static void main(String[] args) {
        thirdparty.special.PaidFor.method();
    }
}

To compile my project, my ("cut down") javac command looks like this -

javac -cp bin Main.java

I've added in a -cp option to this javac command, and also manually created the following folder structure, to which the PaidFor.class file has been moved to. (Presumably, the javac -cp option, and manually creating this folder structure are mandatory.)

(folder structure)
\bin \ thirdparty \ special \ PaidFor.class

What happens if the following situation occurs:

Sometime in the future, my project source code and associated folder structure are deleted, and I also mislay the accompanying documentation for the third party .class file. In other words, I no longer know that the third party .class file has a qualified name of "thirdparty.special", which contains a class called PaidFor, containing members such as method().

I searched online for some clues as to what I could do in this situation. I came across various downloads with descriptions such as "Java class analyzer". Not knowing anything about this topic, I wonder if this is the most appropriate and relevant approach to take in this situation. Thanks a lot for any comments.

役に立ちましたか?

解決

You run the 'javap' tool on the .class file.

他のヒント

At the classfile level, all class names are fully qualified. Simply examining the classfile will give you the fully qualified name of the class it contains, as well as the name and types of all fields and methods it contains.

There are a number of tools to do this. In fact, I wrote an open source classfile disassembler myself.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top