Comments (5)
When you obfuscate your module jar and the library jar on which your module depends, yGuard should create two new jars, an obfuscated module jar and an obfuscated library jar. (With "an obfuscated jar" I mean a jar with obfuscated classes.) This pair of obfuscated jars has to be used together. Moreover, the obfuscated library jar cannot be used with other module jars that have not been obfuscated together with the module and the library. Nor can the obfuscated module jar be used with a library that has not been obfuscated (or has been obfuscated together with other modules).
Furthermore, if code in the module jar uses reflection to access code in the library jar (or vice versa), this code will break (unless all types and members that are accessed through reflection are excluded from renaming).
If this does not help, please provide a short, self-contained, executable example that lets us reproduce the problem. Otherwise there is no way for use to determine what is going wrong.
from yguard.
Ah, now I see what I was doing wrong! I was starting the program using java -jar module_obf.jar
, so I (naively) assumed that it would also automatically use the library_obf.jar
in conjunction with it. It didn't occur to me that I needed to rename it.
Or actually, looking back through my protocol, it did occur to me, but at a very early stage during the project when I had it separated into two different filesets, and thus it mentally compiled and got saved as "renaming the library_obf.jar
to library.jar
" is not how you do it. That's why I didn't try it again later on, because I already had it filed under "tried and did not work".
Anyway, now it works. I'll sum up my learnings here:
To get two dependent files to recognize one another in obfuscated code at runtime, you need to:
- Put them into the same fileset block, like this:
fileset(dir: "./build/install/module") {
include(name: "module*.jar")
include(name: "lib/project-lib*.jar")
exclude(name: "*_obf.jar")
exclude(name: "lib/*_obf.jar")
}
- After using the yGuard task to obfuscate the files, rename the obfuscated files and remove the "_obf"-suffix, because otherwise, when starting the program from an obfuscated file, the program will attempt to load its dependencies from the non-obfuscated file using the obfuscated names, which will fail.
Does that correctly sum it up? If so, could you add it to the documentation? That would have really helped me.
Thanks again for all your help! =^,^=
P.S.: I am aware that I won't be able to use the same obfuscated library for separately compiled modules. However, I am reasonably sure that won't be a problem since the modules should be fully independent from one another, and communicate with one another over the network. So as long as each module is able to recognize its own "obfuscated copy" of the library, that should work, I think. But we'll have to see.
from yguard.
Hey @KiraResari we will try to replicate this with a simple code sample and add it to the examples to sort out future confusion. I will close this ticket once that's done!
Thanks and all the best,
Lennard
from yguard.
Anyway, just wanted to let you know that I managed to get this to work for two modules using the same lib being obfuscated separately, and so far, it seems like the two modules can communicate with one another just fine.
from yguard.
After looking into this issue it seems like this is an advanced yGuard topic that can be solved (e.g if one keeps looking into the documentation). It appears to me that a example of this use case isn't very much suited for a larger audience.
from yguard.
Related Issues (20)
- Springboot Java Code Obfuscation Error HOT 2
- Support for Java 18+? HOT 17
- Remove Kotlin Metadata annotations HOT 2
- <tasks> replaced by <target> HOT 4
- all method param after obscure are change like paramXXXX HOT 2
- Unique class name generation HOT 8
- The demo for example (/examples/resources/) is not valid. After the maven package is packaged, the package structure and resource contents of the jar file are not changed. HOT 2
- Fix replaceContentPolicy strict for package name strings
- Can we obfuscate spring boot war file ? HOT 8
- Keep method params HOT 4
- Combine obfuscation settings in pom.xml with Obfuscation annotation HOT 7
- How to generate pseudorandom name mappings for package, class HOT 3
- Can we do only Obfuscation step using yGuard ? HOT 1
- support multiple keep for multiple class HOT 4
- How to obfuscate .apk with this tool? HOT 1
- Issue with uber-jar obfuscation (Self-contained executable jar) HOT 1
- Excluding clojure HOT 3
- Exposed class is still being obfuscated HOT 1
- What are the limitations of yGuard tool ? HOT 4
- Yshrink does not accept the Record keyword HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yguard.