List of usage examples for java.lang System identityHashCode
@HotSpotIntrinsicCandidate public static native int identityHashCode(Object x);
From source file:nz.co.senanque.forms.FormFactoryTest.java
@Test public void testGetForm() { WorkflowForm form1 = m_formFactory.getForm("launchForm"); WorkflowForm form2 = m_formFactory.getForm("launchForm"); assertFalse(System.identityHashCode(form2) == System.identityHashCode(form1)); WorkflowForm form3 = m_formFactory.getForm("secondForm"); assertNotNull(form3);//from w w w.j av a 2 s.c o m }
From source file:com.mycompany.sportsclubimmutable.PlayerRecords.testRuns.java
@Test // public void testImmutable() { //Testing that the object wasn't edited or changed but that //A whole new object was created and returned bts_runs = new Batsman_runs("Rafiq", "Samsodien", 5, 50); /******** Get HashCode *****************/ String num1 = Integer.toHexString(System.identityHashCode(bts_runs)); String num2 = Integer.toHexString(System.identityHashCode(bts_runs.updateGamesPlayed(7))); Assert.assertNotEquals(num1, num2, "Objects are same"); }
From source file:de.micromata.genome.util.runtime.jndi.JndiDumper.java
public static void dumpJndiBinding(InitialContext initialContext, String parentKey, Binding binding, StringBuilder sb, String indent) throws NamingException { try {//www. j a va 2 s . c om Object obj = binding.getObject(); ClassLoader bindClassLoader = obj.getClass().getClassLoader(); sb.append(indent).append(parentKey + "/" + binding.getName()).append("(") .append(System.identityHashCode(binding)).append(", cl: ").append(bindClassLoader).append("): ") .append(binding.toString()); if (obj instanceof Context) { sb.append("\n"); Context ctx = (Context) obj; indent += " "; NamingEnumeration<Binding> bindings = ctx.listBindings(""); while (bindings.hasMore()) { Binding cbinding = bindings.next(); dumpJndiBinding(initialContext, parentKey + "/" + binding.getName(), cbinding, sb, indent); } } else if (obj instanceof Reference) { Reference ref = (Reference) obj; // binding.get // ref. sb.append("\n"); } else if (obj instanceof Session) { Session sess = (Session) obj; sb.append("\n"); } else if (obj instanceof DataSource) { DataSource ds = (DataSource) obj; if (ds instanceof BasicDataSource) { BasicDataSource dbds = (BasicDataSource) ds; sb.append(" '" + dbds.getUrl() + "'"); } sb.append("\n"); } else if (obj != null) { Class<? extends Object> clazz = obj.getClass(); sb.append(" unkown type: " + clazz); sb.append("\n"); } } catch (NamingException ex) { sb.append("Error access binding: " + binding.getName() + ": " + ex.getMessage()); } }
From source file:org.apache.mnemonic.ChunkBufferNGTest.java
@Test public void testGenChunkBuffers() { Checksum cs = new CRC32(); cs.reset();/* w ww .j a v a 2s . c o m*/ NonVolatileMemAllocator act = new NonVolatileMemAllocator( Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024 * 1024 * 1024L, "./pmchunkbuffertest.dat", true); act.setChunkReclaimer(new Reclaim<Long>() { @Override public boolean reclaim(Long mres, Long sz) { System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres), null == sz ? "NULL" : sz.toString())); return false; } }); DurableChunk<NonVolatileMemAllocator> mch; mch = act.createChunk(1000 * 1024 * 1024L); Assert.assertNotNull(mch); act.setHandler(m_keyid, mch.getHandler()); long bufcnt = mch.getSize() / m_bufsize; ChunkBuffer ckbuf; byte[] rdbytes; for (long idx = 0; idx < bufcnt; ++idx) { // System.err.println(String.format("---- bufcnt: %d, bufsize: %d, idx: %d", bufcnt, m_bufsize, idx)); ckbuf = mch.getChunkBuffer(idx * m_bufsize, m_bufsize); Assert.assertNotNull(ckbuf); rdbytes = RandomUtils.nextBytes(m_bufsize); Assert.assertNotNull(rdbytes); ckbuf.get().clear(); ckbuf.get().put(rdbytes); cs.update(rdbytes, 0, rdbytes.length); } m_checksum = cs.getValue(); m_count = bufcnt; act.close(); }
From source file:chronos.TestJob.java
/** * {@inheritDoc}//ww w.j a v a 2s. com * * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) */ public final void execute(final JobExecutionContext context) throws JobExecutionException { logger.info("TestJob@" + System.identityHashCode(this) + " executing " + System.currentTimeMillis()); final Object obj = context.getJobDetail().getJobDataMap().get(INITIAL_CONTEXT); if (obj != null) { logger.trace("jobDataMap.get(\"" + INITIAL_CONTEXT + "\") returned " + obj.getClass() + "@" + System.identityHashCode(obj)); if (obj instanceof Context) { executeInJndiContext((Context) obj); } else { logger.error("jobDataMap.get(\"" + INITIAL_CONTEXT + "\") is of type " + obj.getClass() + ", expecting a " + Context.class + "!"); } } else { logger.error("jobDataMap.get(\"" + INITIAL_CONTEXT + "\") returned null!"); } }
From source file:org.datalorax.populace.core.walk.instance.InstanceIdentity.java
@Override public int hashCode() { return System.identityHashCode(instance); }
From source file:com.geomenum.r2d2.spring.common.requestdispatcher.RequestDispatcherFactoryTests.java
public void create2DifferentRequestDispatchers() { RequestDispatcher requestDispatcher1 = requestDispatcherFactory.createRequestDispatcher(); RequestDispatcher requestDispatcher2 = requestDispatcherFactory.createRequestDispatcher(); assertNotEquals(requestDispatcher1, requestDispatcher2); assertNotEquals(System.identityHashCode(requestDispatcher1), System.identityHashCode(requestDispatcher2)); }
From source file:org.compass.core.transaction.LocalTransaction.java
public void join(InternalCompassSession session) throws CompassException { this.session = session; if (log.isDebugEnabled()) { log.debug("Joining an existing local transcation on thread [" + Thread.currentThread().getName() + "] Compass [" + System.identityHashCode(compass) + "] Session [" + System.identityHashCode(session) + "]"); }//from w ww . j a v a 2s .co m }
From source file:org.apache.hise.engine.jaxws.HISEJaxWSService.java
public String getId() { return String.valueOf(System.identityHashCode(this)); //return id; }
From source file:de.ailis.midi4js.MessageReceiver.java
/** * @see javax.sound.midi.Receiver#send(javax.sound.midi.MidiMessage, long) *//*from w ww . j av a2s . c o m*/ @Override public void send(final MidiMessage message, final long timeStamp) { try { final JSONStringer json = new JSONStringer(); json.object(); json.key("status").value(message.getStatus()); json.key("message"); json.array(); final byte[] data = message.getMessage(); final int max = Math.min(data.length, message.getLength()); for (int i = 0; i < max; i++) json.value(data[i] & 0xff); json.endArray(); if (message instanceof ShortMessage) processShortMessage((ShortMessage) message, json); else if (message instanceof MetaMessage) processMetaMessage((MetaMessage) message, json); else if (message instanceof SysexMessage) processSysexMessage((SysexMessage) message, json); json.endObject(); this.applet.execJSMethod("messageReceived", System.identityHashCode(this), json.toString(), timeStamp); } catch (final JSONException e) { throw new RuntimeException(e.toString(), e); } }