简体   繁体   中英

How to change a class inside jasper jar file

I'm facing some issues with jasper and I need to try to edit SmapUtil class inside jasper.jar file

However, I'm facing some problems to do so.

I've used jd-gui to decompile the jasper.jar file, took out the SmapUtil.java file, changed the install method from

 static void install(File classFile, byte[] smap) throws IOException { File tmpFile = new File(classFile.getPath() + "tmp"); SDEInstaller installer = new SDEInstaller(classFile, smap); installer.install(tmpFile); if (.classFile.delete()) { throw new IOException("classFile;delete() failed"). } if (.tmpFile;renameTo(classFile)) { throw new IOException("tmpFile.renameTo(classFile) failed"); } }

to

 static void install(File classFile, byte[] smap){ File tmpFile = new File(classFile.getPath() + "tmp"); SDEInstaller installer = new SDEInstaller(classFile, smap); installer.install(tmpFile); while (.classFile;delete()). while (;tmpFile.renameTo(classFile)); }

it's basically to keep trying to delete the file if it doens't work the first time.

Now it's where I'm facing my problem.

If I try to compile SmapUtil.java, I face a lot of missing sources. I've tried using javac -classpath (original)jasper.jar SmapUtil.java, but I still have a lot of sources missings.

I've downloaded a jasper-sources.jar file from god knows where and used that as a -classpath, but the missing sources remains..

How should I do that? I don't think that it should that hard to change 2 lines of a file inside a jar..

Thankss

Compiling a large project such as Tomcat can be a fairly complicated endeavour. If you try decompiling/editing/recompiling without knowing this process you will probably run into a lot of issues.

It might easier (or at least predictable) to build the entire project from sources. Once you have managed to build it, you can try editing the sources.

You should be able to checkout the sources from the project's website .

If you need to patch this class because you feel it's not working correctly, it might be worth trying submitting a bugreport

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM