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.betaconceptframework.astroboa.test.model.ContentObjectTest.java

private void assertPropertyPathForMultipleValueComplexProperty(ContentObject contentObject,
        String propertyPath) {/* w  ww . java  2s  .c  o m*/
    List<CmsProperty<?, ?>> complexProperties = contentObject.getCmsPropertyList(propertyPath);

    Assert.assertNotNull(complexProperties,
            "Content object of type test did not return complex property list " + propertyPath);
    Assert.assertTrue(complexProperties.size() > 0,
            "Content object of type test returned empty complex property list " + propertyPath);

    int i = 0;
    for (CmsProperty<?, ?> complexProperty : complexProperties) {
        if (i > 0) {
            assertPropertyPath(complexProperty, propertyPath + "[" + i + "]",
                    contentObject.getContentObjectType());
        } else {
            assertPropertyPath(complexProperty, propertyPath, contentObject.getContentObjectType());
        }

    }

    //Try to request simple property with index
    CmsProperty<?, ?> complexPropertyWithIndexZero = createCmsProperty(contentObject, propertyPath + "[0]");
    Assert.assertNotNull(complexPropertyWithIndexZero,
            "Content object of type test did not return property '" + propertyPath + "[0]'");
    assertPropertyPath(complexPropertyWithIndexZero, propertyPath, contentObject.getContentObjectType());

    //Normally these two instances should be the same
    Assert.assertTrue(
            System.identityHashCode(complexProperties.get(0)) == System
                    .identityHashCode(complexPropertyWithIndexZero),
            "Method getCmsProperty() returned different instances for the same actually property ('"
                    + propertyPath + "', '" + propertyPath + "[0]') ");

    CmsProperty<?, ?> complexPropertyWithIndexOne = createCmsProperty(contentObject, propertyPath + "[1]");
    Assert.assertNotNull(complexPropertyWithIndexOne,
            "Content object of type test did not return property '" + propertyPath + "[1]'");
    assertPropertyPath(complexPropertyWithIndexOne, propertyPath + "[1]", contentObject.getContentObjectType());

    CmsProperty<?, ?> complexPropertyWithIndexThree = createCmsProperty(contentObject, propertyPath + "[3]");
    Assert.assertNull(complexPropertyWithIndexThree,
            "Content object of type test returned property '" + propertyPath + "[3]'");
}

From source file:org.betaconceptframework.astroboa.test.model.ContentObjectTest.java

private void assertPropertyPathForSingleValueComplexProperty(ContentObject contentObject, String propertyPath) {

    CmsProperty<?, ?> complexProperty = createCmsProperty(contentObject, propertyPath);

    Assert.assertNotNull(complexProperty,
            "Content object of type test did not return complex property list " + propertyPath);
    assertPropertyPath(complexProperty, propertyPath, contentObject.getContentObjectType());

    //Try to request simple property with index
    String newPropertyPath = propertyPath + "[0]";
    CmsProperty<?, ?> complexPropertyWithIndexZero = null;

    complexPropertyWithIndexZero = createCmsProperty(contentObject, newPropertyPath);
    Assert.assertNotNull(complexPropertyWithIndexZero,
            "Content object of type test did not return property '" + newPropertyPath + "'");
    assertPropertyPath(complexPropertyWithIndexZero, propertyPath, contentObject.getContentObjectType());

    //Normally these two instances should be the same
    Assert.assertTrue(/*from  w  w  w  .j  a  v  a 2 s  .  c  o m*/
            System.identityHashCode(complexProperty) == System.identityHashCode(complexPropertyWithIndexZero),
            "Method getCmsProperty() returned different instances for the same actually property ('"
                    + propertyPath + "', '" + newPropertyPath + "') ");

    CmsProperty<?, ?> complexPropertyWithIndexOne = createCmsProperty(contentObject, propertyPath + "[1]");
    Assert.assertNull(complexPropertyWithIndexOne,
            "Content object of type test returned property '" + propertyPath + "[1]'");

    CmsProperty<?, ?> complexPropertyWithIndexThree = createCmsProperty(contentObject, propertyPath + "[3]");
    Assert.assertNull(complexPropertyWithIndexThree,
            "Content object of type test returned property '" + propertyPath + "[3]'");
}

From source file:org.betaconceptframework.astroboa.test.model.ContentObjectTest.java

private void assertPropertyPathForSingleValueSimpleProperty(ContentObject contentObject, String propertyPath) {
    CmsProperty<?, ?> simpleProperty = createCmsProperty(contentObject, propertyPath);

    Assert.assertNotNull(simpleProperty, "Content object of type test did not return property " + propertyPath);
    assertPropertyPath(simpleProperty, propertyPath, contentObject.getContentObjectType());

    //Try to request simple property with index
    String newPropertyPath = propertyPath + "[0]";

    CmsProperty<?, ?> simplePropertyWithIndexZero = null;

    simplePropertyWithIndexZero = createCmsProperty(contentObject, newPropertyPath);
    Assert.assertNotNull(simplePropertyWithIndexZero,
            "Content object of type test did not return property '" + newPropertyPath);
    assertPropertyPath(simplePropertyWithIndexZero, propertyPath, contentObject.getContentObjectType());

    //Normally these two instances should be the same
    Assert.assertTrue(/*w  w  w .  j  av a 2s  .co  m*/
            System.identityHashCode(simpleProperty) == System.identityHashCode(simplePropertyWithIndexZero),
            "Method getCmsProperty() returned different instances for the same actually property ('"
                    + propertyPath + "', '" + newPropertyPath + "') ");

    newPropertyPath = propertyPath + "[1]";
    CmsProperty<?, ?> simplePropertyWithIndexOne = createCmsProperty(contentObject, newPropertyPath);
    Assert.assertNull(simplePropertyWithIndexOne,
            "Content object of type test returned property '" + newPropertyPath + "'");

    newPropertyPath = propertyPath + "[3]";
    CmsProperty<?, ?> simplePropertyWithIndexThree = createCmsProperty(contentObject, newPropertyPath);
    Assert.assertNull(simplePropertyWithIndexThree,
            "Content object of type test returned property '" + newPropertyPath + "'");

}

From source file:com.buaa.cfs.security.UserGroupInformation.java

/**
 * Return the hash of the subject.
 */
@Override
public int hashCode() {
    return System.identityHashCode(subject);
}

From source file:org.apache.axis2.client.Options.java

/**
 * Debug for for property key and value.
 * @param key/*from www. j  a v a 2  s.  c  om*/
 * @param value
 */
private void debugPropertySet(String key, Object value) {
    if (DEBUG_PROPERTY_SET) {
        String className = (value == null) ? "null" : value.getClass().getName();
        String classloader = "null";
        if (value != null) {
            ClassLoader cl = Utils.getObjectClassLoader(value);
            if (cl != null) {
                classloader = cl.toString();
            }
        }
        String valueText = (value instanceof String) ? value.toString() : null;

        String identity = getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this));

        log.debug("==================");
        log.debug(" Property set on object " + identity);
        log.debug("  Key =" + key);
        if (valueText != null) {
            log.debug("  Value =" + valueText);
        }
        log.debug("  Value Class = " + className);
        log.debug("  Value Classloader = " + classloader);
        log.debug("Call Stack = " + JavaUtils.callStackToString());
        log.debug("==================");
    }
}

From source file:org.apache.openjpa.meta.ClassMetaData.java

/**
 * Resolve metadata./*from   w  ww.  ja v a 2 s . co m*/
 */
protected void resolveMeta(boolean runtime) {
    boolean embed = _owner != null && _owner.getDeclaredType() == _type;
    Log log = _repos.getLog();
    if (log.isTraceEnabled())
        log.trace(_loc.get((embed) ? "resolve-embed-meta" : "resolve-meta",
                this + "@" + System.identityHashCode(this)));

    if (runtime && !_type.isInterface() && !ImplHelper.isManagedType(getRepository().getConfiguration(), _type))
        throw new MetaDataException(_loc.get("not-enhanced", _type));

    // are we the target of an embedded value?
    if (embed) {
        if (recursiveEmbed(_owner)) {
            throw new MetaDataException(_loc.get("recurse-embed", _owner));
        }

        // copy info from the "real" metadata for this type
        ClassMetaData meta = _repos.getMetaData(_type, _loader, true);
        meta.resolve(MODE_META);
        copy(this, meta);
        _embedded = Boolean.FALSE; // embedded instance isn't embedded-only
    }

    // make sure superclass is resolved
    ClassMetaData sup = getPCSuperclassMetaData();
    if (sup != null) {
        sup.resolve(MODE_META);
        if (embed) {
            // embedded instance always redefine all superclass fields
            FieldMetaData[] sups = sup.getFields();
            for (int i = 0; i < sups.length; i++) {
                if (_supFieldMap == null || !_supFieldMap.containsKey(sups[i].getName())) {
                    addDefinedSuperclassField(sups[i].getName(), sups[i].getDeclaredType(),
                            sups[i].getDeclaringType());
                }
            }
        }
    }

    // resolve fields and remove invalids
    FieldMetaData fmd;
    for (Iterator<FieldMetaData> itr = _fieldMap.values().iterator(); itr.hasNext();) {
        // only pass on metadata resolve mode so that metadata is always
        // resolved before any other resolve modes our subclasses pass along
        fmd = itr.next();
        fmd.resolve(MODE_META);

        if (!fmd.isExplicit() && (fmd.getDeclaredTypeCode() == JavaTypes.OBJECT
                || fmd.getDeclaredTypeCode() == JavaTypes.PC_UNTYPED
                || (fmd.getDeclaredTypeCode() == JavaTypes.ARRAY
                        && fmd.getElement().getDeclaredTypeCode() == JavaTypes.OBJECT))) {
            _repos.getLog().warn(_loc.get("rm-field", fmd));
            if (fmd.getListingIndex() != -1)
                fmd.setManagement(FieldMetaData.MANAGE_NONE);
            else
                itr.remove();
            clearFieldCache();
        }
    }

    // embedded instances must embed all superclass fields too
    if (embed) {
        clearAllFieldCache();
        resolveDefinedSuperclassFields();
    }

    // this ensures that all field indexes get set when fields are cached
    cacheFields();

    // resolve lifecycle metadata now to prevent lazy threading problems
    _lifeMeta.resolve();

    // record implements in the repository
    if (_interfaces != null) {
        for (Class<?> iface : _interfaces)
            _repos.addDeclaredInterfaceImpl(this, iface);
    }

    // resolve fetch groups
    if (_fgMap != null)
        for (FetchGroup fg : _fgMap.values())
            fg.resolve();

    if (!embed && _type.isInterface()) {
        if (_interface != Boolean.TRUE)
            throw new MetaDataException(_loc.get("interface", _type));

        if (runtime) {
            _impl = _repos.getImplGenerator().createImpl(this);
            _repos.setInterfaceImpl(this, _impl);
        }
    }

    // if this is runtime, create a pc instance and scan it for comparators
    if (runtime && !Modifier.isAbstract(_type.getModifiers())) {
        ProxySetupStateManager sm = new ProxySetupStateManager();
        sm.setProxyData(PCRegistry.newInstance(_type, sm, false), this);
    }
}

From source file:org.apache.openjpa.meta.FieldMetaData.java

/**
 * Resolve and validate metadata. Return true if already resolved.
 *///from  w w w .j  a  va 2s  .co m
public boolean resolve(int mode) {
    if ((_resMode & mode) == mode)
        return true;
    int cur = _resMode;
    _resMode |= mode;

    Log log = getRepository().getLog();
    if (log.isTraceEnabled())
        log.trace(_loc.get("resolve-field", _owner + "@" + System.identityHashCode(_owner) + "." + _name));

    // we only perform actions for metadata mode
    if ((mode & MODE_META) == 0 || (cur & MODE_META) != 0)
        return false;

    Method externalizer = getExternalizerMethod();
    if (externalizer != null)
        setType(externalizer.getReturnType());

    // only pass on metadata resolve mode so that metadata is always
    // resolved before any other resolve modes our subclasses pass along
    _val.resolve(MODE_META);
    _key.resolve(MODE_META);
    _elem.resolve(MODE_META);

    MetaDataRepository repos = getRepository();
    int validate = repos.getValidate();
    if ((validate & MetaDataRepository.VALIDATE_META) != 0
            && (!ImplHelper.isManagedType(repos.getConfiguration(), _owner.getDescribedType())
                    || (validate & MetaDataRepository.VALIDATE_UNENHANCED) == 0)) {
        validateLRS();
        if ((validate & MetaDataRepository.VALIDATE_RUNTIME) == 0)
            validateSupportedType();
        validateValue();
        validateExtensionKeys();
    }
    return false;
}

From source file:org.apache.geode.internal.cache.tier.sockets.HandShake.java

@Override
public String toString() {
    StringBuffer buf = new StringBuffer().append("HandShake@").append(System.identityHashCode(this))
            .append(" code: ").append(this.code);
    if (this.id != null) {
        buf.append(" identity: ");
        /*/*from  ww w. j  a v  a2 s  . c o  m*/
         * for(int i=0; i<this.identity.length; ++i) { buf.append(this.identity[i]); }
         */
        buf.append(this.id.toString());
    }
    return buf.toString();
}

From source file:org.apache.openjpa.meta.ClassMetaData.java

/**
 * Resolve mapping data. Logs resolve message and resolves super by default.
 *//*from   w  w w.  java  2  s.c o m*/
protected void resolveMapping(boolean runtime) {
    Log log = _repos.getLog();
    if (log.isTraceEnabled())
        log.trace(_loc.get("resolve-mapping", this + "@" + System.identityHashCode(this)));

    // make sure superclass is resolved first
    ClassMetaData sup = getPCSuperclassMetaData();
    if (sup != null)
        sup.resolve(MODE_MAPPING);
}

From source file:org.apache.openjpa.meta.ClassMetaData.java

/**
 * Initialize mapping. Logs init message by default.
 *///  w  ww  .  j  av  a 2 s.c  o m
protected void initializeMapping() {
    Log log = _repos.getLog();
    if (log.isTraceEnabled())
        log.trace(_loc.get("init-mapping", this + "@" + System.identityHashCode(this)));
}