Search in sources :

Example 1 with AnnotatedType

use of java.lang.reflect.AnnotatedType in project immutables by immutables.

the class ValuesTest method java8TypeAnnotation.

@Test
public void java8TypeAnnotation() throws Exception {
    Method method = ImmutableHasTypeAnnotation.class.getMethod("str");
    AnnotatedType returnType = method.getAnnotatedReturnType();
    check(returnType.getAnnotation(TypeA.class)).notNull();
    check(returnType.getAnnotation(TypeB.class)).notNull();
}
Also used : AnnotatedType(java.lang.reflect.AnnotatedType) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with AnnotatedType

use of java.lang.reflect.AnnotatedType in project jdk8u_jdk by JetBrains.

the class GetAnnotatedSuperclass method testReturnsEmptyAT.

private static void testReturnsEmptyAT() {
    for (Class<?> toTest : nonNullTestData) {
        tests++;
        AnnotatedType res = toTest.getAnnotatedSuperclass();
        if (res == null) {
            failed++;
            System.out.println(toTest + ".getAnnotatedSuperclass() returns 'null' should  be non-null");
        } else if (res.getAnnotations().length != 0) {
            failed++;
            System.out.println(toTest + ".getAnnotatedSuperclass() returns: " + Arrays.asList(res.getAnnotations()) + ", should be an empty AnnotatedType");
        }
    }
}
Also used : AnnotatedType(java.lang.reflect.AnnotatedType)

Example 3 with AnnotatedType

use of java.lang.reflect.AnnotatedType in project titan by thinkaurelius.

the class TestBed method main.

/**
     * @param args
     * @throws java.io.IOException
     */
public static void main(String[] args) throws Exception {
    Method method = TestBed.class.getMethod("getInt", int.class, int.class);
    AnnotatedType rt = method.getAnnotatedReturnType();
    System.out.println(rt.getType());
    System.out.println(rt.getAnnotations().length);
    System.out.println(method.getAnnotations().length);
    for (int i = 0; i < method.getAnnotations().length; i++) {
        System.out.println(method.getAnnotations()[i]);
    }
    //        String[] s = {"a","b","c","d","e","f","g","h","i","x","u"};
    //        int len = s.length;
    //        Random random = new Random();
    //
    //        Context c = new Context(new ObserverManager(),Observer.NO_OP);
    //        //Warmup
    //        for (int i = 0; i < 1000000000; i++) {
    //            c.observe(s[1],s[2]);
    //        }
    //        long before = System.nanoTime();
    //        for (int i = 0; i < 1000000000; i++) {
    //            c.observe(s[1],s[2]);
    //        }
    //        long total = System.nanoTime()-before;
    //        System.out.println("Total time: " + total/1000000);
    System.exit(0);
    final ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(1, new RejectedExecutionHandler() {

        @Override
        public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
            r.run();
        }
    });
    ScheduledFuture future = exe.scheduleWithFixedDelay(new Runnable() {

        AtomicInteger atomicInt = new AtomicInteger(0);

        @Override
        public void run() {
            try {
                for (int i = 0; i < 10; i++) {
                    exe.submit(new Runnable() {

                        private final int number = atomicInt.incrementAndGet();

                        @Override
                        public void run() {
                            try {
                                Thread.sleep(150);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            System.out.println(number);
                        }
                    });
                    System.out.println("Submitted: " + i);
                //                    doSomethingExpensive(20);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, 0, 1, TimeUnit.SECONDS);
    Thread.sleep(10000);
    //        future.get(1,TimeUnit.SECONDS);
    System.out.println("Cancel: " + future.cancel(false));
    System.out.println("Done: " + future.isDone());
    exe.shutdown();
    //        Thread.sleep(2000);
    System.out.println("Terminate: " + exe.awaitTermination(5, TimeUnit.SECONDS));
    System.out.println("DONE");
    NonBlockingHashMapLong<String> id1 = new NonBlockingHashMapLong<String>(128);
    ConcurrentHashMap<Long, String> id2 = new ConcurrentHashMap<Long, String>(128, 0.75f, 2);
}
Also used : NonBlockingHashMapLong(org.cliffc.high_scale_lib.NonBlockingHashMapLong) Method(java.lang.reflect.Method) AnnotatedType(java.lang.reflect.AnnotatedType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NonBlockingHashMapLong(org.cliffc.high_scale_lib.NonBlockingHashMapLong) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 4 with AnnotatedType

use of java.lang.reflect.AnnotatedType in project janusgraph by JanusGraph.

the class TestBed method main.

/**
 * @param args
 * @throws java.io.IOException
 */
public static void main(String[] args) throws Exception {
    Method method = TestBed.class.getMethod("getInt", int.class, int.class);
    AnnotatedType rt = method.getAnnotatedReturnType();
    System.out.println(rt.getType());
    System.out.println(rt.getAnnotations().length);
    System.out.println(method.getAnnotations().length);
    for (int i = 0; i < method.getAnnotations().length; i++) {
        System.out.println(method.getAnnotations()[i]);
    }
    // String[] s = {"a","b","c","d","e","f","g","h","i","x","u"};
    // int len = s.length;
    // Random random = new Random();
    // 
    // Context c = new Context(new ObserverManager(),Observer.NO_OP);
    // //Warmup
    // for (int i = 0; i < 1000000000; i++) {
    // c.observe(s[1],s[2]);
    // }
    // long before = System.nanoTime();
    // for (int i = 0; i < 1000000000; i++) {
    // c.observe(s[1],s[2]);
    // }
    // long total = System.nanoTime()-before;
    // System.out.println("Total time: " + total/1000000);
    System.exit(0);
    final ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(1, (r, executor) -> r.run());
    ScheduledFuture future = exe.scheduleWithFixedDelay(new Runnable() {

        final AtomicInteger atomicInt = new AtomicInteger(0);

        @Override
        public void run() {
            try {
                for (int i = 0; i < 10; i++) {
                    exe.submit(new Runnable() {

                        private final int number = atomicInt.incrementAndGet();

                        @Override
                        public void run() {
                            try {
                                Thread.sleep(150);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            System.out.println(number);
                        }
                    });
                    System.out.println("Submitted: " + i);
                // doSomethingExpensive(20);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, 0, 1, TimeUnit.SECONDS);
    Thread.sleep(10000);
    // future.get(1,TimeUnit.SECONDS);
    System.out.println("Cancel: " + future.cancel(false));
    System.out.println("Done: " + future.isDone());
    exe.shutdown();
    // Thread.sleep(2000);
    System.out.println("Terminate: " + exe.awaitTermination(5, TimeUnit.SECONDS));
    System.out.println("DONE");
}
Also used : AnnotatedType(java.lang.reflect.AnnotatedType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Method(java.lang.reflect.Method)

Aggregations

AnnotatedType (java.lang.reflect.AnnotatedType)4 Method (java.lang.reflect.Method)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 NonBlockingHashMapLong (org.cliffc.high_scale_lib.NonBlockingHashMapLong)1 Test (org.junit.Test)1