From feab9141c33f0100b4fda3cd861a3c6009c2f752 Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Mon, 12 Feb 2018 23:15:04 +0800 Subject: [PATCH] fix ctx classloader --- .../tweaker/AuthlibInjectorTweaker.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/to2mbn/authlibinjector/tweaker/AuthlibInjectorTweaker.java b/src/main/java/org/to2mbn/authlibinjector/tweaker/AuthlibInjectorTweaker.java index 17aeeb6..a42abca 100644 --- a/src/main/java/org/to2mbn/authlibinjector/tweaker/AuthlibInjectorTweaker.java +++ b/src/main/java/org/to2mbn/authlibinjector/tweaker/AuthlibInjectorTweaker.java @@ -18,9 +18,15 @@ public class AuthlibInjectorTweaker implements ITweaker { @Override public void injectIntoClassLoader(LaunchClassLoader launchClassLoader) { - log("launched from tweaker"); - bootstrap(transformers::add); - launchClassLoader.registerTransformer(TweakerTransformerAdapter.class.getName()); + ClassLoader originalCtxCl = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); + try { + log("launched from tweaker"); + bootstrap(transformers::add); + launchClassLoader.registerTransformer(TweakerTransformerAdapter.class.getName()); + } finally { + Thread.currentThread().setContextClassLoader(originalCtxCl); + } } @Override