Skip to content

Commit 5a1632b

Browse files
committed
Merge branch 'update-annotation-preprocessor'
This change allows library users to write SciJava plugins using java 8 language features without warnings and errors from the plugin indexer. Closes #218.
2 parents 77a9128 + 3d6a2bf commit 5a1632b

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
<url>http://jenkins.imagej.net/job/SciJava-common/</url>
115115
</ciManagement>
116116

117+
<properties>
118+
<scijava.jvm.test.version>1.8</scijava.jvm.test.version>
119+
</properties>
120+
117121
<dependencies>
118122
<!-- Third-party dependencies -->
119123
<dependency>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,19 @@ private double getDoubleConstant(final int index) {
107107
getU4(offset + 5));
108108
}
109109

110+
// See https://en.wikipedia.org/wiki/Java_class_file#The_constant_pool for the
111+
// meaning of the offsets behind these numbers
110112
private void getConstantPoolOffsets() {
111113
final int poolCount = getU2(8) - 1;
112114
poolOffsets = new int[poolCount];
113115
int offset = 10;
114116
for (int i = 0; i < poolCount; i++) {
115117
poolOffsets[i] = offset;
116118
final int tag = getU1(offset);
117-
if (tag == 7 || tag == 8) offset += 3;
118-
else if (tag == 9 || tag == 10 || tag == 11 || tag == 3 || tag == 4 ||
119-
tag == 12) offset += 5;
119+
if (tag == 7 || tag == 8 || tag == 16) offset += 3;
120+
else if (tag == 15) offset += 4;
121+
else if (tag == 3 || tag == 4 || tag == 9 || tag == 10
122+
|| tag == 11 || tag == 12 || tag == 18) offset += 5;
120123
else if (tag == 5 || tag == 6) {
121124
poolOffsets[++i] = offset;
122125
offset += 9;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.scijava.annotations;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
@Simple(string1 = "adfd")
7+
public class AnnotatedD {
8+
9+
public AnnotatedD() {
10+
List<String> list = new ArrayList<>();
11+
list.stream().reduce(String::concat).get();
12+
}
13+
}

src/test/java/org/scijava/annotations/DirectoryIndexerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testRepeatedClassPathElements() throws Exception {
122122
assertFalse(seen.contains(name));
123123
seen.add(name);
124124
}
125-
assertEquals(2, seen.size());
125+
assertEquals(3, seen.size());
126126
}
127127

128128
public static void

src/test/java/org/scijava/annotations/EclipseHelperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void testSkipIndexGeneration() throws Exception {
7171
public void testIndexing() throws Exception {
7272
final File dir = createTemporaryDirectory("eclipse-test-");
7373
copyClasses(dir, Complex.class, Simple.class, Fruit.class,
74-
AnnotatedA.class, AnnotatedB.class, AnnotatedC.class);
74+
AnnotatedA.class, AnnotatedB.class, AnnotatedC.class, AnnotatedD.class);
7575
final File jsonDir = new File(dir, Index.INDEX_PREFIX);
7676
for (final Class<?> clazz : new Class<?>[] { Complex.class, Simple.class })
7777
{
@@ -104,7 +104,7 @@ public Class<?> loadClass(final String className)
104104
// deleted
105105
jsonDir.setLastModified(123456789);
106106
for (final Class<?> clazz : new Class<?>[] { AnnotatedA.class,
107-
AnnotatedB.class, AnnotatedC.class })
107+
AnnotatedB.class, AnnotatedC.class, AnnotatedD.class })
108108
{
109109
assertTrue(new File(dir, DirectoryIndexerTest.getResourcePath(clazz))
110110
.delete());

0 commit comments

Comments
 (0)