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.power.commons.lang.util.ToStringBuilder.java

public ToStringBuilder appendDescription(Object value) {
    if (value != null) {
        if (value.getClass().isArray()) {
            format("%s[%d]", value.getClass().getComponentType().getCanonicalName(), Array.getLength(value));
        } else {//from   w  w w. j  av  a  2 s  . c  o  m
            format("%s@%x", value.getClass().getCanonicalName(), System.identityHashCode(value));
        }
    }

    return this;
}

From source file:org.eclipse.e4.emf.internal.xpath.CollectionPointer.java

@Override
public int hashCode() {
    return System.identityHashCode(collection) + index;
}

From source file:org.broadleafcommerce.common.copy.MultiTenantCopier.java

protected void persistCopyObjectTreeInternal(Object copy, Set<Integer> library,
        MultiTenantCopyContext context) {
    if (library.contains(System.identityHashCode(copy))) {
        return;//from  w  w w  . j a  va 2s.  c  o  m
    }
    library.add(System.identityHashCode(copy));
    List<Object[]> collections = new ArrayList<Object[]>();
    Field[] allFields = context.getAllFields(copy.getClass());
    for (Field field : allFields) {
        if (field.getName().equals("embeddableSiteDiscriminator")) {
            continue;
        }
        if (!Modifier.isStatic(field.getModifiers())) {
            field.setAccessible(true);
            Object newTarget;
            try {
                newTarget = field.get(copy);
            } catch (IllegalAccessException e) {
                throw ExceptionHelper.refineException(e);
            }
            if (newTarget != null) {
                if (field.getAnnotation(ManyToOne.class) != null
                        || field.getAnnotation(OneToOne.class) != null) {
                    if (library.contains(System.identityHashCode(newTarget))) {
                        persistNode(newTarget, context);
                        continue;
                    }
                    persistCopyObjectTreeInternal(newTarget, library, context);
                } else if (field.getAnnotation(ManyToMany.class) != null
                        || field.getAnnotation(OneToMany.class) != null) {
                    collections.add(new Object[] { field, newTarget });
                } else if (field.getType().getAnnotation(Embeddable.class) != null
                        && MultiTenantCloneable.class.isAssignableFrom(field.getType())) {
                    persistCopyObjectTreeInternal(newTarget, library, context);
                }
            }
        }
    }
    if (copy.getClass().getAnnotation(Embeddable.class) == null) {
        persistNode(copy, context);
    }
    for (Object[] collectionItem : collections) {
        if (collectionItem[1] instanceof Collection) {
            Collection newCollection = (Collection) collectionItem[1];
            for (Object member : newCollection) {
                persistCopyObjectTreeInternal(member, library, context);
            }
        } else if (collectionItem[1] instanceof Map) {
            Map newMap = (Map) collectionItem[1];
            for (Object key : newMap.keySet()) {
                persistCopyObjectTreeInternal(newMap.get(key), library, context);
            }
        } else {
            throw new IllegalArgumentException(String.format("During copy object persistence, "
                    + "an unrecognized type was detected for a OneToMany or ManyToMany field. The system currently only "
                    + "recognizes Collection and Map. (%s.%s)", copy.getClass().getName(),
                    ((Field) collectionItem[0]).getName()));
        }
    }
}

From source file:org.pentaho.reporting.engine.classic.core.layout.output.ElementChangeChecker.java

public ElementChangeChecker() {
    performanceCollector = new PerformanceCollector();
    attrName = "ElementChangeTracker-NeedResult@" + System.identityHashCode(this);
    elementAttribute = "ElementChangeTracker-DetailResult@" + System.identityHashCode(this);
    currentFieldsAndValues = new HashMap<String, Object>();
}

From source file:com.microsoft.tfs.core.clients.workitem.internal.fields.FieldImpl.java

@Override
public String toString() {
    return MessageFormat.format("FieldImpl({0},{1})@{2}", //$NON-NLS-1$
            Integer.toString(fieldDefinition.getID()), fieldDefinition.getReferenceName(),
            Integer.toHexString(System.identityHashCode(this)));
}

From source file:org.envirocar.app.application.service.DeviceInRangeService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    logger.info("onStartCommand " + getClass().getName() + "; Hash: " + System.identityHashCode(this));

    discoveryEnabled = true;/*from w ww  . j av  a2  s . c o m*/

    startWithDelay(0);

    PendingIntent pIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class),
            Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

    Notification note = new NotificationCompat.Builder(getApplicationContext())
            .setSmallIcon(R.drawable.dashboard).setContentTitle("enviroCar").setContentIntent(pIntent)
            .setContentText(getResources().getText(R.string.device_discovery_pending)).build();

    startForeground(BackgroundServiceImpl.BG_NOTIFICATION_ID, note);

    return super.onStartCommand(intent, flags, startId);
}

From source file:org.envirocar.app.application.service.BackgroundServiceImpl.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    logger.info("onStartCommand " + getClass().getName() + "; Hash: " + System.identityHashCode(this));
    startBackgroundService();/*from w  w w.jav  a  2s . c  o m*/

    createForegroundNotification(R.string.service_state_starting);

    doTextToSpeech("Establishing connection");

    return START_STICKY;
}

From source file:de.innovationgate.wgpublisher.webtml.init.WebTMLEnvironmentBuilder.java

public TMLContext prepareWebTmlEnvironment() throws WGException {

    if (_debug) {
        _core.getLog().info("Request: " + System.identityHashCode(_request) + ", Session: "
                + _request.getSession().getId() + ", Ajax: " + (_ajaxInfo != null));
    }/*from  w w  w.  ja v  a  2s .c o  m*/

    // Create WebTML context
    TMLContext context = new TMLContext(_doc, _core, _userProfile, null, _request, _response,
            _request.getSession());
    TMLContext.clearThreadMainContext();
    context.makeThreadMainContext();
    _request.setAttribute(WGACore.ATTRIB_MAINCONTEXT, context.content());

    // Process multipartformdata
    de.innovationgate.wgpublisher.webtml.form.TMLForm.MultipartFormData data = retrieveMultipartFormData(
            _request);

    // create TMLForm if data is available
    TMLForm form = null;
    if (data != null) {
        if (data.getFormInfoItem() != null) {
            form = processTMLForm(context, _request, data, _ajaxInfo);
            context.getEnvironment().setForm(form);
            _request.setAttribute(WGACore.ATTRIB_POSTED_TMLFORM, form);
        } else {
            WGA.get(context).tmlPage().setVar("multipartData", data.getFileItems());
        }
    }

    // Process WebTML var parameters
    String varParam = _request.getParameter(WGPDispatcher.URLPARAM_VARS);
    if (varParam != null) {
        try {
            processVarParams(_request, context, varParam);
        } catch (Exception e) {
            _core.getLog().error("Exception processing var params", e);
            context.addwarning("Unable to process var params: " + e.getMessage());
        }
    }

    // Set DefaultURLBuilder if no other is already set
    _core.retrieveURLBuilder(_request, _doc.getDatabase());

    // Restore AJAX environment on AJAX call
    if (_ajaxInfo != null) {
        restoreAjaxEnvironment(_ajaxInfo, context);
    }

    // Read transient portlet states
    TMLPortletStateStorage storage = context.getPortletStateStorage();
    if (storage instanceof TMLPortletStateTransientStorage) {
        TMLPortletStateTransientStorage transientStorage = (TMLPortletStateTransientStorage) storage;
        transientStorage.readStates(_core);
        reregisterChildPortlets(context.db(), transientStorage.getAllStates(), context.getPortletRegistry(),
                null);
    }

    // Process WebTML action
    try {
        if (processAction(context, _request, _response, form, _ajaxInfo != null)) {
            if (form != null) {
                TMLFormInfo formInfo = form.getforminfo();
                if (formInfo.isValidated() && formInfo.keepOnValidate() && !form.wasValidatedInThisRequest()) {
                    form.validate();
                }
            }
        }
    } catch (Exception e) {
        _core.getLog().error("Exception processing WebTML action", e);
        context.addwarning("Unable to process WebTML action: " + e.getMessage());
    }

    return context;

}

From source file:eu.project.ttc.utils.JCasUtils.java

public static void showJCas(JCas jcas) {
    FSIterator<Annotation> it = jcas.getAnnotationIndex().iterator();
    Map<String, MutableInt> counters = new TreeMap<String, MutableInt>();
    int total = 0;
    while (it.hasNext()) {
        total += 1;//w  w w  . j a v  a 2s .  co m
        String annoType = "rien";
        try {
            Annotation annotation = (Annotation) it.next();
            annoType = annotation.getType().getName();
        } catch (NullPointerException e) {
            it.moveToNext();
            annoType = e.getClass().getCanonicalName();
        }
        if (counters.get(annoType) == null) {
            counters.put(annoType, new MutableInt(1));
        } else {
            counters.get(annoType).increment();
        }
    }
    System.out.println("Total annotation in JCas (ID: " + System.identityHashCode(jcas) + "): " + total);
    for (String annoType : counters.keySet()) {
        System.out.println(annoType + ": " + counters.get(annoType));
    }
}

From source file:org.mule.module.launcher.MuleApplicationClassLoader.java

@Override
public String toString() {
    return String.format("%s[%s]@%s", getClass().getName(), appName,
            Integer.toHexString(System.identityHashCode(this)));
}