List of usage examples for java.lang.ref Reference getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
static void printObject(Object obj) { System.out.println("find threadlocal var:" + obj); if (obj instanceof Object[]) { System.out.println("array:" + Arrays.deepToString((Object[]) obj)); } else if (obj instanceof Reference) { Reference ref = (Reference) obj; System.out.println("ref: " + ref.getClass().getName() + ",ref to " + ref.get()); } else {//from w ww. j a v a2s . co m System.out.println("others: " + obj); } }
From source file:Main.java
@SuppressWarnings("rawtypes") private static void printObject(ThreadLocal threadLocal, Object obj) { String threadLocalCls = threadLocal.getClass().getName(); if (threadLocal instanceof NamedThreadLocal) { System.out.print("......Spring threadlocal var: " + threadLocal + "="); } else if (obj == null || threadLocalCls.startsWith("java") || threadLocalCls.startsWith("sun")) { return;//from ww w . ja va 2s . co m } if (obj instanceof Object[]) { System.out.println(Arrays.deepToString((Object[]) obj)); } else if (obj instanceof java.lang.ref.Reference) { java.lang.ref.Reference ref = (Reference) obj; System.out.println(" ref " + ref.getClass().getName() + " ref to " + ref.get()); } else if (obj instanceof ThreadLocal) { ThreadLocal threadLc = (ThreadLocal) obj; String clssName = threadLc.getClass().getName(); System.out.println(threadLc.getClass().getName() + "=" + threadLc.get()); } else { System.out.println(obj); } }