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:com.gs.obevo.db.impl.core.jdbc.JdbcHelper.java

private String displayConnection(Connection connection) {
    return "Connection[" + System.identityHashCode(connection) + "]: " + connection.toString();
}

From source file:com.chuhan.privatecalc.fragment.os.BackStackState.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder(128);
    sb.append("BackStackEntry{");
    sb.append(Integer.toHexString(System.identityHashCode(this)));
    if (mIndex >= 0) {
        sb.append(" #");
        sb.append(mIndex);/* www .  j av a2s  . co m*/
    }
    if (mName != null) {
        sb.append(" ");
        sb.append(mName);
    }
    sb.append("}");
    return sb.toString();
}

From source file:org.droid2droid.internal.AbstractRemoteAndroidImpl.java

@Override
public boolean unbindService(ServiceConnection conn) {
    synchronized (mBinders) {
        Binded binder = mBinders.get(conn);
        if (binder != null) {
            if (D)
                Log.d(TAG_CLIENT_BIND, PREFIX_LOG + "UnBindOID...");
            Parcel data = Parcel.obtain();
            Parcel reply = Parcel.obtain();
            try {

                try {
                    data.writeInt(System.identityHashCode(conn));
                    transactRemoteAndroid(getConnectionId(), UNBIND_SRV, data, reply, 0, mExecuteTimeout);
                    if (D)
                        Log.d(TAG_CLIENT_BIND, PREFIX_LOG + "UnBindOID ok");
                } catch (RemoteException e) {
                    if (W && !D)
                        Log.w(TAG_CLIENT_BIND, "Error when unbind (" + e.getMessage() + ")");
                    if (D)
                        Log.w(TAG_CLIENT_BIND, "Errer when unbind", e);
                }//  ww w . j  a  va 2s . c  o m
            } finally {
                if (data != null)
                    data.recycle();
                if (reply != null)
                    reply.recycle();
            }
            mBinders.remove(conn);
        } else
            return false;
    }

    return true;
}

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

public static Connection getStandaloneConnectionWithException() throws SQLException {
    Connection conn = s_ds.getConnection();
    if (s_connLogger.isTraceEnabled()) {
        s_connLogger.trace("Retrieving a standalone connection: dbconn" + System.identityHashCode(conn));
    }//from  w  ww  .j a v  a 2s. c  o  m
    return conn;
}

From source file:org.jbpm.graph.def.ProcessDefinition.java

/**
 * Computes the hash code for this process definition. Process definitions with a null name or
 * a negative version will return their {@linkplain System#identityHashCode(Object) identity
 * hash code}./*from   w  w  w .  j  av a  2 s. c  o  m*/
 */
public int hashCode() {
    if (name == null || version < 0)
        return System.identityHashCode(this);

    int result = 224001527 + name.hashCode();
    result = 1568661329 * result + version;
    return result;
}

From source file:IdentityHashMap.java

/**
 * Returns <tt>true</tt> if this map contains a mapping for the specified
 * key.//from  w  w  w.j  a  v a 2s  .co m
 * 
 * @return <tt>true</tt> if this map contains a mapping for the specified
 * key.
 * @param key key whose presence in this Map is to be tested.
 */
public boolean containsKey(Object key) {
    Entry tab[] = table;
    if (key != null) {
        //int hash = key.hashCode();
        int hash = System.identityHashCode(key);
        int index = (hash & 0x7FFFFFFF) % tab.length;
        for (Entry e = tab[index]; e != null; e = e.next)
            // if (e.hash==hash && key.equals(e.key))
            if (e.hash == hash && (key == e.key))
                return true;
    } else {
        for (Entry e = tab[0]; e != null; e = e.next)
            if (e.key == null)
                return true;
    }

    return false;
}

From source file:org.apache.kylin.common.KylinConfig.java

public static void setKylinConfigInEnvIfMissing(Properties prop) {
    synchronized (KylinConfig.class) {
        if (SYS_ENV_INSTANCE == null) {
            try {
                KylinConfig config = new KylinConfig();
                config.reloadKylinConfig(prop);
                logger.info("Resetting SYS_ENV_INSTANCE by a input stream: " + System.identityHashCode(config));
                SYS_ENV_INSTANCE = config;
            } catch (IllegalArgumentException e) {
                throw new IllegalStateException("Failed to find KylinConfig ", e);
            }//  ww  w.  jav  a 2 s.c  o  m
        }
    }
}

From source file:WeakIdentityHashMap.java

/**
 * Return a hash code for non-null Object x.
 *//*from  w w  w. j av a 2  s .  c o  m*/
int hash(Object x) {
    int h = System.identityHashCode(x);
    return h - (h << 7); // that is,, -127 * h
}

From source file:WeakIdentityMap.java

public boolean containsKey(Object key) {
    if (key == null) {
        key = KeyFactory.NULL;/*from  w w w.ja v  a  2 s.  c o  m*/
    }

    Entry[] tab = this.table;
    int hash = System.identityHashCode(key);
    int index = (hash & 0x7fffffff) % tab.length;

    for (Entry e = tab[index], prev = null; e != null; e = e.next) {
        Object entryKey = e.get();

        if (entryKey == null) {
            // Clean up after a cleared Reference.
            this.modCount++;
            if (prev != null) {
                prev.next = e.next;
            } else {
                tab[index] = e.next;
            }
            this.count--;
        } else if (e.hash == hash && key == entryKey) {
            return true;
        } else {
            prev = e;
        }
    }

    return false;
}

From source file:jetbrains.exodus.entitystore.PersistentEntityStoreImpl.java

public PersistentEntityStoreImpl(@NotNull final PersistentEntityStoreConfig config,
        @NotNull final Environment environment, @Nullable final BlobVault blobVault,
        @NotNull final String name) {
    hashCode = System.identityHashCode(this);
    this.config = config;
    this.environment = environment;
    PersistentEntityStores.adjustEnvironmentConfigForEntityStore(environment.getEnvironmentConfig());
    this.name = name;
    location = environment.getLocation();
    namingRulez = new StoreNamingRules(name);
    iterableCache = new EntityIterableCacheImpl(this);
    entityIdCache = new ConcurrentObjectCache<>(ENTITY_ID_CACHE_SIZE);
    explainer = new Explainer(config.isExplainOn());
    propertyDataGetter = new PropertyDataGetter();
    linkDataGetter = config.isDebugLinkDataGetter() ? new DebugLinkDataGetter() : new LinkDataGetter();
    blobDataGetter = new BlobDataGetter();
    allSequences = new HashMap<>();

    final PersistentStoreTransaction txn = beginTransaction();
    sequences = environment.openStore(SEQUENCES_STORE, StoreConfig.WITHOUT_DUPLICATES,
            txn.getEnvironmentTransaction());
    final boolean fromScratch;
    try {//w  ww.  j av  a2s . c  om
        this.blobVault = blobVault == null ? createDefaultFSBlobVault() : blobVault;

        entitiesSequences = new IntHashMap<>();
        final TwoColumnTable entityTypesTable = new TwoColumnTable(txn, namingRulez.getEntityTypesTableName(),
                StoreConfig.WITHOUT_DUPLICATES);
        final PersistentSequence entityTypesSequence = getSequence(txn,
                namingRulez.getEntityTypesSequenceName());
        entityTypes = new PersistentSequentialDictionary(entityTypesSequence, entityTypesTable) {
            @Override
            protected void created(final PersistentStoreTransaction txn, final int id) {
                preloadTables(txn, id);
            }
        };
        propertyIds = new PersistentSequentialDictionary(
                getSequence(txn, namingRulez.getPropertyIdsSequenceName()),
                new TwoColumnTable(txn, namingRulez.getPropertyIdsTableName(), StoreConfig.WITHOUT_DUPLICATES));
        linkIds = new PersistentSequentialDictionary(getSequence(txn, namingRulez.getLinkIdsSequenceName()),
                new TwoColumnTable(txn, namingRulez.getLinkIdsTableName(), StoreConfig.WITHOUT_DUPLICATES));

        propertyTypes = new PropertyTypes();
        propertyCustomTypeIds = new PersistentSequentialDictionary(
                getSequence(txn, namingRulez.getPropertyCustomTypesSequence()),
                new TwoColumnTable(txn, namingRulez.getPropertyCustomTypesTable(),
                        StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING));

        entitiesTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, final int entityTypeId) {
                return new SingleColumnTable(txn, namingRulez.getEntitiesTableName(entityTypeId),
                        StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING);
            }
        });
        entitiesHistoryTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, final int entityTypeId) {
                return new SingleColumnTable(txn, namingRulez.getEntitiesHistoryTableName(entityTypeId),
                        StoreConfig.WITH_DUPLICATES);
            }
        });
        propertiesTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, final int entityTypeId) {
                return new PropertiesTable(txn, namingRulez.getPropertiesTableName(entityTypeId),
                        StoreConfig.WITHOUT_DUPLICATES);
            }
        });
        propertiesHistoryTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, final int entityTypeId) {
                return new SingleColumnTable(txn, namingRulez.getPropertiesHistoryTableName(entityTypeId),
                        StoreConfig.WITHOUT_DUPLICATES);
            }
        });
        linksTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, final int entityTypeId) {
                return new TwoColumnTable(txn, namingRulez.getLinksTableName(entityTypeId),
                        StoreConfig.WITH_DUPLICATES_WITH_PREFIXING);
            }
        });
        linksHistoryTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, int entityTypeId) {
                return new SingleColumnTable(txn, namingRulez.getLinksHistoryTableName(entityTypeId),
                        StoreConfig.WITH_DUPLICATES_WITH_PREFIXING);
            }
        });
        blobsTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, final int entityTypeId) {
                return new BlobsTable(PersistentEntityStoreImpl.this, txn,
                        namingRulez.getBlobsTableName(entityTypeId), StoreConfig.WITHOUT_DUPLICATES);
            }
        });
        blobsHistoryTables = new OpenTablesCache(new OpenTablesCache.TableCreator() {
            @NotNull
            @Override
            public Table createTable(@NotNull final PersistentStoreTransaction txn, final int entityTypeId) {
                return new SingleColumnTable(txn, namingRulez.getBlobsHistoryTableName(entityTypeId),
                        StoreConfig.WITHOUT_DUPLICATES);
            }
        });

        final String internalSettingsName = namingRulez.getInternalSettingsName();
        final Store settings = environment.openStore(internalSettingsName, StoreConfig.WITHOUT_DUPLICATES,
                txn.getEnvironmentTransaction(), false);
        fromScratch = settings == null;
        if (fromScratch) {
            internalSettings = environment.openStore(internalSettingsName, StoreConfig.WITHOUT_DUPLICATES,
                    txn.getEnvironmentTransaction(), true);
        } else {
            internalSettings = settings;
        }
        txn.flush();
    } catch (IOException e) {
        throw ExodusException.toEntityStoreException(e);
    } finally {
        txn.abort();
    }

    if (!config.getRefactoringSkipAll()) {
        applyRefactorings(fromScratch); // this method includes refactorings that could be clustered into separate txns
    }

    final PersistentStoreTransaction preloadTxn = beginTransaction();
    try {
        preloadTables(preloadTxn); // this is called to pre-load tables for all entity types to prevent them from being lazy loaded
    } finally {
        preloadTxn.commit();
    }

    configMBean = config.isManagementEnabled() ? new EntityStoreConfig(this) : null;

    startedAt = System.currentTimeMillis();
    transactionCount = 0;

    if (log.isDebugEnabled()) {
        log.debug("Created successfully.");
    }
}