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();
}
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");
}
}
}
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);
}
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");
}
Aggregations