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:nz.co.senanque.vaadin.formatting.FormatterDoubleTest.java

@Test
public void testIdentity() {
    TestIdentityObject l = new TestIdentityObject(100L);
    int i1 = System.identityHashCode(l);
    l.setLong(100L);//from  w w w.jav a 2 s.c om
    l.setString("hello");
    int i2 = System.identityHashCode(l);
    assertEquals(i1, i2);
}

From source file:com.github.errantlinguist.latticevisualiser.StateShapeTransformer.java

/**
 * /* ww w.  j av  a 2s. c o  m*/
 * @return The hash code.
 */
private int calculateHashCode() {
    final int prime = 31;
    int result = 1;
    // Get the identity hash code of the graph because it may change during
    // runtime (it is mutable)
    result = prime * result + (graph == null ? 0 : System.identityHashCode(graph));
    // result = prime * result
    // + (shapeFactory == null ? 0 : shapeFactory.hashCode());
    return result;
}

From source file:org.linkedin.glu.provisioner.plan.api.Plan.java

public String getId() {
    String id = (String) _metadata.get("id");

    if (id == null) {
        if (_step == null)
            id = Integer.toHexString(System.identityHashCode(this));
        else// w w w  . j  a v  a2  s . c  o  m
            id = getStep().getId();
    }

    return id;
}

From source file:com.github.errantlinguist.latticevisualiser.StatePaintTransformer.java

/**
 * //from  w ww. j a va2 s . c om
 * @return The hash code.
 */
private int calculateHashCode() {
    final int prime = 31;
    int result = 1;
    // Get the identity hash code of the graph because it may change during
    // runtime (it is mutable)
    result = prime * result + (graph == null ? 0 : System.identityHashCode(graph));
    return result;
}

From source file:com.alibaba.druid.pool.bonecp.TestPSCache.java

public static void f(DataSource ds, int count) throws Exception {
    Connection conn = ds.getConnection();

    for (int i = 0; i < count; ++i) {
        PreparedStatement stmt = conn.prepareStatement("SELECT 1");
        System.out.println(System.identityHashCode(unwrap(stmt)));
        stmt.close();/*w  ww . jav a  2s. c  o  m*/
    }

    conn.close();
}

From source file:org.mule.module.launcher.MuleSharedDomainClassLoader.java

@Override
public String toString() {
    return String.format("%s[%s]@%s", getClass().getName(), domain,
            Integer.toHexString(System.identityHashCode(this)));
}

From source file:gridool.util.GridUtils.java

@Nonnull
public static String generateTaskId(@Nonnull final String jobId, @Nonnull final GridTask task) {
    final long time = System.nanoTime();
    final int hashcode = System.identityHashCode(task);
    long tid = Thread.currentThread().getId();
    return jobId + '#' + Long.toString(time) + '/' + Integer.toString(hashcode) + 'T' + Long.toString(tid);
}

From source file:chronos.quartz.console.controllers.IndexController.java

/**
 * @param model//from ww  w .  j a v  a2s . c om
 *        {@link Model}
 */
@RequestMapping("/index.html")
@SuppressWarnings("unchecked")
public final void index(final Model model) {
    model.addAttribute("now", new Date());
    try {
        final StdSchedulerFactory factory = new StdSchedulerFactory();
        factory.initialize();
        final Collection<Scheduler> allSchedulers = factory.getAllSchedulers();
        logger.debug("Got " + allSchedulers.size() + " schedulers...");
        final Scheduler scheduler;
        if (allSchedulers.size() == 0) {
            logger.debug("Creating scheduler instance");
            scheduler = factory.getScheduler();
        } else {
            scheduler = allSchedulers.iterator().next();
            logger.debug("Using existing scheduler instance");
        }
        logger.debug("Got scheduler "
                + getUniqueIdentifier(scheduler.getSchedulerName(), scheduler.getSchedulerInstanceId()) + "@"
                + System.identityHashCode(scheduler));

        model.addAttribute("jobGroups", extractJobGroups(scheduler));
        model.addAttribute("triggerGroups", extractTriggers(scheduler));
    } catch (final SchedulerException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:com.ejisto.modules.web.util.FieldSerializationUtil.java

private static MockedField translateField(Field field, Object container, String className, String contextPath) {
    Class<?> fieldType = field.getType();
    MockedField out = buildMockedField(className, field.getName(), contextPath, fieldType.getName());
    Object value = safeGet(field, container);
    if (value == null || isBlackListed(fieldType)) {
        out.setFieldValue(null);/*from w w w .  j av  a2 s  .c o  m*/
        return out;
    }
    int hashCode = System.identityHashCode(value);
    String existingClassMapping = CACHED_IDS.putIfAbsent(hashCode, out.getFieldType());
    if (StringUtils.isNotBlank(existingClassMapping)) {
        out.setLink(String.valueOf(hashCode));
        return out;
    } else if (field.isEnumConstant() || fieldType.isPrimitive()) {
        out.setFieldValue(String.valueOf(value));
    } else {
        out.setExpression(translateValue(value));
    }
    out.setRecordedObjectHashCode(hashCode);
    return out;
}

From source file:org.eclipse.gemini.blueprint.compendium.internal.cm.DefaultManagedServiceBeanManager.java

public void unregister(Object bean) {
    int hashCode = System.identityHashCode(bean);
    if (log.isTraceEnabled())
        log.trace("Stopped tracking instance " + bean.getClass().getName() + "@" + hashCode);

    instanceRegistry.remove(new Integer(hashCode));
}