Skip to content

Commit

Permalink
Fix long value handling in annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Jan 28, 2011
1 parent 5ccf0d2 commit 926c390
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jboss/jandex/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ private long decodeLongEntry(int index) {
int[] offsets = constantPoolOffsets;

int pos = offsets[index - 1];
if (pool[pos] != CONSTANT_INTEGER)
throw new IllegalStateException("Constant pool entry is not an integer info type: " + index + ":" + pos);
if (pool[pos] != CONSTANT_LONG)
throw new IllegalStateException("Constant pool entry is not an long info type: " + index + ":" + pos);

return bitsToLong(pool, pos);
}
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/org/jboss/jandex/test/BasicTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class BasicTestCase {
public @interface TestAnnotation {
String name();
int[] ints();

long longValue();
Class<?> klass();
NestedAnnotation nested();
ElementType[] enums();
Expand All @@ -57,7 +59,7 @@ public class BasicTestCase {
}

@TestAnnotation(name = "Test", ints = { 1, 2, 3, 4, 5 }, klass = Void.class, nested = @NestedAnnotation(1.34f), nestedArray = {
@NestedAnnotation(3.14f), @NestedAnnotation(2.27f) }, enums = { ElementType.TYPE, ElementType.PACKAGE })
@NestedAnnotation(3.14f), @NestedAnnotation(2.27f) }, enums = { ElementType.TYPE, ElementType.PACKAGE }, longValue = 10)
public class DummyClass {
}

Expand Down Expand Up @@ -98,6 +100,7 @@ private void verifyDummy(Index index) {
assertTrue(2.27f == instance.value("nestedArray").asNestedArray()[1].value().asFloat());
assertEquals(ElementType.TYPE.name(), instance.value("enums").asEnumArray()[0]);
assertEquals(ElementType.PACKAGE.name(), instance.value("enums").asEnumArray()[1]);
assertEquals(10, instance.value("longValue").asLong());

// Verify target
assertEquals(DummyClass.class.getName(), instance.target().toString());
Expand Down

0 comments on commit 926c390

Please # to comment.