37
37
import com .oracle .graal .python .builtins .objects .dict .PDict ;
38
38
import com .oracle .graal .python .builtins .objects .object .PythonBuiltinObject ;
39
39
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
40
- import com .oracle .truffle .api .CompilerDirectives ;
41
40
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
42
41
import com .oracle .truffle .api .object .Shape ;
43
42
@@ -214,8 +213,8 @@ protected String makePackagePath(String fullname) {
214
213
* @return code
215
214
* @throws IOException
216
215
*/
217
- @ CompilerDirectives . TruffleBoundary
218
- private String getCode (String filenameAndSuffix ) throws IOException {
216
+ @ TruffleBoundary
217
+ public static String getCodeFromArchive (String filenameAndSuffix , String archive ) throws IOException {
219
218
ZipFile zip = null ;
220
219
try {
221
220
zip = new ZipFile (archive );
@@ -237,7 +236,7 @@ private String getCode(String filenameAndSuffix) throws IOException {
237
236
reader .close ();
238
237
return code .toString ();
239
238
} catch (IOException e ) {
240
- throw new IOException ( "Can not read code from " + makePackagePath ( filenameAndSuffix ), e ) ;
239
+ throw e ;
241
240
} finally {
242
241
if (zip != null ) {
243
242
try {
@@ -323,8 +322,12 @@ protected final ModuleCodeData getModuleCode(String fullname) throws IOException
323
322
324
323
boolean isPackage = entry .type .contains (EntryType .IS_PACKAGE );
325
324
326
- String code = "" ;
327
- code = getCode (searchPath );
325
+ String code ;
326
+ try {
327
+ code = getCodeFromArchive (searchPath , archive );
328
+ } catch (IOException e ) {
329
+ throw new IOException ("Can not read code from " + makePackagePath (searchPath ), e );
330
+ }
328
331
return new ModuleCodeData (code , isPackage , fullSearchPath );
329
332
}
330
333
return null ;
0 commit comments