public static boolean callDesiredAssertionStatus(Class thiz) { return thiz.desiredAssertionStatus(); }
private boolean assertFinal() { try { final Class<?> clazz = getClass(); if (!clazz.desiredAssertionStatus()) return true; assert clazz.isAnonymousClass() || (clazz.getModifiers() & (Modifier.FINAL | Modifier.PRIVATE)) != 0 || Modifier.isFinal(clazz.getMethod("incrementToken").getModifiers()) : "TokenStream implementation classes or at least their incrementToken() implementation must be final"; return true; } catch (NoSuchMethodException nsme) { return false; } }
public ClientPropertyContext(Object instance, Setter setter, Class<?>[] types, int[] paramCounts) { this.instance = instance; this.setter = setter; this.simpleType = null; this.paramTypes = types; this.paramCounts = paramCounts; /* * Verify input arrays of same length and that the total parameter count, * plus one for the root type, equals the total number of types passed in. */ if (ClientPropertyContext.class.desiredAssertionStatus()) { assert types.length == paramCounts.length : "Length mismatch " + types.length + " != " + paramCounts.length; int count = 1; for (int i = 0, j = paramCounts.length; i < j; i++) { count += paramCounts[i]; } assert count == types.length : "Mismatch in total parameter count " + count + " != " + types.length; } }
/** * Assert that the given {@link Element} is compatible with this class and * automatically typecast it. */ public static HeadingElement as(Element elem) { if (HeadingElement.class.desiredAssertionStatus()) { assert is(elem); } return (HeadingElement) elem; }
/** * Makes a best-effort attempt to get a useful debugging string describing the * given JavaScriptObject. In Production Mode with assertions disabled, this * will either call and return the JSO's toString() if one exists, or just * return "[JavaScriptObject]". In Development Mode, or with assertions * enabled, some stronger effort is made to represent other types of JSOs, * including inspecting for document nodes' outerHTML and innerHTML, etc. */ @Override public final String toString() { return JavaScriptObject.class.desiredAssertionStatus() ? toStringVerbose(this) : toStringSimple(this); }
public class Assert { static final boolean $assertionsDisabled = !Assert.class.desiredAssertionStatus(); public static void main(String[] args) { if (!$assertionsDisabled) { if (System.currentTimeMillis() != 0L) { throw new AssertionError(); } } } }
public class Assert { // This method is synthetic. static final boolean $assertionsDisabled = !Assert.class.desiredAssertionStatus(); public static void main(String[] args) { if (!$assertionsDisabled) { if (System.currentTimeMillis() != 0L) { throw new AssertionError(); } } } }
/** * Tests orthrodromic distance on the equator. The main purpose of this method is actually to * get Java assertions to be run, which will compare the Geodetic Calculator results with the * Default Ellipsoid computations. */ @Test public void testEquator() { assertTrue(GeodeticCalculator.class.desiredAssertionStatus()); final GeodeticCalculator calculator = new GeodeticCalculator(); calculator.setStartingGeographicPoint(0, 0); double last = Double.NaN; for (double x = 0; x <= 180; x += 0.125) { calculator.setDestinationGeographicPoint(x, 0); final double distance = calculator.getOrthodromicDistance() / 1000; // In kilometers /* * Checks that the increment is constant and then tapers off. */ assertTrue( x == 0 ? (distance == 0) : (x < 179.5 ? (Math.abs(distance - last - 13.914936) < 2E-6) : (distance - last < 13))); last = distance; } }
/** * Tests {@link GeneralDirectPosition#equals} method between different implementations. The * purpose of this test is also to run the assertion in the direct position implementations. */ @Test public void testEquals() { assertTrue(GeneralDirectPosition.class.desiredAssertionStatus()); assertTrue(DirectPosition2D.class.desiredAssertionStatus()); CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84; DirectPosition p1 = new DirectPosition2D(WGS84, 48.543261561072285, -123.47009555832284); GeneralDirectPosition p2 = new GeneralDirectPosition(48.543261561072285, -123.47009555832284); assertFalse(p1.equals(p2)); assertFalse(p2.equals(p1)); p2.setCoordinateReferenceSystem(WGS84); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); } }
JsClassLoader(ClassLoader parent) { super(parent); setDefaultAssertionStatus(JsClassLoader.class.desiredAssertionStatus()); } }
private void assertNothingPending() { if (getClass().desiredAssertionStatus()) { for (TypeInfoComputed tic : typeToTypeInfoComputed.values()) { assert (!tic.isPendingInstantiable()); } } }
private void assertNothingPending() { if (getClass().desiredAssertionStatus()) { for (TypeInfoComputed tic : typeToTypeInfoComputed.values()) { assert (!tic.isPendingInstantiable()); } } }
public JsClassLoaderImpl(ClassLoader parent, FindResources f, Fn.Presenter d) { super(parent); setDefaultAssertionStatus(JsClassLoader.class.desiredAssertionStatus()); this.f = f; this.d = d; }
/** * Assert that the given {@link Element} is compatible with this class and * automatically typecast it. */ public static HeadingElement as(Element elem) { if (HeadingElement.class.desiredAssertionStatus()) { assert is(elem); } return (HeadingElement) elem; }
/** * Assert that the given {@link Element} is compatible with this class and * automatically typecast it. */ public static HeadingElement as(Element elem) { if (HeadingElement.class.desiredAssertionStatus()) { assert is(elem); } return (HeadingElement) elem; }
/** * Makes a best-effort attempt to get a useful debugging string describing the * given JavaScriptObject. In Production Mode with assertions disabled, this * will either call and return the JSO's toString() if one exists, or just * return "[JavaScriptObject]". In Development Mode, or with assertions * enabled, some stronger effort is made to represent other types of JSOs, * including inspecting for document nodes' outerHTML and innerHTML, etc. */ @Override public final String toString() { return JavaScriptObject.class.desiredAssertionStatus() ? toStringVerbose(this) : toStringSimple(this); }
/** * Creates a new test suite for the given class. * * @param testing The class to be tested. */ protected ImageTestBase(final Class<?> testing) { assertTrue(testing.desiredAssertionStatus()); viewEnabled = Boolean.getBoolean(SwingTestBase.SHOW_PROPERTY_KEY); }
private OperationTransformerRegistry getRegistryUpdater(final ModelVersion version) { int micro = version.getMicro(); for (int i = micro; i >= 0; i--) { ModelVersion currentVersion = ModelVersion.create(version.getMajor(), version.getMinor(), i); OperationTransformerRegistry current = registryUpdater.get(this, currentVersion); if (current != null) { if(micro != i && this.getClass().desiredAssertionStatus()) { ControllerLogger.MGMT_OP_LOGGER.couldNotFindTransformerRegistryFallingBack(version, currentVersion); } return current; } } return null; }
/** * Makes sure that J2SE 1.4 assertions are enabled. */ @Test public void testAssertionEnabled() { assertTrue("Assertions not enabled.", Hints.class.desiredAssertionStatus()); }
/** * Creates a new test case using the given hints for fetching the factories. * * @param type The base class of the transform being tested. * @param hints The hints to use for fetching factories, or {@code null} for the default ones. */ protected TransformTestBase(final Class<? extends MathTransform> type, final Hints hints) { this(FactoryFinder.getDatumFactory(hints), FactoryFinder.getCRSFactory(hints), FactoryFinder.getMathTransformFactory(hints)); assertTrue("Tests should be run with assertions enabled.", type.desiredAssertionStatus()); }