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.
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
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
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.
The input is now a BufferedReader, so you can read from a file with
new BufferedReader(new FileReader(...)), or from an input stream with
new BufferedReader(new InputStreamReader(...)).
RemappedRuntimeInheritanceProvider is similar to RuntimeInheritanceProvider, providing
access to inheritance information at runtime, but class names are remapped before
looking up, and the inheritance is reverse-remapped before returning.
This allows the inheritance to be provided from an obfuscated jar, via the cb2obf
mappings. For example:
java -cp target/SpecialSource-1.2-SNAPSHOT-shaded.jar:mcpc-plus-1.4.7-R0.2-SNAPSHOT-023.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/IncompatiblePlugin-01.jar --out-jar /tmp/sp/out.jar -L
-L enables remapped runtime inheritance, in order to use the obfuscated MCPC+ jar classes
to lookup the inherited classes for remapping. The same mappings are used as for remapping
the plugin (--srg-in and --shade-relocation take effect).
The original option, -l, in contrast does not remap on class lookup, and can be used to
lookup inheritance from a jar with CraftBukkit mappings, for example:
java -cp target/SpecialSource-1.2-SNAPSHOT-shaded.jar:craftbukkit-1.4.7-R0.1.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/IncompatiblePlugin-01.jar --out-jar /tmp/sp/out.jar -l
The JarRemapper constructor is now public; you can create a remapper
with a JarMapping and list of IInheritanceProviders, and then use it
to remap an entire jar with remapJar(), or individual classes using
remapClassFile().
If -l is specified, will now traverse the runtime class hierarchy in
tryClimb to determine the method/symbol from the parent to remap, in
addition to the classes in the jar.
This can be used to remap plugins that call into external classes.
For example, with a Bukkit plugin:
java -cp ../jars/craftbukkit-1.4.7-R0.1.jar:target/SpecialSource-1.1-SNAPSHOT.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 ../IncompatiblePlugin/IncompatiblePlugin-01.jar --out /tmp/bp/out.jar
using:
https://bitbucket.org/agaricusb/incompatibleplugin/downloads/IncompatiblePlugin-01.jar6d75d94496
agaricus/plugins/IncompatiblePlugin/SamplePosCommand.java will be remapped:
worldServer.q(...)
from worldServer.getTileEntity(). World provides getTileEntity and is remapped in cb2obf;
but WorldServer subclasses World and overrides getTileEntiy.. this information is not
available in the plugin itself and would not be remapped alone. By adding the CB jar to
the classpath and enabling runtime inheritance, the call is correctly remapped.
The --shade-relocation/-R option causes the --srg-in mapping old class
names to be transformed with the pattern. Multiple patterns can be given,
though currently only exact prefix matches are supported.
Example:
--shade-relocation net.minecraft.server=net.minecraft.server.v1_4_R1
--shade-relocation org.bouncycastle=net.minecraft.v1_4_R1.org.bouncycastle
The mapping will be 'shaded' before being applied to the jar.
You can use these options with --srg-in 1.4.7/cb2obf.csrg to remap plugins
which depend on the version-shaded class names (aka 'vcb').