Commit Graph

197 Commits

Author SHA1 Message Date
md-5
f943b5a6c5 Catch exception not throwable 2013-05-10 14:37:42 +10:00
Agaricus
710ccc6439 Catch all errors in getParents(), improves Java 8 compatibility
If the superclasses cannot be read in ClassLoaderProvider for any reason,
we ignore it and move on. This was the case before but the exception catch
was changed to only include IOError during the 1.5 refactor. This uncovered
an issue where on Java 8 inheritance traversal was hitting the Java 8 classes
in the JRE and throwing IllegalArgumentExceptions from ASM 4.1 since it does
not yet support the 52.0 classfile format.

To restore the previous behavior we change from catching IOException to Throwable,
including IllegalArgumentException. This will prevent correct inheritance trees
to be built on Java 8 classes however this is no worse than before and could be
fixed separately by an ASM 5 or 4.1.1 update once/if it is available.

For background see:
https://github.com/MinecraftPortCentral/MCPC-Plus/issues/841
2013-05-09 19:56:07 -07:00
Agaricus
4fd0cde9d1 Add support for remote URLs in --read-inheritance 2013-05-08 19:27:48 -07:00
md_5
8b5465f36a [maven-release-plugin] prepare for next development iteration 2013-04-27 19:44:38 +10:00
md_5
56dcad5267 [maven-release-plugin] prepare release SpecialSource-1.5 2013-04-27 19:44:22 +10:00
Agaricus
c507342ae0 Fix debug information loss in remapper preprocessor.
Only skip debugging information if not rewriting the class.
Fixes https://github.com/MinecraftPortCentral/MCPC-Plus/issues/802
2013-04-26 18:55:14 -07:00
Agaricus
29104f24d2 Fix null superclass in inheritance map
Object has no superclass, so don't add it to the list.
Also allow InheritanceMap setParents null as a shorthand for none.
2013-04-26 18:46:28 -07:00
Agaricus
d33223562d Fix ClassCastException in tryClimb building inheritance map
The interface uses the generic Collection type but the implementation
an ArrayList. Fix by creating an ArrayList from the Collection. Resolves
this crash observed when updating MCPC+'s plugin loader:

https://gist.github.com/agaricusb/5471423
2013-04-26 18:46:28 -07:00
LexManos
04069fb8b9 Fixup SpecialSource now allowing it to be a replacement for RetroGuard in MCP. The Default RemappingMethodAdaptor 'sorts' the LocalVariables. Which causes things to receive random-ish variable indexes causing FernFlower to decompile them differently.
We now use a modified version of RemappingMethodAdaptor that bpasses the superclass LocalVariablesSorter

In addition I added a few more command line options, Most notibly:
kill-source: Removes the 'SourceFile' attribute
kill-lvt: Removes any LocalVariableTable attributes
kill-generics: Remvoes any LocalVariableTypeTable and Signature attributes
identifier: Tags each class with the specified UTF8 string in the constant pool. This is useful for loaders such as FML to know if the class has been obfusicated to SRG names or not.
2013-04-25 18:04:53 +10:00
Agaricus
66b7fb9269 Fix FileLocator path separator
File.separator is the separator used in subdirectory paths ('/'), whereas
File.pathSeparator is used in $PATH for separating multiple paths (':').
Using the wrong separator worked on OS X since the /var/folders subdir
could be created (":ss-cache") but failed on (Linux?) ci.md-5.net since
/tmp:ss-cache cannot be created (nor it should it be). With this change,
the path should be /tmp/ss-cache, as expected.
2013-04-21 12:10:43 -07:00
Agaricus
dbdfa68975 Always log file downloads and cache hits
Useful since the files can be stored in non-obvious locations (on OS X,
temporary directory is in /var/folders with per-user random subdir) and
may need to be manually removed for testing. Could consider multiple
logging levels instead of always logging these messages.. but they're
more useful to show than most of the other 'verbose' log messages.
2013-04-21 12:07:58 -07:00
Agaricus
36df368ab6 Fix FileLocator temporary directory creation
File.createTempFile() creates a temporary file, so we instead get
the java.io.tmpdir property and use File mkdirs().

There is a Files.createTempDirectory() method in JDK 7, and
Files.createTempDir() in Guava, could possibly use but for caching
its important to use a consistent path (also the path must be unique,
so the full URI is used, since it could refer to specific commit,
where the path disambiguates the resource, beyond the base filename).

Fixes 'no such file or directory' error building MCPC+ via SpecialSourceMP.
2013-04-21 11:47:29 -07:00
md_5
2d06f11347 Refactor downloader into FileLocator and optimize for speed. 2013-04-20 14:00:29 +10:00
md_5
6ea97c26c8 Remove obsolete inheritance providers and globalise verbose setting 2013-04-20 13:33:50 +10:00
md_5
132584eda4 Refactor some of the inheritance providers. 2013-04-20 13:31:42 +10:00
md_5
d846476686 Refactor mapping writers 2013-04-20 13:17:15 +10:00
md_5
1ed5c500b0 Refactor and rename transform classes 2013-04-20 13:08:32 +10:00
md_5
b3934893e0 Rewrite Jar class. 2013-04-20 12:41:16 +10:00
md_5
73b1cfd81c Refactor a few classes into packages. 2013-04-20 12:19:18 +10:00
md_5
3a7ef779bf Update POM & depends 2013-04-20 12:07:55 +10:00
md_5
a318ec4ce6 Quick code format in preparation for repackage. 2013-04-20 12:01:28 +10:00
Agaricus
41244d37e1 Add support for \-style paths in remote mapping file downloads 2013-03-22 11:07:35 -07:00
Agaricus
ef37d9f8e6 Improve exception message on noncomparable jars
Show the mismatched number of symbols
2013-03-16 10:11:47 -07:00
md_5
1b86fa2de3 Reverse-mergecommit 43688dd80b 2013-03-11 16:30:19 +11:00
md_5
43688dd80b Feed in the original ClassReader to ensure the constant pool is not excessively mangled. 2013-03-11 16:10:46 +11:00
Agaricus
44434e8e1b Fix command return status on error 2013-03-10 18:20:19 -07:00
Agaricus
374cb129e2 Add loading of numeric "srg" names from MCP directory
Normally, loadMappingsDir() loads:

    obf -> num -> pkgmcp

but with numericSrgNames, it loads:

    pkgmcp -> num

where:

obf = obfuscated "notch" names
num = numeric "srg" names
pkgmcp = descriptive "csv" names

This implementation could probably be improved further.

Compatibility Note: --numeric used to load these mappings:

    obf -> num

that is, ignoring the fields/methods.csv. But this turned out not to
be too useful. You can still get this mapping with ignoreCsv=true, but
now numericSrgNames and --numeric loads the much more useful mapping:

    pkgmcp -> num

Useful for targetting FML runtime deobfuscation.
2013-03-10 13:45:51 -07:00
Agaricus
65ba1c8053 Add method descriptor to JarMappingLoadTransformer
Again, not used by CSVMappingTransformer, but could be used by other
transformation classes to be written.
2013-03-10 11:40:27 -07:00
Agaricus
f91c319a8b Add class name to JarMappingLoadTransformer field/method
Not used by CSVMappingTransformer, since the CSVs only contain:
    func_###,newname
    field_###,newname
with no class name, but it could be used by other load transformers.
2013-03-10 11:32:08 -07:00
md_5
f7f4290098 [maven-release-plugin] prepare for next development iteration 2013-03-09 18:07:50 +11:00
md_5
d7974083ee [maven-release-plugin] prepare release SpecialSource-1.4 2013-03-09 18:07:39 +11:00
Agaricus
1e3c04f7f1 Add support for access map '**' pattern to match all symbols
Classes, fields, and methods. Also add some documentation of
this ever-expanding file format.
2013-03-08 20:35:36 -08:00
Agaricus
47036ad5a8 Add convenient alias to private visibility
Since AccessMap never downgrades visibility, 'private' in AT is
effectively equivalent to 'no change'. Useful in case you want to
change other flags but not the visibility. Accept '*' as private.
2013-03-08 18:48:19 -08:00
Agaricus
4eacd3ef15 Add support for loading single AT patterns in AccessMap
In addition to filenames and URLs, loadAccessTransformer(String) now
accepts the literal "pattern:" followed by an access transformer line.
Useful for adding individual transformations without a new _at.cfg.
2013-03-08 18:42:21 -08:00
Agaricus
0f3edc778e Rework access map to never decrease visibility
Now will only upgrade, from private->default->protected->public.
Useful for modifying access with wildcards, e.g. classname.* protected
to change all fields in the class to protected -- except those which
are already public. This matches FML's access transformer behavior.
2013-03-08 12:41:59 -08:00
Agaricus
1b9c9f239a Fix NPE when reflection remapping is used without access map 2013-03-07 20:54:58 -08:00
Agaricus
3ae83a6b81 Add support for access modifier mapping
Allows for easily changing arbitrary symbol access flags. Supports
FML *_at.cfg access transformer file format loading in AccessMap.
Multiple AT's can be merged together and applied simultaneously
from the remapper 'preprocessor' class. Symbol visibility, final,
as well as any Java access flag can be set or cleared with +/-.
2013-03-07 19:57:29 -08:00
md_5
6ba34dbfee [maven-release-plugin] prepare for next development iteration 2013-03-07 16:24:26 +11:00
md_5
0cf67b4345 [maven-release-plugin] prepare release SpecialSource-1.3 2013-03-07 16:24:13 +11:00
Agaricus
e6addcde3b Exclude signature files (.DSA, .SF) from remapped jar
The remapped jar is altered and will fail to validate against
the included signatures from the original jar, if any. Normally
not a problem, you can compile against the remapped jar as a library
with no errors. However, when loading the jar from Maven (hit with
the Forge jar), signature validation will fail. Stripping the
signature files fixes this.
2013-03-03 16:23:47 -08:00
Agaricus
3decd36620 Add support for remapping jar mods with multiple --in-jar
You can now pass multiple filenames to --in-jar, and the files
in the subsequent jars will overwrite those in the previous. This
allows remapping "jar mods", which are distributed as an archive of
a subset of files against a reference jar. For example, Forge
overwrites base classes in Minecraft. Example usage:

java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --in-jar http://files.minecraftforge.net/minecraftforge/minecraftforge-universal-1.4.7-6.6.2.534.zip --out-jar /tmp/n/test.jar --srg-in https://raw.github.com/MinecraftForge/FML/master/conf/
2013-03-03 10:41:28 -08:00
Agaricus
9fcbdce6e7 Refactor Jar resource access and entry list
* Add getResource(), extracted from getClass()
* Remove getInputStream(), using getResource() instead
* Change getEntries() to getEntryNames(), hiding JarEntry
* Store filename for getFilename()
2013-03-02 19:04:10 -08:00
Agaricus
61270b1259 Privatize Jar file and main members; replace with accessors 2013-03-02 16:22:21 -08:00
Agaricus
fd908cb405 Fix missing class transformer on reversed mapping directory loading
Loading mappings from directories, with the 'reverse' option, would
not account for repackaging on field names. Add missing transform.
2013-03-02 15:19:07 -08:00
Agaricus
cc5391a5cf Add caching for remotely downloaded resources
Mappings or jars downloaded from http URLs given to --srg-in or
--in-jar, --first-jar, --second-jar, will be cached locally in
a temporary directory, and reused on subsequent invocations if
present. The cache can be invalidated with --force-redownload.
2013-03-01 20:53:03 -08:00
Agaricus
5b979a4da3 Save downloaded files to non-random temporary filenames
Fixes repeated downloads filling up your disk.
2013-03-01 20:30:42 -08:00
Agaricus
a6e18b0665 Move loadMappings() dir/file logic to JarMapping
Instead of in the command-line interface.. this allows
other code providing an interface to SpecialSource to
easily pass user-supplied options for loading mappings.
2013-03-01 19:10:06 -08:00
Agaricus
91803d03ea Add support for remote --first-jar/--second-jar
Example:
java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --first-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --second-jar http://repo.bukkit.org/content/groups/public/org/bukkit/minecraft-server/1.4.7/minecraft-server-1.4.7.jar
2013-02-28 20:18:11 -08:00
Agaricus
308d1b4413 Add --numeric-srg option for using srg names (vs csv) on MCP dirs
Normally, --srg-in on a directory will load joined.srg or
client.srg and server.srg, translated through fields.csv,
methods.csv, and packages.csv, if available. --numeric will
ignore fields.csv and methods.csv, remapping the jar to
the numeric "srg" names instead of descriptive "csv" names.
(packages.csv will still be used if it exists; if you want
flat packaging then specify joined.srg to --srg-in directly.)
2013-02-27 21:56:07 -08:00
Agaricus
e36a60a078 Add support for remote --srg-in mappings
Mappings can now be downloaded from remote URLs. Both
individual .srgs and directories of .srg/.csv are supported.
Examples:

java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --out-jar /tmp/net.jar --srg-in https://raw.github.com/MinecraftForge/FML/master/conf/joined.srg
java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --out-jar /tmp/net2.jar --srg-in https://raw.github.com/MinecraftForge/FML/master/conf/
2013-02-27 21:37:02 -08:00