From 24ed3dc06bc133e4f718acc4a691e905b081fb11 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 21 Sep 2014 23:21:34 -0400 Subject: fixed bugs with anonymous/inner classes --- src/cuchaz/enigma/bytecode/InnerClassWriter.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/cuchaz/enigma/bytecode') diff --git a/src/cuchaz/enigma/bytecode/InnerClassWriter.java b/src/cuchaz/enigma/bytecode/InnerClassWriter.java index 5044e06..f94a85d 100644 --- a/src/cuchaz/enigma/bytecode/InnerClassWriter.java +++ b/src/cuchaz/enigma/bytecode/InnerClassWriter.java @@ -16,8 +16,10 @@ import javassist.CtClass; import javassist.bytecode.AccessFlag; import javassist.bytecode.ConstPool; import javassist.bytecode.Descriptor; +import javassist.bytecode.EnclosingMethodAttribute; import javassist.bytecode.InnerClassesAttribute; import cuchaz.enigma.analysis.JarIndex; +import cuchaz.enigma.mapping.BehaviorEntry; import cuchaz.enigma.mapping.ClassEntry; public class InnerClassWriter @@ -44,6 +46,18 @@ public class InnerClassWriter // this is an inner class, rename it to outer$inner ClassEntry obfClassEntry = new ClassEntry( obfOuterClassName + "$" + new ClassEntry( obfClassName ).getSimpleName() ); c.setName( obfClassEntry.getName() ); + + BehaviorEntry caller = m_jarIndex.getAnonymousClassCaller( obfClassName ); + if( caller != null ) + { + // write the enclosing method attribute + c.getClassFile().addAttribute( new EnclosingMethodAttribute( + c.getClassFile().getConstPool(), + caller.getClassName(), + caller.getName(), + caller.getSignature() + ) ); + } } // write the inner classes if needed -- cgit v1.2.3