aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs150/pr114005/Declaration2.java
blob: 0e0b959c50c717db5164a4b647b2d0c67be2c587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.lang.annotation.*;
import java.lang.reflect.*;

@Retention(RetentionPolicy.RUNTIME)
@interface SampleAnnotation { }

interface TestInterface { }

class Test implements TestInterface{}

// Second case: the ITD is annotated via a declare @field.
public aspect Declaration2 {

	declare @field: * TestInterface.secondProperty: @SampleAnnotation;
	
	// ITD directly on the implementor
    @SampleAnnotation 
	public String Test.firstProperty;
	
    // ITD on the interface
	public String TestInterface.secondProperty;

	public static void main(String[] args) {
		for (Field field: Test.class.getFields()) {
			StringBuffer sb = new StringBuffer();
			sb.append(field.toString());
			boolean b = field.isAnnotationPresent(SampleAnnotation.class);
			sb.append(" has annotation:").append(b);
			System.out.println(sb.toString());
		}
	}
}