Resource Files - RetroGuard Documentation
For all but the most trivial Java applications and applets, there are
resource files associated with the code and stored with it in the Jar file.
These resources can include images, audio files and resource bundles for
localizing internationalized code.
In addition, the Jar file contains a manifest file and can contain files
associated with digital signatures.
Below we specify the way that RetroGuard deals with each of these types
of non-'.class' files in the Jar.
Resource files
The common idioms for accessing resource files from a Java class are:
- using a relative path and the
java.lang.Class methods
InputStream getResourceAsStream(String relativePath);
URL getResource(String relativePath);
- using an absolute path and the
java.lang.ClassLoader
methods
InputStream getResourceAsStream(String absolutePath);
URL getResource(String absolutePath);
The relative paths are prefixed at run-time by the current class's name, and
then the named resource is found. If this class name has been obfuscated, the
path of the resource will also have to have been updated with the obfuscated
version so that the resource can still be located.
RetroGuard's behavior is to update all components of a resource's path
with obfuscated versions. The possibility exists that classes lose track of
their resources if those resources have been referenced through absolute paths.
For this reason, we encourage the use of the relative path methods of
java.lang.Class , rather than the absolute path methods of
java.lang.ClassLoader .
|