Browse souce code repository at: https://github.com/jjYBdx4IL/java-evaluation/blob/master/src/test/java/tests/java/lang/ReflectTest.java
package tests.java.lang;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import java.lang.reflect.Field;

import javax.inject.Inject;

//@meta:keywords:reflection,reflect,declared,field,access@
public class ReflectTest {

    @Inject
    int one = 123;

    //@meta:keywords:declared,field,access,annotation,injection@
    @Test
    public void testFieldAccess() throws Exception {
        assertEquals(0, getClass().getFields().length);
        assertEquals(1, getClass().getDeclaredFields().length);
        
        // retrieve field value via reflection
        Field f = ReflectTest.class.getDeclaredField("one");
        assertEquals(int.class, f.getType());
        assertEquals("one", f.getName());
        assertEquals("ReflectTest", f.getDeclaringClass().getSimpleName());
        assertEquals(123, f.getInt(this));
        
        // update via reflection
        f.set(this, 124);
        assertEquals(124, one);
        
        // can be found via its annotation, ie. for injection
        assertTrue(f.isAnnotationPresent(Inject.class));
    }

    @Test(expected = NoSuchFieldException.class)
    public void testNotExisting() throws Exception {
        getClass().getField("notexisting");
    }
}
-------------------------------------------------------------------------------
Test set: tests.java.lang.ReflectTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in tests.java.lang.ReflectTest
testFieldAccess  Time elapsed: 0 s
testNotExisting  Time elapsed: 0 s