Skip to content

Commit 3115c43

Browse files
committed
EclipseHelper: skip unpacked ImageJ1 classes
This is a hacky workaround for the situation where ImageJ1 classes got loaded prematurely by the Eclipse helper when running from within Eclipse with a project coupling to ImageJA. Since we know that ImageJ1 will never use SciJava plugin annotations, we can safely skip loading those classes, thus preventing the premature loading in that scenario. As usual, thanks to Johannes Schindelin for his help with this fix!
1 parent 45918c3 commit 3115c43

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/org/scijava/annotations/EclipseHelper.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ private void maybeIndex(final URL url, final ClassLoader loader) {
207207

208208
private void index(File directory, ClassLoader loader) {
209209
debug("Directory: " + directory);
210-
if (!directory.canWrite() || upToDate(directory)) {
211-
debug("can write: " + directory.canWrite()
212-
+ ", up-to-date: " + upToDate(directory));
210+
if (!directory.canWrite() || upToDate(directory) || isIJ1(directory)) {
211+
debug("can write: " + directory.canWrite() + ", up-to-date: " +
212+
upToDate(directory) + ", : is IJ1: " + isIJ1(directory));
213213
return;
214214
}
215215
final File jsonDirectory = new File(directory, Index.INDEX_PREFIX);
@@ -234,6 +234,14 @@ private void index(File directory, ClassLoader loader) {
234234
}
235235
}
236236

237+
/**
238+
* A hacky way of detecting whether the given directory is the root of an
239+
* ImageJ1 codebase containing unpacked ImageJ1 classes.
240+
*/
241+
private boolean isIJ1(File directory) {
242+
return new File(directory, "IJ_Props.txt").exists();
243+
}
244+
237245
private boolean upToDate(final File directory) {
238246
final File jsonDirectory = new File(directory, Index.INDEX_PREFIX);
239247
if (!jsonDirectory.isDirectory()) {

0 commit comments

Comments
 (0)