4747import org .apache .commons .io .IOUtils ;
4848import org .objectweb .asm .ClassReader ;
4949import org .objectweb .asm .ClassWriter ;
50+ import org .objectweb .asm .Opcodes ;
5051import org .objectweb .asm .commons .JSRInlinerAdapter ;
5152import org .objectweb .asm .tree .AbstractInsnNode ;
5253import org .objectweb .asm .tree .ClassNode ;
@@ -64,6 +65,7 @@ public class Deobfuscator {
6465
6566 private final Configuration configuration ;
6667
68+ private final Set <String > missingRefs = new HashSet <>();
6769 private final Map <String , ClassNode > classpath = new HashMap <>();
6870 private final Map <String , ClassNode > libraries = new HashMap <>();
6971 private final Map <String , ClassNode > classes = new HashMap <>();
@@ -480,6 +482,11 @@ public boolean runFromConfig(TransformerConfig config) throws Throwable {
480482
481483 public ClassNode assureLoaded (String ref ) {
482484 ClassNode clazz = classpath .get (ref );
485+ // Attempt to fetch from runtime, cases like 'java/awt/bla' can be loaded this way
486+ if (clazz == null ) {
487+ clazz = pullFromRuntime (ref );
488+ }
489+ // Still missing, cannot recover
483490 if (clazz == null ) {
484491 throw new NoClassInPathException (ref );
485492 }
@@ -496,6 +503,23 @@ public ClassNode assureLoadedElseRemove(String referencer, String ref) {
496503 return clazz ;
497504 }
498505
506+ private ClassNode pullFromRuntime (String ref ) {
507+ try {
508+ if (!missingRefs .contains (ref )) {
509+ // Realistically we do not need the method bodies at all, can skip.
510+ ClassNode node = new ClassNode (Opcodes .ASM9 );
511+ new ClassReader (ref ).accept (node , ClassReader .SKIP_CODE );
512+ classpath .put (ref , node );
513+ return node ;
514+ }
515+ } catch (IOException ex ) {
516+ // Ignored, plenty of cases where ref will not exist at runtime.
517+ // Cache missing value so that we don't try again later.
518+ missingRefs .add (ref );
519+ }
520+ return null ;
521+ }
522+
499523 public void loadHierachy () {
500524 Set <String > processed = new HashSet <>();
501525 LinkedList <ClassNode > toLoad = new LinkedList <>(this .classes .values ());
0 commit comments