Commit Graph

237 Commits

Author SHA1 Message Date
Agaricus
7ab477500c Fix incomplete shade relocation of .srg files
.csrg OK
2013-02-20 20:39:54 -08:00
Agaricus
f643febd34 Refactor ShadeRelocationSimulator into JarMappingInputTransformer
JarMappings loaded from disk are now transformed through a
JarMappingInputTransformer interface, which can arbitrarily
transform classes on loading. Currently only implemented
by ShadeRelocationSimulator.
2013-02-20 20:26:50 -08:00
Agaricus
04ca0de2f4 Add support for reading mappings from directories
MCP conf directories: packaged.srg, joined.srg or server.srg+client.srg
2013-02-20 20:10:53 -08:00
Agaricus
db83423bf5 Add opencsv dependency 2013-02-20 19:42:40 -08:00
Agaricus
abafa99ab3 Add CLI support for multiple --srg-in mappings
You could always load multiple mappings by calling loadMapping()
multiple times (as in MCPC+), but now it is also supported for
command-line usage. --srg-in mapping1.srg --srg-in mapping2.srg...
equivalent to cat mapping1.srg mapping2.srg.
2013-02-20 19:13:08 -08:00
Agaricus
2cb7a3c96d Add CLI alternate syntax for shade relocation
--srg-in ../jars/1.4.7/cb2pkgmcp.srg --shade-relocation net.minecraft.server=net.minecraft.server.v1_4_R1,org.bouncycastle=net.minecraft.v1_4_R1.org.bouncycastle
--srg-in ../jars/1.4.7/cb2pkgmcp.srg@net.minecraft.server=net.minecraft.server.v1_4_R1,org.bouncycastle=net.minecraft.v1_4_R1.org.bouncycastle
2013-02-20 19:03:39 -08:00
Agaricus
5b02d05ed2 Cache negative hits in InheritanceMap 2013-02-18 19:07:08 -08:00
Agaricus
3d40eca480 Cache inheritance mapping in JarMapping
JarMapping now maintains an InheritanceMap, and will populate
from IInheritanceProvider, if given. This allows inheritance to
be cached either locally or globally (across different JarMappings).
2013-02-18 18:45:48 -08:00
Agaricus
a8b5ebcbc6 Revert "Add a 'fallback' to InheritanceMap"
This reverts commit d2c2ad65db.
2013-02-18 18:15:49 -08:00
Agaricus
d2c2ad65db Add a 'fallback' to InheritanceMap
setFallback() allows an IInheritanceProvider to be specified which
will be consulted when inheritance for a requested class is unavailable.
If it returns a value, the inheritance will be cached in the InheritanceMap.
2013-02-18 18:14:31 -08:00
Agaricus
a430689c64 Add support for remapping subpackages in package map
Change data structure to a linked hash map, preserving insertion
order. This allows subpackages to be inserted into the package
map for remapping, before their parent package. For example,
A/B/C -> X and A/B -> Y. With the unordered HashMap data structure,
this was not possible (reliably). With LinkedHashMap, now it is.
2013-02-17 12:28:19 -08:00
Agaricus
fc8bae3e04 Add accessors for InheritanceMap and remove public access 2013-02-16 23:54:09 -08:00
Agaricus
1c18d27d8a Combine reflection remapping into RemapperPreprocessor
Allows simultaneously extracting inheritance information,
and remapping reflection -- all in a single pass.
2013-02-06 21:36:50 -08:00
Agaricus
5dc73a76ec Add RemapperPreprocessor
Used to "preprocess" a class file, using the ASM tree API,
before remapping with JarRemapper. Right now it only
extracts the inheritance and adds to an InheritanceMap.

Code moved from MCPC+ PluginClassLoader.
2013-02-06 20:41:05 -08:00
Agaricus
0bc766f8e7 Add debug option to ReflectionRemapper 2013-02-05 21:54:35 -08:00
Agaricus
3be71eee94 Use tryClimb in ReflectionRemapper 2013-02-05 21:54:35 -08:00
Agaricus
20dfec9ce3 Refactor tryClimb() into JarMapping
JarMapping now contains the IInheritanceProvider and tryClimb()
instead of JarRemapper, to allow other remappers access to the
same inheritance traversal code.
2013-02-05 21:54:35 -08:00
Agaricus
6e34774a46 Initial implementation of field reflection remapper
Remaps the string constant in class.getDeclaredField("fieldname")
2013-02-05 21:54:35 -08:00
Agaricus
874e759a9d Add remapClassFile() accepting byte[] instead of InputStream 2013-02-05 21:54:35 -08:00
Agaricus
c562f814b5 Expose jarMapping and inheritanceProvider in JarMapping 2013-02-05 21:54:35 -08:00
md_5
1b1857aeaa Don't need that validation either 2013-02-04 20:45:20 +11:00
md_5
45ccb010c0 SRG files can still be valid even without that check - they may not be mapping complete jars. That belongs in debug log at best. 2013-02-04 20:22:13 +11:00
Agaricus
147a04ddfc Fix package renaming in csrg mappings
The trailing slash was being remapped, causing incorrect package names.
Expected format is for example:

org/bukkit/craftbukkit/v1_4_6/ org/bukkit/craftbukkit/v1_4_R1

to replace org/bukkit/craftbukkit/v1_4_6 -> org/bukkit/craftbukkit/v1_4_R1
The trailing slash is only to disambiguate from class remaps in csrg.
2013-02-03 14:55:02 -08:00
Agaricus
0ef12539d9 Add package mapping count to log output 2013-02-03 14:47:05 -08:00
md_5
0da951d711 Java 6 support 2013-02-03 19:32:50 +11:00
md_5
898cb2320b Skip empty lines + comments in SRG 2013-02-03 19:28:47 +11:00
Agaricus
e602ed5dc8 Improve error messages for csrg/srg mapping file parsing 2013-02-02 22:38:46 -08:00
Agaricus
79bc85e8b0 Add standard srg format support to --srg-in
Previously, only the (much easier to parse) 'csrg' format was supported
2013-02-02 20:52:57 -08:00
Agaricus
ccf4bd5abd Add empty inheritance provider singleton
Previously, an empty list would signify no inheritance information.
2013-02-01 23:41:25 -08:00
Agaricus
fbd2b64a61 Simplify inheritance lookup
Remap through only one inheritance provider, instead of a list of them.

The multiple inheritance provider lookup functionality (check each one,
in order, until one provider responds for the class name) is still
available, but refactored into a new InheritanceProviders class.

Simplifies the common case of only having one inheritance provider, and
also reduces the redundant looping code previously in JarMapper/InheritanceMap.
2013-01-31 19:49:45 -08:00
Agaricus
8ee18916f1 Add remapped inheritance map file reading
The inheritance map, as generated with --write-inheritance/-H, can now
be read using --read-inheritance/-H. It will be remapped through the
currently loaded inverse mapping before supplying the inheritance provider.

Example usage:

java -cp target/SpecialSource-1.3-SNAPSHOT-shaded.jar net.md_5.specialsource.SpecialSource --shade-relocation net.minecraft.server=net.minecraft.server.v1_4_R1 --shade-relocation org.bouncycastle=net.minecraft.v1_4_R1.org.bouncycastle --srg-in ../jars/1.4.7/cb2obf.csrg --in-jar ../IncompatiblePlugin/target/bukkit-sample-plugin-0.5.jar  --out-jar /tmp/sp/out.jar  -h /tmp/h

where the inheritance map was previously generated using:

java -cp target/SpecialSource-1.3-SNAPSHOT-shaded.jar:mcpc-plus-1.4.7-R0.2-SNAPSHOT.jar net.md_5.specialsource.SpecialSource --srg-in ~/minecraft/1.4.x/jars/1.4.7/cb2obf.csrg --live --write-inheritance /tmp/h
2013-01-29 21:32:50 -08:00
Agaricus
4725e6d913 Add inheritance map file reading 2013-01-29 20:31:47 -08:00
Agaricus
29900947d1 Add missing copyrights 2013-01-29 19:33:39 -08:00
Agaricus
0ecf1100de Reduce unnecessary output in generated inheritance map
Only includes mapped classes in the parents, and only includes entries
for classes which have relevant parents (extends/implements classes).
Shrinks inheritance map on MCPC+ build 73 by 279 lines.
2013-01-29 19:25:31 -08:00
Agaricus
fbe56aec27 Add option to generate unrenamed symbols in mapping output 2013-01-28 22:42:01 -08:00
Agaricus
97b6e4179f Sort inheritance map written to file 2013-01-27 13:32:04 -08:00
Agaricus
a64fb14abd Add inheritance map writing
New --write-inheritance/-H command-line option, iterates all classes
in mapping and writes inheritance (interfaces and superclasses) to file.

Example usage, generating inheritance map from MCPC+:

java -cp target/SpecialSource-1.3-SNAPSHOT-shaded.jar:mcpc-plus-1.4.7-R0.2-SNAPSHOT.jar net.md_5.specialsource.SpecialSource --srg-in ~/minecraft/1.4.x/jars/1.4.7/cb2obf.csrg --live --write-inheritance /tmp/h
2013-01-27 13:22:44 -08:00
Agaricus
d23c72ae7a Add Guava dependency 2013-01-27 13:10:33 -08:00
Agaricus
c5964ee89d Add verbose mode to URLClassLoaderInheritanceProvider 2013-01-26 01:42:46 -08:00
Agaricus
4499220c61 Optimize RemappedRuntimeInheritanceProvider to not traverse inheritance if not remapped
Used to lookup the inheritance if every single class - now will return
null and allow other inheritance providers to answer instead.

Consequentially mapTypeName() has been enhanced to accept a 'default' type name:
pass the same typeName to 'pass through' unmapped names, or null if you want to
distinguish between unmapped and mapped names, as RemappedRuntimeInheritanceProvider does.
2013-01-26 01:30:29 -08:00
Agaricus
718ffc8bb5 Add verbose mode to RemappedRuntimeInheritanceProvider 2013-01-26 01:16:51 -08:00
Agaricus
89c00557a7 Fix recent regression in remapping inner classes
Broken in refactor in 3ff134311d
The outer class name (before '$') should be used for mapClassName.
2013-01-26 00:05:22 -08:00
Agaricus
25fcbb40fe Require explicit classloader for runtime inheritance
Previously, the runtime inheritance providers would always use the
system classloader. Now you have to explicitly pass the classloader
to use. Also add a 'verbose' flag for debugging.
2013-01-25 23:27:40 -08:00
Agaricus
41fefc0167 Always output class names in generated mappings, even if not renamed
Although SpecialSource avoids generating unnecessary output where
methods/fields are not renamed, the _absence_ of a class rename is
arguably as important as a class rename, especially when comparing
jars where nearly all classes are renamed.

In the common case of generating Minecraft mappings from an obfuscated
jar and an internally-renamed deobfuscated mc-dev jar, all classes
are renamed, except for one -- the main class:

net/minecraft/server/MinecraftServer net/minecraft/server/MinecraftServer

When the mc-dev server jar is shaded into CraftBukkit, all classes are
relocated under a versioned package. However, the shading relocation
simulator misses MinecraftServer since it is not included in the mappings,
as it isn't renamed.

Always outputting class names, regardless of whether they are renamed,
only increases the mapping file by one line and removes the need to
special-case MinecraftServer.
2013-01-25 21:48:00 -08:00
Agaricus
ba63cd9803 Remove obsolete throws on JarRemapper constructor
Now that mappings are loaded in JarRemapping, IOException is no longer thrown here.
2013-01-25 20:40:37 -08:00
md_5
db4ed56212 [maven-release-plugin] prepare for next development iteration 2013-01-25 14:29:15 +11:00
md_5
322c96347a [maven-release-plugin] prepare release SpecialSource-1.2.1 2013-01-25 14:28:59 +11:00
Agaricus
d60caf4345 Fix class file loading in URLClassLoaderInheritanceProvider 2013-01-24 19:22:14 -08:00
md_5
2b589946e8 [maven-release-plugin] prepare for next development iteration 2013-01-24 19:19:45 +11:00
md_5
b4a9f08e80 [maven-release-plugin] prepare release SpecialSource-1.2 2013-01-24 19:19:32 +11:00