public void testReferenceSize() { if (!isSupportedJVM()) { System.err.println("WARN: Your JVM does not support certain Oracle/Sun extensions."); System.err.println(" Memory estimates may be inaccurate."); System.err.println(" Please report this to the Lucene mailing list."); System.err.println("JVM version: " + RamUsageEstimator.JVM_INFO_STRING); System.err.println("UnsupportedFeatures:"); for (JvmFeature f : RamUsageEstimator.getUnsupportedFeatures()) { System.err.print(" - " + f.toString()); if (f == RamUsageEstimator.JvmFeature.OBJECT_ALIGNMENT) { System.err.print( "; Please note: 32bit Oracle/Sun VMs don't allow exact OBJECT_ALIGNMENT retrieval, this is a known issue."); } System.err.println(); } } assertTrue(NUM_BYTES_OBJECT_REF == 4 || NUM_BYTES_OBJECT_REF == 8); if (!Constants.JRE_IS_64BIT) { assertEquals("For 32bit JVMs, reference size must always be 4?", 4, NUM_BYTES_OBJECT_REF); } }
/** * Returns true, if the current JVM is fully supported by {@code RamUsageEstimator}. If this * method returns {@code false} you are maybe using a 3rd party Java VM that is not supporting * Oracle/Sun private APIs. The memory estimates can be imprecise then (no way of detecting * compressed references, alignments, etc.). Lucene still tries to use sensible defaults. */ public static boolean isSupportedJVM() { return supportedFeatures.size() == JvmFeature.values().length; }