Skip to content

Commit

Permalink
Proxy can be a native transformer handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumfrey committed Sep 4, 2017
1 parent d31ccf1 commit 3e0d070
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.spongepowered.asm.service.ILegacyClassTransformer;

import net.minecraft.launchwrapper.IClassTransformer;

Expand All @@ -38,7 +39,7 @@
* the mixin transformer itself. Only the latest proxy to be instantiated
* will actually provide callbacks to the underlying mixin transformer.
*/
public final class Proxy implements IClassTransformer {
public final class Proxy implements IClassTransformer, ILegacyClassTransformer {

/**
* All existing proxies
Expand Down Expand Up @@ -74,4 +75,23 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
return basicClass;
}

@Override
public String getName() {
return this.getClass().getName();
}

@Override
public boolean isDelegationExcluded() {
return true;
}

@Override
public byte[] transformClassBytes(String name, String transformedName, byte[] basicClass) {
if (this.isActive) {
return Proxy.transformer.transformClassBytes(name, transformedName, basicClass);
}

return basicClass;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ public Collection<ITransformer> getTransformers() {
List<IClassTransformer> transformers = Launch.classLoader.getTransformers();
List<ITransformer> wrapped = new ArrayList<ITransformer>(transformers.size());
for (IClassTransformer transformer : transformers) {
wrapped.add(new LegacyTransformerHandle(transformer));
if (transformer instanceof ITransformer) {
wrapped.add((ITransformer)transformer);
} else {
wrapped.add(new LegacyTransformerHandle(transformer));
}

if (transformer instanceof IClassNameTransformer) {
MixinServiceLaunchWrapper.logger.debug("Found name transformer: {}", transformer.getClass().getName());
Expand Down

0 comments on commit 3e0d070

Please sign in to comment.