Skip to content

Commit 15dff7d

Browse files
Merge pull request #2260 from antlechner/antonia/annotation-class-value
Add support for Java annotations with Class value
2 parents e0a5142 + e0ad069 commit 15dff7d

11 files changed

+115
-2
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,9 @@ void java_bytecode_parsert::relement_value_pairs(
15141514
}
15151515
}
15161516

1517+
/// Corresponds to the element_value structure
1518+
/// Described in Java 8 specification 4.7.16.1
1519+
/// https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.16.1
15171520
void java_bytecode_parsert::relement_value_pair(
15181521
annotationt::element_value_pairt &element_value_pair)
15191522
{
@@ -1531,8 +1534,8 @@ void java_bytecode_parsert::relement_value_pair(
15311534

15321535
case 'c':
15331536
{
1534-
UNUSED u2 class_info_index=read_u2();
1535-
// todo: class
1537+
u2 class_info_index = read_u2();
1538+
element_value_pair.value = symbol_exprt(pool_entry(class_info_index).s);
15361539
}
15371540
break;
15381541

Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public @interface AnnotationWithClassType {
2+
Class<?> value();
3+
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@AnnotationWithClassType(java.lang.String.class)
2+
public class ClassWithClassTypeAnnotation {
3+
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@AnnotationWithClassType(byte.class)
2+
public class ClassWithPrimitiveTypeAnnotation {
3+
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@AnnotationWithClassType(void.class)
2+
public class ClassWithVoidTypeAnnotation {
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
java-testing-utils
2+
testing-utils
3+
java_bytecode

0 commit comments

Comments
 (0)