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:org.neo4j.ogm.utils.EntityUtils.java

public static Long identity(Object entity, MetaData metaData) {

    ClassInfo classInfo = metaData.classInfo(entity);
    Object id = classInfo.identityField().readProperty(entity);
    return (id == null ? -System.identityHashCode(entity) : (Long) id);
}

From source file:Main.java

/**
 * Returns an empty array of the specified type.  The intent is that
 * it will return the same empty array every time to avoid reallocation,
 * although this is not guaranteed.//from w  w  w  . j  a va 2 s.c  o  m
 */
@SuppressWarnings("unchecked")
public static <T> T[] emptyArray(Class<T> kind) {
    if (kind == Object.class) {
        return (T[]) EMPTY;
    }

    int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF) % CACHE_SIZE;
    Object cache = sCache[bucket];

    if (cache == null || cache.getClass().getComponentType() != kind) {
        cache = Array.newInstance(kind, 0);
        sCache[bucket] = cache;

        // Log.e("cache", "new empty " + kind.getName() + " at " + bucket);
    }

    return (T[]) cache;
}

From source file:Main.java

/**
 * Returns an empty array of the specified type.  The intent is that
 * it will return the same empty array every time to avoid reallocation,
 * although this is not guaranteed./*  ww w. j  a v a 2s.  co m*/
 */
@SuppressWarnings("unchecked")
public static <T> T[] emptyArray(final Class<T> kind) {
    if (kind == Object.class) {
        return (T[]) EMPTY;
    }

    final int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF) % CACHE_SIZE;
    Object cache = sCache[bucket];

    if (cache == null || cache.getClass().getComponentType() != kind) {
        cache = Array.newInstance(kind, 0);
        sCache[bucket] = cache;

        // Log.e("cache", "new empty " + kind.getName() + " at " + bucket);
    }

    return (T[]) cache;
}

From source file:nz.co.senanque.logging.HashIdLogger.java

public static void log(Object object, Object id) {
    if (logger.isDebugEnabled()) {
        logger.debug("{}@{} {}", object.getClass(), System.identityHashCode(object), id);
    }// ww  w. j  a  va 2  s  .co  m
}

From source file:org.diffkit.util.DKObjectUtil.java

/**
 * Hex String representation of identity hashCode()
 *//*from w w w .  j av a 2  s. c o  m*/
public static String getAddressHexString(Object target_) {
    if (target_ == null)
        return null;
    return "@" + Integer.toHexString(System.identityHashCode(target_));
}

From source file:org.mule.util.ObjectUtils.java

/**
 * Like {@link #identityToString(Object)} but without the object's full package
 * name./*from   w w  w  .  ja  va 2 s  .  com*/
 *
 * @param obj the object for which the identity description is to be generated
 * @return the object's identity description in the form of
 *         "ClassName@IdentityCode" or "null" if the argument was null.
 */
public static String identityToShortString(Object obj) {
    if (obj == null) {
        return "null";
    } else {
        return new StringBuffer(40).append(ClassUtils.getSimpleName(obj.getClass())).append('@')
                .append(Integer.toHexString(System.identityHashCode(obj))).toString();
    }
}

From source file:nz.co.senanque.logging.HashIdLogger.java

public static void log(Object object, String id, BeanFactory beanFactory) {
    if (logger.isDebugEnabled()) {
        logger.debug("{}@{} {} {}", object.getClass(), System.identityHashCode(object), id, beanFactory);
    }/*w ww .j av a 2  s . c  o  m*/
}

From source file:org.eclipse.ecr.core.storage.sql.net.BinaryManagerServlet.java

/** Name used for the servlet holder for this servlet. */
public static String getName(BinaryManager binaryManager) {
    return BinaryManagerServlet.class.getSimpleName() + '-' + System.identityHashCode(binaryManager);
}

From source file:org.eclipse.ecr.runtime.util.SimpleRuntime.java

private static synchronized String generateId() {
    long stamp = System.currentTimeMillis();
    counter++;//w  w w .j a  va 2  s  .c  o  m
    return Long.toHexString(stamp) + '-' + System.identityHashCode(System.class) + '.' + counter;
}

From source file:chronos.beans.ChronosServiceBean.java

/**
 * Called by the J2EE container after EJB construction.
 *//*from ww  w  .j a  v  a 2s.co  m*/
@PostConstruct
public final void postConstruct() {
    logger.debug("ChronosServiceBean@" + System.identityHashCode(this) + "#postConstruct()...");
}