Coder Social home page Coder Social logo

Comments (5)

thomasbehr avatar thomasbehr commented on May 29, 2024

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.

KiraResari avatar KiraResari commented on May 29, 2024

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:

  1. 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")
				}
  1. 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.

Fohlen avatar Fohlen commented on May 29, 2024

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.

KiraResari avatar KiraResari commented on May 29, 2024

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.

Fohlen avatar Fohlen commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.