I found proguard to be too strict about entries in jars.
I use the following code to get a base-url for images
in an application which may run via WebStart:
String id = "images/";
URL url = getClass().getResource(id);
if (id != null && url != null) {
imageBase = url.toExternalForm();
logger.info("imageBase: " + imageBase);
}
else {
logger.warn("WARNING: Cannot load images.");
}
This does not work anymore when the jar was processed
with proguard because the directory entry is missing,
allthough all the images in the directory are in place.
My current workaround is to extract the processed jar
and create a new one .
I also noticed that the entries are unsorted, but I
guess this does not have any effect.
BTW: proguard does its job very well !!!!
Logged In: YES
user_id=555208
You're right. Directory entries are always removed from the
output jar files. They always seemed useless, but clearly
that's not always true. I'll think about a solution. For
now, I'll add a note that people should add them manually
after the processing. I assume the -u option of the jar
command can be helpful here.
Eric.
Logged In: YES
user_id=1422395
I've also run into this problem. Can the priority of this
particular bug be increased?
Logged In: YES
user_id=2055146
Originator: NO
For Spring developers this is a serious bug. In my project we use wildcards [classpath*:com/mycompany/myproject/*-sc.xml] to specify the configuration files to load into our application context. Because the directories are removed from the obfuscated jar, the classloader cannot load the files and we are left with a busted app following the obfuscation process.
If you're not familiar with Spring, I can provide you with additional details should you need/care for them. However, the crux of the issue is that ClassLoader.getResources(String name) *should* return an Enumeration with at least one value in it when provided a valid package for value of the 'name' parameter.
With all due respect, the obfuscated jars are corrupt. Would you please expose an option to retain the directories in the archive?
The option -keepdirectories in recent versions allows to selectively keep directory entries in the output.