Example usage for java.lang System identityHashCode

List of usage examples for java.lang System identityHashCode

Introduction

In this page you can find the example usage for java.lang System identityHashCode.

Prototype

@HotSpotIntrinsicCandidate
public static native int identityHashCode(Object x);

Source Link

Document

Returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode().

Usage

From source file:de.kaiserpfalzEdv.commons.dto.NameBuilder.java

public Comparator<Nameable> getShortNameComparator() {
    return new Comparator<Nameable>() {
        @Override//from  w w  w.j  a  va  2 s  .  c  o m
        public int compare(Nameable o1, Nameable o2) {
            return new CompareToBuilder().append(o1.getShortName(), o2.getShortName()).build();
        }

        @Override
        public String toString() {
            return "ShortNameComparator@" + System.identityHashCode(this);
        }
    };
}

From source file:org.envirocar.app.application.service.BackgroundServiceImpl.java

@Override
public IBinder onBind(Intent intent) {
    logger.info("onBind " + getClass().getName() + "; Hash: " + System.identityHashCode(this));
    return binder;
}

From source file:com.googlecode.jsonrpc4j.spring.JsonProxyFactoryBean.java

/**
 * {@inheritDoc}/*from  w  w w  .  j ava  2 s  . com*/
 */
public Object invoke(MethodInvocation invocation) throws Throwable {

    // handle toString()
    Method method = invocation.getMethod();
    if (method.getDeclaringClass() == Object.class && method.getName().equals("toString")) {
        return proxyObject.getClass().getName() + "@" + System.identityHashCode(proxyObject);
    }

    // get return type
    Type retType = (invocation.getMethod().getGenericReturnType() != null)
            ? invocation.getMethod().getGenericReturnType()
            : invocation.getMethod().getReturnType();

    // get arguments
    Object arguments = ReflectionUtil.parseArguments(invocation.getMethod(), invocation.getArguments(),
            useNamedParams);

    // invoke it
    return jsonRpcHttpClient.invoke(invocation.getMethod().getName(), arguments, retType, extraHttpHeaders);
}

From source file:com.teletalk.jserver.util.SpillOverByteArrayOutputStream.java

/**
 * Performs spill over./*  w  w w .  j av  a  2s . com*/
 */
private void spillOver() {
    try {
        this.spillOverFile = File.createTempFile("SpillOver" + Long.toHexString(
                (long) System.identityHashCode(Thread.currentThread()) + (long) System.identityHashCode(this)),
                ".tmp");

        this.spillOverFileOutputStream = new BufferedOutputStream(new FileOutputStream(this.spillOverFile));
        if (this.byteArrayOutputStream != null) {
            this.byteArrayOutputStream.writeTo(this.spillOverFileOutputStream);
            this.byteArrayOutputStream = null;
        }
    } catch (Exception e) {
        this.spillOverFileOutputStream = null;
        this.spillOverFailed = true;

        Class commonsLoggingLogClass = null;
        try {
            commonsLoggingLogClass = Class.forName("org.apache.commons.logging.LogFactory");
        } catch (Throwable t) {
        }

        if (commonsLoggingLogClass != null) {
            org.apache.commons.logging.LogFactory.getLog(this.getClass())
                    .error("Error (" + e + ") creating spill over file!", e);
        } else {
            System.out.println("Error (" + e + ") creating spill over file!");
            e.printStackTrace();
        }
    }
}

From source file:org.apache.cayenne.event.EventSubject.java

/**
 * @return a String in the form <code>&lt;ClassName 0x123456&gt; SomeName</code>
 * @see Object#toString()//  w w  w  .ja  v a2  s .  c  om
 */
@Override
public String toString() {
    StringBuilder buf = new StringBuilder(64);

    buf.append("<");
    buf.append(this.getClass().getName());
    buf.append(" 0x");
    buf.append(Integer.toHexString(System.identityHashCode(this)));
    buf.append("> ");
    buf.append(_fullyQualifiedSubjectName);

    return buf.toString();
}

From source file:org.apache.mnemonic.collections.DurableHashMapNGTest.java

@BeforeClass
public void setUp() throws Exception {
    rand = Utils.createRandom();//from   w  w w. ja v a 2 s  .c om
    unsafe = Utils.getUnsafe();
    m_act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"),
            1024 * 1024 * 1024, "./pobj_hashmaps.dat", true);
    cKEYCAPACITY = m_act.handlerCapacity();
    m_act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
        @Override
        public boolean reclaim(ByteBuffer mres, Long sz) {
            System.out.println(String.format("Reclaim Memory Buffer: %X  Size: %s",
                    System.identityHashCode(mres), null == sz ? "NULL" : sz.toString()));
            System.out.println(" String buffer " + mres.asCharBuffer().toString());
            return false;
        }
    });
    m_act.setChunkReclaimer(new Reclaim<Long>() {
        @Override
        public boolean reclaim(Long mres, Long sz) {
            System.out.println(String.format("Reclaim Memory Chunk: %X  Size: %s",
                    System.identityHashCode(mres), null == sz ? "NULL" : sz.toString()));
            return false;
        }
    });

    for (long i = 0; i < cKEYCAPACITY; ++i) {
        m_act.setHandler(i, 0L);
    }
}

From source file:com.ayuget.redface.ui.fragment.PostsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d(LOG_TAG, String.format("@%d -> Fragment(currentPage=%d) -> onCreate", System.identityHashCode(this),
            currentPage));//from   w w w.  ja v  a 2s.c o m

    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        currentScrollPosition = 0;
    } else {
        currentScrollPosition = savedInstanceState.getInt(ARG_SAVED_SCROLL_POSITION, 0);
    }

    quotedMessages = new HashMap<>();
}

From source file:info.magnolia.module.servletsanity.support.ServletAssert.java

private static void appendRequestChain(HttpServletRequest request) throws IOException {
    append("Request Chain:");
    ServletRequest r = request;//from ww  w .j  a  va 2s .c  o  m
    do {
        append("&nbsp;&nbsp;&nbsp;&nbsp;" + r.getClass().getName() + " @ " + System.identityHashCode(r) + " - "
                + r.toString());
        r = r instanceof HttpServletRequestWrapper ? ((HttpServletRequestWrapper) r).getRequest() : null;
    } while (r != null);
    append("");
}

From source file:org.midonet.midolman.Midolman.java

public static void dumpStacks() {
    Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
    for (Thread thread : traces.keySet()) {
        System.err.print("\"" + thread.getName() + "\" ");
        if (thread.isDaemon())
            System.err.print("daemon ");
        System.err.print(String.format("prio=%x tid=%x %s [%x]\n", thread.getPriority(), thread.getId(),
                thread.getState(), System.identityHashCode(thread)));

        StackTraceElement[] trace = traces.get(thread);
        for (StackTraceElement e : trace) {
            System.err.println("        at " + e.toString());
        }//from w  w  w .  ja v a2 s  . co m
    }
}

From source file:com.tesora.dve.distribution.DistributionRange.java

public MappingSolution mapKeyToGeneration(IKeyValue key) throws PEException {
    StorageGroupGeneration groupGen = storageGroup.getLastGen();

    setComparatorClass(key);//w  w  w.j  ava  2s  .  co m
    ListIterator<GenerationKeyRange> i = rangeGenerations.listIterator(rangeGenerations.size());
    while (i.hasPrevious()) {
        //TODO: this traverses from youngest to oldest, but returns oldest match or lastGen(), which can be confusing.  -sgossard
        GenerationKeyRange genKeyRange = i.previous();
        if (genKeyRange.isInRange(key))
            groupGen = genKeyRange.getStorageGroupGeneration();
        else
            break;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Mapping key " + key.toString() + " to generation " + groupGen.getVersion()
                + " using range " + this + " which has " + rangeGenerations.size()
                + " generations and is rep'd by object " + System.identityHashCode(this));
    }

    return getMappingInGeneration(key, groupGen);
}