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.eclipse.persistence.logging.AbstractSessionLog.java

/**
 * Return the specified connection information.
 *///from w ww  .j  a va  2s . c o m
protected String getConnectionString(Accessor connection) {
    // Bug 3630182 - if possible, print the actual connection's hashcode instead of just the accessor
    if (connection.getDatasourceConnection() == null) {
        return CONNECTION_STRING + "(" + String.valueOf(System.identityHashCode(connection)) + ")";
    } else {
        return CONNECTION_STRING + "("
                + String.valueOf(System.identityHashCode(connection.getDatasourceConnection())) + ")";
    }
}

From source file:de.fhg.igd.mapviewer.AbstractTileOverlayPainter.java

/**
 * @see java.lang.Comparable#compareTo(java.lang.Object)
 *//*  w w  w  .  j ava2s . co  m*/
@Override
public int compareTo(TileOverlayPainter other) {
    if (this == other)
        return 0;

    if (other instanceof AbstractTileOverlayPainter) {
        int priority = getPriority();
        int otherPriority = ((AbstractTileOverlayPainter) other).getPriority();

        if (priority < otherPriority) {
            return -1;
        } else if (priority > otherPriority) {
            return 1;
        }
    }

    int classCompare = getClass().getName().compareTo(other.getClass().getName());

    if (classCompare != 0) {
        return classCompare;
    }

    int hash = System.identityHashCode(this);
    int otherHash = System.identityHashCode(other);

    if (hash < otherHash)
        return -1;
    else if (hash > otherHash)
        return 1;

    return 0;
}

From source file:org.apache.calcite.avatica.jdbc.JdbcMeta.java

public StatementHandle prepare(ConnectionHandle ch, String sql, long maxRowCount) {
    try {//  w w w  .  ja v  a 2 s . c om
        final Connection conn = getConnection(ch.id);
        final PreparedStatement statement = conn.prepareStatement(sql);
        final int id = System.identityHashCode(statement);
        statementCache.put(id, new StatementInfo(statement));
        StatementHandle h = new StatementHandle(ch.id, id,
                signature(statement.getMetaData(), statement.getParameterMetaData(), sql));
        if (LOG.isTraceEnabled()) {
            LOG.trace("prepared statement " + h);
        }
        return h;
    } catch (SQLException e) {
        throw propagate(e);
    }
}

From source file:org.apache.ojb.broker.util.ReferenceMap.java

private int hashCode(Object obj) {
    return useSystemIdentity ? System.identityHashCode(obj) : obj.hashCode(); // null keys|values are not supported
}

From source file:com.cloud.utils.db.TransactionLegacy.java

protected void closeConnection() {
    closePreviousStatement();//from  w w  w.  j av  a2 s. co  m

    if (_conn == null) {
        return;
    }

    if (_txn) {
        s_connLogger.trace("txn: Not closing DB connection because we're still in a transaction.");
        return;
    }

    try {
        // we should only close db connection when it is not user managed
        if (_dbId != CONNECTED_DB) {
            if (s_connLogger.isTraceEnabled()) {
                s_connLogger.trace("Closing DB connection: dbconn" + System.identityHashCode(_conn));
            }
            _conn.close();
            _conn = null;
        }

    } catch (final SQLException e) {
        s_logger.warn("Unable to close connection", e);
    }
}

From source file:com.cloud.utils.db.Transaction.java

protected void closeConnection() {
    closePreviousStatement();//from ww w  .  j  av  a  2 s  .c o m

    if (_conn == null) {
        return;
    }

    if (_txn) {
        s_connLogger.trace("txn: Not closing DB connection because we're still in a transaction.");
        return;
    }

    try {
        // we should only close db connection when it is not user managed
        if (this._dbId != CONNECTED_DB) {
            if (s_connLogger.isTraceEnabled()) {
                s_connLogger.trace("Closing DB connection: dbconn" + System.identityHashCode(_conn));
            }
            _conn.close();
            _conn = null;
        }

    } catch (final SQLException e) {
        s_logger.warn("Unable to close connection", e);
    }
}

From source file:com.facebook.litho.DebugComponent.java

private static String createKey(InternalNode node, int componentIndex) {
    final InternalNode parent = node.getParent();
    final InternalNode nestedTreeHolder = node.getNestedTreeHolder();

    String key;/*from  w  w w .j  a  va2  s .c o m*/
    if (parent != null) {
        key = createKey(parent, 0) + "." + parent.getChildIndex(node);
    } else if (nestedTreeHolder != null) {
        key = createKey(nestedTreeHolder, 0) + ".nested";
    } else {
        final ComponentContext c = node.getContext();
        final ComponentTree tree = c.getComponentTree();
        key = Integer.toString(System.identityHashCode(tree));
    }

    return key + "(" + componentIndex + ")";
}

From source file:org.codehaus.groovy.grails.web.pages.GroovyPage.java

protected boolean isHtmlPart(String htmlPart) {
    return htmlPartsSet != null && htmlPart != null && htmlPartsSet.contains(System.identityHashCode(htmlPart));
}

From source file:com.jecelyin.editor.v2.core.text.TextUtils.java

/**
 * Debugging tool to print the spans in a CharSequence.  The output will
 * be printed one span per line.  If the CharSequence is not a Spanned,
 * then the entire string will be printed on a single line.
 */// w w w .  j a  v a 2 s  .c  om
public static void dumpSpans(CharSequence cs, Printer printer, String prefix) {
    if (cs instanceof Spanned) {
        Spanned sp = (Spanned) cs;
        Object[] os = sp.getSpans(0, cs.length(), Object.class);

        for (int i = 0; i < os.length; i++) {
            Object o = os[i];
            printer.println(prefix + cs.subSequence(sp.getSpanStart(o), sp.getSpanEnd(o)) + ": "
                    + Integer.toHexString(System.identityHashCode(o)) + " " + o.getClass().getCanonicalName()
                    + " (" + sp.getSpanStart(o) + "-" + sp.getSpanEnd(o) + ") fl=#" + sp.getSpanFlags(o));
        }
    } else {
        printer.println(prefix + cs + ": (no spans)");
    }
}