MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / checkForUpdate

Method checkForUpdate

ij/src/main/java/ij/plugin/Compiler.java:85–113  ·  view source on GitHub ↗
(String plugin, String currentVersion)

Source from the content-addressed store, hash-verified

83 }
84
85 private void checkForUpdate(String plugin, String currentVersion) {
86 int slashIndex = plugin.lastIndexOf("/");
87 if (slashIndex==-1 || !plugin.endsWith(".jar"))
88 return;
89 String className = plugin.substring(slashIndex+1, plugin.length()-4);
90 File f = new File(Prefs.getImageJDir()+"plugins"+File.separator+"jars"+File.separator+className+".jar");
91 if (!f.exists() || !f.canWrite()) {
92 if (IJ.debugMode) IJ.log("checkForUpdate: jar not found ("+plugin+")");
93 return;
94 }
95 String version = null;
96 try {
97 Class c = IJ.getClassLoader().loadClass("Compiler");
98 version = "0.00a";
99 Method m = c.getDeclaredMethod("getVersion", new Class[0]);
100 version = (String)m.invoke(null, new Object[0]);
101 }
102 catch (Exception e) {}
103 if (version==null) {
104 if (IJ.debugMode) IJ.log("checkForUpdate: class not found ("+className+")");
105 return;
106 }
107 if (version.compareTo(currentVersion)>=0) {
108 if (IJ.debugMode) IJ.log("checkForUpdate: up to date ("+className+" "+version+")");
109 return;
110 }
111 boolean ok = Macro_Runner.downloadJar(plugin);
112 if (IJ.debugMode) IJ.log("checkForUpdate: "+className+" "+version+" "+ok);
113 }
114
115 boolean isJavac() {
116 if (compilerTool==null)

Callers 1

compileAndRunMethod · 0.95

Calls 9

getImageJDirMethod · 0.95
logMethod · 0.95
getClassLoaderMethod · 0.95
downloadJarMethod · 0.95
substringMethod · 0.80
invokeMethod · 0.80
lengthMethod · 0.65
existsMethod · 0.45
compareToMethod · 0.45

Tested by

no test coverage detected