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.apache.openjpa.meta.InterfaceImplGenerator.java

/**
 * Return a unique Class<?> name./*from w w  w. ja v a  2s  . c om*/
 */
protected final String getClassName(ClassMetaData meta) {
    Class<?> iface = meta.getDescribedType();
    return iface.getName() + "$" + System.identityHashCode(iface) + POSTFIX;
}

From source file:de.ailis.midi4js.Midi4JS.java

/**
 * Returns the handle for the midi device with the specified index. The
 * device must be released by calling the releaseMidiDevice() method!
 *
 * @param index/*from w ww.  j  av  a2s  . co  m*/
 *            The device index.
 * @return The device handle.
 * @throws MidiUnavailableException
 *             If the midi device is not available.
 */
public int getMidiDevice(final int index) throws MidiUnavailableException {
    final Info[] infos = MidiSystem.getMidiDeviceInfo();
    final MidiDevice device = MidiSystem.getMidiDevice(infos[index]);
    final int handle = System.identityHashCode(device);
    this.deviceMap.put(handle, device);
    return handle;
}

From source file:net.gleamynode.oil.impl.wal.QueueImpl.java

public QueueReference moveTo(QueueReference reference, Queue queue) throws OilException {
    if (!(reference instanceof QueueReferenceImpl)) {
        throw new IllegalArgumentException();
    }//from ww  w. j av  a 2  s .  com

    if (!(queue instanceof QueueImpl)) {
        throw new IllegalArgumentException();
    }

    if (this == queue) {
        throw new IllegalArgumentException();
    }

    QueueReference result;
    QueueReferenceImpl ref = (QueueReferenceImpl) reference;
    QueueImpl q = (QueueImpl) queue;

    if (parent != q.parent) {
        throw new IllegalArgumentException();
    }

    Sync lockA = lock.writeLock();
    Sync lockB = q.lock.writeLock();

    // sort locks to avoid deadlocks.
    if (System.identityHashCode(lockA) > System.identityHashCode(lockB)) {
        Sync tmp = lockA;
        lockA = lockB;
        lockB = tmp;
    }

    parent.acquireSharedLock();
    SyncUtil.acquire(lockA);
    SyncUtil.acquire(lockB);

    try {
        QueueExtent extent = extentList.getById(ref.getExtentId());

        if (extent == null) {
            result = null;
        } else if (extent.getChecksum() != ref.getChecksum()) {
            result = null;
        } else {
            result = extent.moveTo(ref.getOffset(), q);

            if (result != null) {
                extent.tryToDiscard();
            }
        }
    } finally {
        lockB.release();
        lockA.release();
        parent.releaseSharedLock();
    }

    return result;
}

From source file:IK.AbstractBone.java

public AbstractBone(AbstractBone par, DVector tipHeading, DVector rollHeading, String inputTag,
        frameType coordinateType) throws NullParentForBoneException {
    if (par != null) {
        if (this.tag == null || this.tag == "") {
            this.tag = Integer.toString(System.identityHashCode(this));
        } else//from ww  w  .  j  a  va2s.  co  m
            this.tag = inputTag;

        Ray tipHeadingRay = new Ray(par.getTip(), tipHeading);
        Ray rollHeadingRay = new Ray(par.getTip(), rollHeading);
        DVector tempTip = new DVector();
        DVector tempRoll = new DVector();
        DVector tempX = new DVector();

        if (coordinateType == frameType.GLOBAL) {
            tempTip = tipHeadingRay.heading();
            tempRoll = rollHeadingRay.heading();
        } else if (coordinateType == frameType.RELATIVE) {
            tempTip = par.localAxes().getGlobalOf(tipHeadingRay.heading());
            tempRoll = par.localAxes().getGlobalOf(rollHeadingRay.heading());
        } else {
            System.out.println("WOAH WOAH WOAH");
        }

        tempX = tempRoll.cross(tempTip);
        tempRoll = tempX.cross(tempTip);

        this.boneHeight = tipHeadingRay.mag();
        this.parent = par;
        this.parentArmature = this.parent.parentArmature;
        parentArmature.addToBoneList(this);

        generateAxes(parent.getTip(), tempX, tempTip, tempRoll);
        this.localAxes.orthogonalize();
        localAxes.setParent(parent.localAxes);
        previousOrientation = localAxes.attachedCopy(true);

        majorRotationAxes = parent.localAxes().getAbsoluteCopy();
        majorRotationAxes.translateTo(parent.getTip());
        majorRotationAxes.setParent(parent.localAxes);

        this.parent.addChild(this);
        this.parent.addFreeChild(this);
        this.updateSegmentedArmature();
    } else {
        throw new NullParentForBoneException();
    }
}

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

/**
 * Event fired by the webview contained in the viewpager child fragments once the page has
 * been loaded. It allow us to set the page position only once the DOM is ready, otherwise
 * initial posiion is broken./*  w  w  w .j  a  v a  2 s. co m*/
 */
@Subscribe
public void onTopicPageLoaded(PageLoadedEvent event) {
    Log.d(LOG_TAG, String.format(
            "@%d -> Received topicPageLoaded event (topic='%s', page='%d'), current(topic='%s', page='%d', currentPagePosition='%s')",
            System.identityHashCode(this), event.getTopic().getSubject(), event.getPage(), topic.getSubject(),
            currentPage, currentPagePosition));
    if (event.getTopic().equals(topic) && event.getPage() == currentPage) {
        if (currentPagePosition != null && !userScrolledViewPager) {
            event.getTopicPageView().setPagePosition(currentPagePosition);
        }
    }
}

From source file:org.openhie.openempi.model.IdentifierDomain.java

@Override
public int hashCode() {
    if (identifierDomainId != null) {
        return new HashCodeBuilder().append(identifierDomainId).toHashCode();
    }// www. ja  v a  2 s . c  o  m
    if (this.getNamespaceIdentifier() != null) {
        return new HashCodeBuilder().append(namespaceIdentifier).toHashCode();
    }
    if (this.getUniversalIdentifier() != null && this.getUniversalIdentifierTypeCode() != null) {
        return new HashCodeBuilder().append(universalIdentifier).append(universalIdentifierTypeCode)
                .toHashCode();
    }
    return System.identityHashCode(this);
}

From source file:com.heisenberg.impl.definition.ActivityImpl.java

public String toString() {
    return id != null ? "[" + id.toString() + "]" : "[" + Integer.toString(System.identityHashCode(this)) + "]";
}

From source file:IdentityMap.java

/**
 * {@inheritDoc}/*from w  w  w  .ja v a2s  . com*/
 * @see java.util.Map#get(java.lang.Object)
 */
public Object get(final Object key) {
    int hash = System.identityHashCode(key);
    int index = hash % _capacity;
    if (index < 0) {
        index = -index;
    }

    Entry entry = _buckets[index];
    while (entry != null) {
        if (entry.getKey() == key) {
            return entry.getValue();
        }
        entry = entry.getNext();
    }
    return null;
}

From source file:org.apache.hadoop.hive.metastore.HiveClientCache.java

private RemovalListener<HiveClientCacheKey, ICacheableMetaStoreClient> createRemovalListener() {
    RemovalListener<HiveClientCacheKey, ICacheableMetaStoreClient> listener = new RemovalListener<HiveClientCacheKey, ICacheableMetaStoreClient>() {
        @Override//w w w.j  av  a2s  . co  m
        public void onRemoval(RemovalNotification<HiveClientCacheKey, ICacheableMetaStoreClient> notification) {
            ICacheableMetaStoreClient hiveMetaStoreClient = notification.getValue();
            if (hiveMetaStoreClient != null) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Evicting client: "
                            + Integer.toHexString(System.identityHashCode(hiveMetaStoreClient)));
                }

                // TODO: This global lock may not be necessary as all concurrent methods in ICacheableMetaStoreClient
                // are synchronized.
                synchronized (CACHE_TEARDOWN_LOCK) {
                    hiveMetaStoreClient.setExpiredFromCache();
                    hiveMetaStoreClient.tearDownIfUnused();
                }
            }
        }
    };

    return listener;
}

From source file:org.compass.core.impl.DefaultCompass.java

public DefaultCompass(CompassMapping mapping, ConverterLookup converterLookup, CompassMetaData compassMetaData,
        PropertyNamingStrategy propertyNamingStrategy, ExecutorManager executorManager,
        CompassSettings settings, boolean duplicate, LuceneSearchEngineFactory searchEngineFactory)
        throws CompassException {

    this.mapping = mapping;
    this.converterLookup = converterLookup;
    this.compassMetaData = compassMetaData;
    this.propertyNamingStrategy = propertyNamingStrategy;
    this.executorManager = executorManager;
    this.name = settings.getSetting(CompassEnvironment.NAME, "default");
    this.settings = settings;
    this.duplicate = duplicate;

    this.eventManager = new CompassEventManager(this, mapping);
    eventManager.configure(settings);//from w ww.  ja v a2 s.c o  m

    if (!duplicate) {
        registerJndi();
    }

    searchEngineFactory.setTransactionContext(new CompassTransactionContext(this));
    this.searchEngineFactory = searchEngineFactory;

    // build the transaction factory
    transactionFactory = TransactionFactoryFactory.createTransactionFactory(this, settings);
    localTransactionFactory = TransactionFactoryFactory.createLocalTransactionFactory(this, settings);

    firstLevelCacheFactory = new FirstLevelCacheFactory();
    firstLevelCacheFactory.configure(settings);

    searchEngineFactory.getIndexManager().verifyIndex();

    if (!duplicate) {
        start();
    }

    if (settings.getSettingAsBoolean(CompassEnvironment.REGISTER_SHUTDOWN_HOOK, true)) {
        try {
            shutdownThread = new ShutdownThread(this);

            if (logger.isDebugEnabled()) {
                logger.debug("Registering shutdown hook [" + System.identityHashCode(shutdownThread) + "]");
            }
            Runtime.getRuntime().addShutdownHook(shutdownThread);
        } catch (AccessControlException e) {
            // we are not allowed to register a shutdown thread, ignore
        }
    }

    this.debug = settings.getSettingAsBoolean(CompassEnvironment.DEBUG, false);
}