Skip to content

Commit 2ae2e15

Browse files
committed
avoid laoding previous versions
1 parent bcbfb34 commit 2ae2e15

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/io/bioimage/modelrunner/pytorch/javacpp/PytorchJavaCPPInterface.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public class PytorchJavaCPPInterface implements DeepLearningEngineInterface
106106
private static final String DTYPE_KEY = "dtype";
107107
private static final String IS_INPUT_KEY = "isInput";
108108
private static final String MEM_NAME_KEY = "memoryName";
109+
/**
110+
* Name without vesion of the JAR created for this library
111+
*/
112+
private static final String JAR_FILE_NAME = "dl-modelrunner-pytorch-javacpp";
109113

110114
/**
111115
* Constructor for the interface. It is going to be called from the
@@ -463,6 +467,8 @@ private List<String> getProcessCommandsWithoutArgs() throws IOException, URISynt
463467
String codeSource = protectionDomain.getCodeSource().getLocation().getPath();
464468
String f_name = URLDecoder.decode(codeSource, StandardCharsets.UTF_8.toString());
465469
for (File ff : new File(f_name).getParentFile().listFiles()) {
470+
if (ff.getName().startsWith(JAR_FILE_NAME) && !ff.getAbsolutePath().equals(f_name))
471+
continue;
466472
classpath += ff.getAbsolutePath() + File.pathSeparator;
467473
}
468474
String className = PytorchJavaCPPInterface.class.getName();

0 commit comments

Comments
 (0)