idea modify the source code

1. Open the jar with the compressed file, find the class file to be modified, and view the source code through the source code tool.

Scenario: Modify the FontMapperImpl.class file in pdfbox-2.0.22.jar

Insert picture description here
1.1 Open the jar package with 360 compression
Insert picture description here
1.2 Drag FontMapperImpl.class to the decompilation tool, view the source code, here use Idea directly
Insert picture description here

2. Create a new blank project decompilatoin (start from any name)

Insert picture description here

3. Create a new package in decompilatoin, the structure is the same as that of the source code. New java and decompiled source code are the same

In the above class file, you can know the package: org.apache.pdfbox.pdmodel.font, create the same package, and the same java file
Insert picture description here

4. As the above java file reports an error. Just after importing the source jar package

4.1 The pom.xlm file is introduced into the jar package
Insert picture description here
4.2 The java file does not report an error
Insert picture description here

5. Modify the java file

For example, add print log in FontMapperImpl.java
Insert picture description here

6. Compile java files to generate class files

Click compile to compile
Insert picture description here
and generate class files in target
Insert picture description here

7, replace our modified class file with the file in the jar

Insert picture description here

8. Replace the modified jar with the original jar and verify

Insert picture description here

Guess you like

Origin blog.csdn.net/fangye1/article/details/113180382