List of usage examples for java.lang System identityHashCode
@HotSpotIntrinsicCandidate public static native int identityHashCode(Object x);
From source file:IK.AbstractBone.java
public AbstractBone(AbstractArmature parArma, DVector tipHeading, DVector rollHeading, String inputTag, double inputBoneHeight, frameType coordinateType) throws NullParentForBoneException { if (parArma != null) { if (this.tag == null || this.tag == "") { this.tag = Integer.toString(System.identityHashCode(this)); } else// w ww .jav a2 s .co m this.tag = inputTag; Ray tipHeadingRay = new Ray(parArma.localAxes.origin(), tipHeading); tipHeadingRay.getRayScaledTo(inputBoneHeight); Ray rollHeadingRay = new Ray(parArma.localAxes.origin(), 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 = parArma.localAxes.getGlobalOf(tipHeadingRay.heading()); tempRoll = parArma.localAxes.getGlobalOf(rollHeadingRay.heading()); } else { System.out.println("WOAH WOAH WOAH"); } tempX = tempRoll.cross(tempTip); tempRoll = tempX.cross(tempTip); this.parentArmature = parArma; parentArmature.addToBoneList(this); generateAxes(parentArmature.localAxes.origin(), tempX, tempTip, tempRoll); this.localAxes.orthogonalize(); localAxes.setParent(parentArmature.localAxes); previousOrientation = localAxes.attachedCopy(true); majorRotationAxes = parentArmature.localAxes().getAbsoluteCopy(); majorRotationAxes.setParent(parentArmature.localAxes()); this.boneHeight = inputBoneHeight; //this.updateSegmentedArmature(); } else { throw new NullParentForBoneException(); } }
From source file:net.datenwerke.sandbox.SandboxLoader.java
@Override protected Class<?> loadClass(final String name, boolean resolve) throws ClassNotFoundException { Class clazz = null;/*from ww w. j a va 2s . c om*/ if (debug) logger.log(Level.INFO, getName() + "(" + System.identityHashCode(this) + ")" + " about to load class: " + name); if (null != enhancer) enhancer.classtoBeLoaded(this, name, resolve); boolean trustedSource = false; if (name.startsWith("java.") || bypassClazz(name)) { clazz = super.loadClass(name, resolve); /* check if it comes from an available jar */ if (!name.startsWith("java.") && null != whitelistedUcp) { String path = name.replace('.', '/').concat(".class"); Resource res = whitelistedUcp.getResource(path, false); if (res != null) trustedSource = true; } } else { /* check subcontext */ if (hasSubloaders) { SandboxLoader subLoader = doGetSubLoaderByClassContext(name); if (null != subLoader) return subLoader.loadClass(name, resolve); } /* check if we have already handeled this class */ clazz = findLoadedClass(name); if (clazz != null) { if (null != whitelistedUcp) { String path = name.replace('.', '/').concat(".class"); Resource res = whitelistedUcp.getResource(path, false); if (res != null) trustedSource = true; } } else { try { String basePath = name.replace('.', '/'); String path = basePath.concat(".class"); ProtectionDomain domain = null; try { CodeSource codeSource = new CodeSource(new URL("file", "", codesource.concat(basePath)), (java.security.cert.Certificate[]) null); domain = new ProtectionDomain(codeSource, new Permissions(), this, null); } catch (MalformedURLException e) { throw new RuntimeException("Could not create protection domain."); } /* define package */ int i = name.lastIndexOf('.'); if (i != -1) { String pkgName = name.substring(0, i); java.lang.Package pkg = getPackage(pkgName); if (pkg == null) { definePackage(pkgName, null, null, null, null, null, null, null); } } /* first strategy .. check jars */ if (null != whitelistedUcp) { Resource res = whitelistedUcp.getResource(path, false); if (res != null) { byte[] cBytes = enhance(name, res.getBytes()); clazz = defineClass(name, cBytes, 0, cBytes.length, domain); trustedSource = true; } } /* load class */ if (clazz == null) { InputStream in = null; try { /* we only load from local sources */ in = parent.getResourceAsStream(path); byte[] cBytes = null; if (in != null) cBytes = IOUtils.toByteArray(in); if (null == cBytes && null != enhancer) cBytes = enhancer.loadClass(this, name); if (null == cBytes) throw new ClassNotFoundException("Could not find " + name); /* load and define class */ cBytes = enhance(name, cBytes); clazz = defineClass(name, cBytes, 0, cBytes.length, domain); } finally { if (null != in) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } /* do we need to resolve */ if (resolve) resolveClass(clazz); } catch (IOException e) { throw new ClassNotFoundException("Could not load " + name, e); } catch (Exception e) { throw new ClassNotFoundException("Could not load " + name, e); } } } if (!trustedSource && null != clazz && null != securityManager) securityManager.checkClassAccess(name); if (null != enhancer) enhancer.classLoaded(this, name, clazz); return clazz; }
From source file:org.mule.transport.AbstractTransportMessageHandler.java
@Override public String toString() { final StringBuffer sb = new StringBuffer(80); sb.append(ClassUtils.getSimpleName(this.getClass())); sb.append("{this=").append(Integer.toHexString(System.identityHashCode(this))); sb.append(", endpoint=").append(endpoint.getEndpointURI()); sb.append(", disposed=").append(getLifecycleState().isDisposed()); sb.append('}'); return sb.toString(); }
From source file:org.gachette.spi.graphprovider.collection.CollectionGraphProvider.java
private int calculateHashCode(Object object) { if (object instanceof GachetteProxy) { return System.identityHashCode(((GachetteProxy) object).getOriginalObject()); } else {/*from ww w . ja va 2 s . co m*/ return System.identityHashCode(object); } }
From source file:org.pentaho.reporting.engine.classic.core.Element.java
public SimpleStyleSheet getComputedStyle() { final SimpleStyleSheet computedStyle = (SimpleStyleSheet) this.attributes .getAttribute(AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.COMPUTED_STYLE); if (computedStyle == null) { final int hc = System.identityHashCode(this); throw new InvalidReportStateException("No computed style for (" + hc + ") - " + this); }//from w w w . j av a 2s .c o m return computedStyle; }
From source file:org.springframework.context.annotation.ConfigurationClassPostProcessor.java
/** * Derive further bean definitions from the configuration classes in the registry. *///from w w w .ja va 2 s. co m @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { int registryId = System.identityHashCode(registry); if (this.registriesPostProcessed.contains(registryId)) { throw new IllegalStateException( "postProcessBeanDefinitionRegistry already called on this post-processor against " + registry); } if (this.factoriesPostProcessed.contains(registryId)) { throw new IllegalStateException( "postProcessBeanFactory already called on this post-processor against " + registry); } this.registriesPostProcessed.add(registryId); processConfigBeanDefinitions(registry); }
From source file:org.apache.hadoop.hive.llap.cache.LlapAllocatorBuffer.java
private String toDebugString(long state) { return "0x" + Integer.toHexString(System.identityHashCode(this)) + "(" + State.getArena(state) + ":" + State.getHeader(state) + "; " + allocSize + "; " + State.toFlagString(State.getAllFlags(state)) + ")"; }
From source file:org.broadleafcommerce.common.copy.MultiTenantCopyContext.java
public Object removeOriginalIdentifier(Object copy) { if (currentEquivalentMap.containsKey(System.identityHashCode(copy))) { currentCloneMap.remove(System.identityHashCode(copy)); String valKey = currentEquivalentMap.remove(System.identityHashCode(copy)); return Long.parseLong(valKey.substring(valKey.indexOf("_") + 1, valKey.length())); }/*from ww w . j av a2 s . c o m*/ return null; }
From source file:com.meltmedia.cadmium.servlets.ClassLoaderLeakPreventor.java
public void contextInitialized(ServletContextEvent servletContextEvent) { final ServletContext servletContext = servletContextEvent.getServletContext(); stopThreads = !"false".equals(servletContext.getInitParameter("ClassLoaderLeakPreventor.stopThreads")); stopTimerThreads = !"false" .equals(servletContext.getInitParameter("ClassLoaderLeakPreventor.stopTimerThreads")); executeShutdownHooks = !"false" .equals(servletContext.getInitParameter("ClassLoaderLeakPreventor.executeShutdownHooks")); threadWaitMs = getIntInitParameter(servletContext, "ClassLoaderLeakPreventor.threadWaitMs", THREAD_WAIT_MS_DEFAULT);/*from ww w. j a v a2s .c o m*/ shutdownHookWaitMs = getIntInitParameter(servletContext, "ClassLoaderLeakPreventor.shutdownHookWaitMs", SHUTDOWN_HOOK_WAIT_MS_DEFAULT); info("Settings for " + this.getClass().getName() + " (CL: 0x" + Integer.toHexString(System.identityHashCode(getWebApplicationClassLoader())) + "):"); info(" stopThreads = " + stopThreads); info(" stopTimerThreads = " + stopTimerThreads); info(" executeShutdownHooks = " + executeShutdownHooks); info(" threadWaitMs = " + threadWaitMs + " ms"); info(" shutdownHookWaitMs = " + shutdownHookWaitMs + " ms"); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { // If package org.jboss is found, we may be running under JBoss mayBeJBoss = (contextClassLoader.getResource("org/jboss") != null); } catch (Exception ex) { // Do nothing } info("Initializing context by loading some known offenders with system classloader"); // This part is heavily inspired by Tomcats JreMemoryLeakPreventionListener // See http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?view=markup try { // Switch to system classloader in before we load/call some JRE stuff that will cause // the current classloader to be available for garbage collection Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); java.awt.Toolkit.getDefaultToolkit(); // Will start a Thread java.security.Security.getProviders(); java.sql.DriverManager.getDrivers(); // Load initial drivers using system classloader javax.imageio.ImageIO.getCacheDirectory(); // Will call sun.awt.AppContext.getAppContext() try { Class.forName("javax.security.auth.Policy").getMethod("getPolicy").invoke(null); } catch (IllegalAccessException iaex) { error(iaex); } catch (InvocationTargetException itex) { error(itex); } catch (NoSuchMethodException nsmex) { error(nsmex); } catch (ClassNotFoundException e) { // Ignore silently - class is deprecated } try { javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (Exception ex) { // Example: ParserConfigurationException error(ex); } try { Class.forName("javax.xml.bind.DatatypeConverterImpl"); // Since JDK 1.6. May throw java.lang.Error } catch (ClassNotFoundException e) { // Do nothing } try { Class.forName("javax.security.auth.login.Configuration", true, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { // Do nothing } // This probably does not affect classloaders, but prevents some problems with .jar files try { // URL needs to be well-formed, but does not need to exist new URL("jar:file://dummy.jar!/").openConnection().setDefaultUseCaches(false); } catch (Exception ex) { error(ex); } ///////////////////////////////////////////////////// // Load Sun specific classes that may cause leaks final boolean isSunJRE = System.getProperty("java.vendor").startsWith("Sun"); try { Class.forName("com.sun.jndi.ldap.LdapPoolManager"); } catch (ClassNotFoundException cnfex) { if (isSunJRE) error(cnfex); } try { Class.forName("sun.java2d.Disposer"); // Will start a Thread } catch (ClassNotFoundException cnfex) { if (isSunJRE && !mayBeJBoss) // JBoss blocks this package/class, so don't warn error(cnfex); } try { Class<?> gcClass = Class.forName("sun.misc.GC"); final Method requestLatency = gcClass.getDeclaredMethod("requestLatency", long.class); requestLatency.invoke(null, 3600000L); } catch (ClassNotFoundException cnfex) { if (isSunJRE) error(cnfex); } catch (NoSuchMethodException nsmex) { error(nsmex); } catch (IllegalAccessException iaex) { error(iaex); } catch (InvocationTargetException itex) { error(itex); } // Cause oracle.jdbc.driver.OracleTimeoutPollingThread to be started with contextClassLoader = system classloader try { Class.forName("oracle.jdbc.driver.OracleTimeoutThreadPerVM"); } catch (ClassNotFoundException e) { // Ignore silently - class not present } } finally { // Reset original classloader Thread.currentThread().setContextClassLoader(contextClassLoader); } }
From source file:it.unibo.alchemist.boundary.monitors.RecordingMonitor.java
/** * Save in a svg file a screenshot of the current source. * /*from w w w . j av a2 s . co m*/ * @param env * unused * @param r * unused * @param time * the current time of the simulation that could be added to the * file name * @param step * the current step of the simulation that could be added to the * file name */ @SuppressWarnings("unchecked") private void saveScreenshot(final Environment<T> env, final Reaction<T> r, final Time time, final long step) { assert source == sourceComponent; // NOPMD if (source != null) { source.stepDone(env, r, time, step); if (System.identityHashCode(fpCache) != System.identityHashCode(getFilePath())) { fpCache = getFilePath(); } if (System.identityHashCode(efCache) != System.identityHashCode(getEffectsFile())) { efCache = getEffectsFile(); List<Effect> effects = null; try { effects = (List<Effect>) FileUtilities.fileToObject(getEffectsFile()); } catch (IOException | ClassNotFoundException e1) { effects = defEffects; } finally { source.setEffectStack(effects); sourceComponent.revalidate(); } } final int zoomVal = zoom.getVal(); final double[] offset = env.getOffset(); final double[] size = env.getSize(); offset[0] += size[0] / 2; offset[1] += size[1] / 2; final Position center = new Continuous2DEuclidean(offset); source.zoomTo(center, zoomVal); sourceComponent.revalidate(); // source.getWormhole().setViewPosition(new Point(width.getVal() * povX.getVal() / 100, // (height.getVal() * povY.getVal() / 100) + height.getVal())); lastStep = step; lastUpdate = time.toDouble(); final String currentStep = isLoggingStep() ? getSeparator() + step : ""; final String currentTime = isLoggingTime() ? getSeparator() + time : ""; try { final boolean dir = new File(fpCache).mkdirs(); writer = new PrintStream(new File(fpCache + System.getProperty("file.separator") + screenCounter++ + currentStep + currentTime + ".svg"), StandardCharsets.UTF_8.name()); if (!dir) { L.error("Cannot create monitor"); } } catch (FileNotFoundException | UnsupportedEncodingException e) { L.error("Cannot create monitor", e); } svgGraphicator = new SVGGraphics2D(width.getVal(), height.getVal()); source.setDrawLinks(drawLinks); // final Method paintComponent = sourceComponent.getClass().getMethod("paintComponent", Graphics.class); // paintComponent.setAccessible(true); // paintComponent.invoke(sourceComponent, svgGraphicator); sourceComponent.paint(svgGraphicator); writer.print(svgGraphicator.getSVGDocument()); writer.close(); } }