List of usage examples for java.lang System identityHashCode
@HotSpotIntrinsicCandidate public static native int identityHashCode(Object x);
From source file:org.apache.hadoop.hdfs.client.DfsClientShmManager.java
@Override public String toString() { return String.format("ShortCircuitShmManager(%08x)", System.identityHashCode(this)); }
From source file:IdentityMap.java
/** * {@inheritDoc}/*from w ww .j a v a2 s. c o m*/ * @see java.util.Collection#remove(java.lang.Object) */ public boolean remove(final Object key) { int hash = System.identityHashCode(key); int index = hash % _capacity; if (index < 0) { index = -index; } Entry entry = _buckets[index]; Entry prev = null; while (entry != null) { if (entry.getKey() == key) { // Found the entry. if (prev == null) { // First element in bucket matches. _buckets[index] = entry.getNext(); } else { // Remove the entry from the chain. prev.setNext(entry.getNext()); } _entries--; return true; } prev = entry; entry = entry.getNext(); } return false; }
From source file:com.xpn.xwiki.XWikiContext.java
/** * @return true if {@link XWikiContext#dropPermissions()} has been called * on this context, or if the {@link XWikiConstant.DROPPED_PERMISSIONS} * key has been set in the {@link org.xwiki.context.ExecutionContext} * for this thread. This is done by calling {@Document#dropPermissions()} *///from w w w . ja v a2s.c om public boolean hasDroppedPermissions() { if (this.get(XWikiConstant.DROPPED_PERMISSIONS) != null) { return true; } final Object dropped = this.execution.getContext().getProperty(XWikiConstant.DROPPED_PERMISSIONS); if (dropped == null || !(dropped instanceof Integer)) { return false; } return ((Integer) dropped) == System.identityHashCode(this.execution.getContext()); }
From source file:nz.co.senanque.rules.RuleSessionImpl.java
public void unbind(ValidationObject validationObject) { Integer id = System.identityHashCode(validationObject); m_unbinding.add(id);/*www . j a va 2s . c om*/ List<ProposedValue> proposedValues = new ArrayList<ProposedValue>(); ProxyObject proxyObject = getSession().getProxyObject(validationObject); for (ProxyField proxyField : proxyObject.getFieldMap().values()) { if (!proxyField.isDerived()) { // Figure out if this property contains a list or a known object type // we want to ignore those and only reset primitive objects (long, String etc) Class<?> clazz = proxyField.getPropertyMetadata().getGetMethod().getReturnType(); if (clazz.isAssignableFrom(List.class)) { continue; } if (getSession().getValidationEngine().getClassMetadata(clazz) != null) { continue; } RuleProxyField ruleProxyField = getRuleProxyField(proxyField); if (ruleProxyField.isDifferent(proxyField.getInitialValue())) { ProposedValue pv = new ProposedValue(ruleProxyField, proxyField.getInitialValue()); proposedValues.add(pv); } } } setValues(proposedValues); m_boundObjects.remove(id); m_unbinding.remove(id); List<String> kill = new ArrayList<String>(); for (Map.Entry<String, RuleContext> entry : m_ruleContextsMap.entrySet()) { if (entry.getValue().getValidationObject() == validationObject) { kill.add(entry.getKey()); } } for (String key : kill) { RuleContext rc = m_ruleContextsMap.remove(key); rc.reset(); } }
From source file:org.apache.hadoop.hive.ql.exec.tez.WorkloadManager.java
private void runWmThread() { while (true) { EventState currentEvents = null; currentLock.lock();//from ww w . j a va 2 s . c o m try { while (!hasChanges) { try { hasChangesCondition.await(1, TimeUnit.SECONDS); } catch (InterruptedException e) { LOG.warn("WM thread was interrupted and will now exit"); return; } } hasChanges = false; currentEvents = current; current = (currentEvents == one) ? two : one; } finally { currentLock.unlock(); } try { LOG.info("Processing current events"); processCurrentEvents(currentEvents, syncWork); scheduleWork(syncWork); updateSessionTriggerProvidersOnMasterThread(); } catch (InterruptedException ex) { LOG.warn("WM thread was interrupted and will now exit"); return; } catch (Exception | AssertionError ex) { LOG.error("WM thread encountered an error but will attempt to continue", ex); for (SettableFuture<Boolean> testEvent : currentEvents.testEvents) { LOG.info("Failing test event " + System.identityHashCode(testEvent)); testEvent.setException(ex); } currentEvents.testEvents.clear(); if (currentEvents.applyRpFuture != null) { currentEvents.applyRpFuture.setException(ex); currentEvents.applyRpFuture = null; } // TODO: we either have to kill HS2 or, as the non-actor model would implicitly, // hope for the best and continue on other threads. Do the latter for now. continue; } } }
From source file:com.invalidcodeexception.experiment.langstringbuilder.lang3.UnsafeToStringStyle.java
/** * <p>Append to the <code>toString</code> an <code>Object</code> * value that has been detected to participate in a cycle. This * implementation will print the standard string value of the value.</p> * * @param buffer the <code>StringBuffer</code> to populate * @param fieldName the field name, typically not used as already appended * @param object the value to add to the <code>toString</code>, * not <code>null</code>/*from ww w . j ava 2 s . c om*/ * * @since 2.2 */ protected void appendCyclicObject(StringBuilder buffer, String fieldName, Object object) { if (object == null) { throw new NullPointerException("Cannot get the toString of a null identity"); } buffer.append(object.getClass().getName()).append('@') .append(Integer.toHexString(System.identityHashCode(object))); }
From source file:com.greenlaw110.rythm.toString.ToStringStyle.java
/** * <p>Append to the <code>toString</code> an <code>Object</code> * value that has been detected to participate in a cycle. This * implementation will print the standard string value of the value.</p> * * @param buffer the <code>StringBuilder</code> to populate * @param fieldName the field name, typically not used as already appended * @param value the value to add to the <code>toString</code>, * not <code>null</code>/*from w w w. java 2s .c o m*/ * * @since 2.2 */ protected void appendCyclicObject(StringBuilder buffer, String fieldName, Object value) { if (value == null) { throw new NullPointerException("Cannot get the toString of a null identity"); } buffer.append(value.getClass().getName()).append('@') .append(Integer.toHexString(System.identityHashCode(value))); }
From source file:org.apache.geode.cache.client.internal.PoolImpl.java
@Override public String toString() { StringBuilder sb = new StringBuilder(100); sb.append(this.getClass().getSimpleName()).append('@').append(System.identityHashCode(this)) .append(" name=").append(getName()); return sb.toString(); }
From source file:org.jboss.jopr.tool.jbas5.MetadataConversionUtils.java
private static PropertyDefinition convertMetaTypeToPropertyDefinition(MetaType metaType, String propName, MetaValue metaValue) {/* www. jav a 2 s . c om*/ PropertyDefinition propDef; if (metaType.isSimple() || metaType.isEnum()) { PropertySimpleType propType = convertClassToPropertySimpleType(metaType.getClassName()); propDef = new PropertyDefinitionSimple(propName, null, false, propType); } else if (metaType.isCollection() || metaType.isArray()) { propDef = convertMetaTypeToPropertyDefinitionList(metaType, propName, metaValue); } else if (metaType.isComposite() || metaType.isGeneric() || metaType.isTable() || metaType instanceof PropertiesMetaType) { LOG.trace("Converting map with type [" + metaType + "@" + System.identityHashCode(metaType) + "], name [" + propName + "], and value [" + metaValue + "]..."); propDef = convertMetaTypeToPropertyDefinitionMap(metaType, propName, metaValue); } else { throw new IllegalStateException("Unsupported MetaType: " + metaType); } propDef.setDisplayName(StringUtils.deCamelCase(propName)); return propDef; }
From source file:de.micromata.genome.jpa.Emgr.java
/** * Identity hex.//ww w . j a v a2 s. co m * * @param o the o * @return the string */ private String identityHex(Object o) { return Integer.toHexString(System.identityHashCode(o)); }