@@ -62,15 +62,27 @@ public DexFactory(Logger logger, ClassLoader classLoader, File dexBaseDir, Strin
6262 static long totalMultiDexTime = 0 ;
6363 static long totalLoadDexTime = 0 ;
6464
65- public Class <?> resolveClass (String name , String className , String [] methodOverrides ) throws ClassNotFoundException , IOException
65+ public Class <?> resolveClass (String name , String className , String [] methodOverrides , boolean isInterface ) throws ClassNotFoundException , IOException
6666 {
67- String fullClassName = className .replace ("$" , "_" ) + CLASS_NAME_LOCATION_SEPARATOR + name ;
67+ String fullClassName = className .replace ("$" , "_" );
68+
69+ if (!isInterface ) {
70+ fullClassName += CLASS_NAME_LOCATION_SEPARATOR + name ;
71+ }
6872
6973 // try to get pre-generated binding classes
7074 try
7175 {
76+ if (logger .isEnabled ()) {
77+ logger .write ("getting pre-generated proxy class with name: " + fullClassName .replace ("-" , "_" ));
78+ }
79+
7280 Class <?> pregeneratedClass = classLoader .loadClass (fullClassName .replace ("-" , "_" ));
7381
82+ if (logger .isEnabled ()) {
83+ logger .write ("Pre-generated class found: " + fullClassName .replace ("-" , "_" ));
84+ }
85+
7486 return pregeneratedClass ;
7587 }
7688 catch (Exception e )
@@ -85,7 +97,12 @@ public Class<?> resolveClass(String name, String className, String[] methodOverr
8597 }
8698
8799 String classToProxy = this .getClassToProxyName (className );
88- String dexFilePath = classToProxy + CLASS_NAME_LOCATION_SEPARATOR + name ;
100+ String dexFilePath = classToProxy ;
101+
102+ if (!isInterface ) {
103+ dexFilePath += CLASS_NAME_LOCATION_SEPARATOR + name ;
104+ }
105+
89106 File dexFile = this .getDexFile (dexFilePath );
90107
91108 // generate dex file
@@ -97,7 +114,7 @@ public Class<?> resolveClass(String name, String className, String[] methodOverr
97114 logger .write ("generating proxy in place" );
98115 }
99116
100- dexFilePath = this .generateDex (name , classToProxy , methodOverrides );
117+ dexFilePath = this .generateDex (name , classToProxy , methodOverrides , isInterface );
101118 dexFile = new File (dexFilePath );
102119 long stopGenTime = System .nanoTime ();
103120 totalGenTime += stopGenTime - startGenTime ;
@@ -139,6 +156,7 @@ public Class<?> resolveClass(String name, String className, String[] methodOverr
139156 // be directly used.
140157 // However, this is the only viable way to get our dynamic classes
141158 // loaded within the system class loader
159+
142160 df = DexFile .loadDex (jarFilePath , new File (this .odexDir , fullClassName ).getAbsolutePath (), 0 );
143161 result = df .loadClass (fullClassName , classLoader );
144162 }
@@ -234,7 +252,7 @@ private File getDexFile(String className) throws InvalidClassException
234252 return null ;
235253 }
236254
237- private String generateDex (String proxyName , String className , String [] methodOverrides ) throws ClassNotFoundException , IOException
255+ private String generateDex (String proxyName , String className , String [] methodOverrides , boolean isInterface ) throws ClassNotFoundException , IOException
238256 {
239257 Class <?> classToProxy = Class .forName (className );
240258
@@ -249,7 +267,7 @@ private String generateDex(String proxyName, String className, String[] methodOv
249267 }
250268 }
251269
252- return proxyGenerator .generateProxy (proxyName , classToProxy , methodOverridesSet );
270+ return proxyGenerator .generateProxy (proxyName , classToProxy , methodOverridesSet , isInterface );
253271 }
254272
255273 private void updateDexThumbAndPurgeCache ()
0 commit comments