import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
import static x30_pkg.x30_util.DynamicObject;
class main {
static double collectionBytesPerEntry(Collection l) {
Object[] a = toObjectArray_nonConcurrent(l);
long arraySize = unsafe_sizeOf(a);
long payloadSize = guessObjectSize(a)-arraySize;
return doubleRatio(guessObjectSize(l)-payloadSize, l(a));
}
static Object[] toObjectArray_nonConcurrent(Collection c) {
int n = l(c);
Object[] a = new Object[n];
if (c != null) {
var it = c.iterator();
for (int i = 0; i < n; i++)
a[i] = it.next();
}
return a;
}
static Map unsafe_sizeOf_cache = weakHashMap();
static long unsafe_sizeOf(Object o) {
if (isArray(o))
if (o instanceof Object[])
return inMemorySizeOfObjectArray(((Object[]) o).length);
else
return inMemorySizeOfPrimitiveArray(o);
Class c = _getClass(o);
Integer l = unsafe_sizeOf_cache.get(c);
if (l == null)
unsafe_sizeOf_cache.put(c, l = unsafe_sizeOf_uncached(c));
return l;
}
static int unsafe_sizeOf_uncached(Class src) {
int WORD = javaDataModelWordSize();
int MIN_SIZE = 16;
List instanceFields = new ArrayList();
while (src != null && src != Object.class && empty(instanceFields)) {
for (Field f : src.getDeclaredFields())
if ((f.getModifiers() & Modifier.STATIC) == 0)
instanceFields.add(f);
src = src.getSuperclass();
}
long maxOffset = MIN_SIZE-1;
for (Field f : instanceFields) {
long offset = unsafe_objectFieldOffset(f);
if (offset > maxOffset) maxOffset = offset;
}
return (((int) maxOffset/WORD) + 1)*WORD;
}
static long guessObjectSize(Object o) {
return guessDeepObjectSize_recursive(o);
}
static long guessObjectSize(guessDeepObjectSize_recursive_Data data, Object o) {
return guessDeepObjectSize_recursive(data, o);
}
static double doubleRatio(double x, double y) {
return y == 0 ? 0 : x/y;
}
static int l(Object[] a) { return a == null ? 0 : a.length; }
static int l(boolean[] a) { return a == null ? 0 : a.length; }
static int l(byte[] a) { return a == null ? 0 : a.length; }
static int l(short[] a) { return a == null ? 0 : a.length; }
static int l(long[] a) { return a == null ? 0 : a.length; }
static int l(int[] a) { return a == null ? 0 : a.length; }
static int l(float[] a) { return a == null ? 0 : a.length; }
static int l(double[] a) { return a == null ? 0 : a.length; }
static int l(char[] a) { return a == null ? 0 : a.length; }
static int l(Collection c) { return c == null ? 0 : c.size(); }
static int l(Iterator i) { return iteratorCount_int_close(i); } // consumes the iterator && closes it if possible
static int l(Map m) { return m == null ? 0 : m.size(); }
static int l(CharSequence s) { return s == null ? 0 : s.length(); }
static long l(File f) { return f == null ? 0 : f.length(); }
static int l(Object o) {
return o == null ? 0
: o instanceof String ? l((String) o)
: o instanceof Map ? l((Map) o)
: o instanceof Collection ? l((Collection) o)
: o instanceof Object[] ? l((Object[]) o)
: o instanceof boolean[] ? l((boolean[]) o)
: o instanceof byte[] ? l((byte[]) o)
: o instanceof char[] ? l((char[]) o)
: o instanceof short[] ? l((short[]) o)
: o instanceof int[] ? l((int[]) o)
: o instanceof float[] ? l((float[]) o)
: o instanceof double[] ? l((double[]) o)
: o instanceof long[] ? l((long[]) o)
: (Integer) call(o, "size");
}
static Map weakHashMap() {
return newWeakHashMap();
}
static boolean isArray(Object o) {
return o != null && o.getClass().isArray();
}
static long inMemorySizeOfObjectArray(int length) {
return roundUpTo(javaDataModelWordSize(),
unsafe_sizeOf(_SimulatedArrayStub.class) + java_pointerSize()*((long) length));
}
static long inMemorySizeOfPrimitiveArray(Object o) {
return roundUpTo(javaDataModelWordSize(),
unsafe_sizeOf(_SimulatedArrayStub.class) + primitiveTypeSize(arrayElementType(o))*((long) l(o)));
}
static Class> _getClass(String name) {
try {
return Class.forName(name);
} catch (ClassNotFoundException e) {
return null; // could optimize this
}
}
static Class _getClass(Object o) {
return o == null ? null
: o instanceof Class ? (Class) o : o.getClass();
}
static Class _getClass(Object realm, String name) {
try {
return classLoaderForObject(realm).loadClass(classNameToVM(name));
} catch (ClassNotFoundException e) {
return null; // could optimize this
}
}
static int javaDataModelWordSize_value;
static int javaDataModelWordSize() {
if (javaDataModelWordSize_value == 0)
javaDataModelWordSize_value = Integer.valueOf(System.getProperty("sun.arch.data.model"))/8;
return javaDataModelWordSize_value;
}
static boolean empty(Collection c) { return c == null || c.isEmpty(); }
static boolean empty(Iterable c) { return c == null || !c.iterator().hasNext(); }
static boolean empty(CharSequence s) { return s == null || s.length() == 0; }
static boolean empty(Map map) { return map == null || map.isEmpty(); }
static boolean empty(Object[] o) { return o == null || o.length == 0; }
static boolean empty(Object o) {
if (o instanceof Collection) return empty((Collection) o);
if (o instanceof String) return empty((String) o);
if (o instanceof Map) return empty((Map) o);
if (o instanceof Object[]) return empty((Object[]) o);
if (o instanceof byte[]) return empty((byte[]) o);
if (o == null) return true;
throw fail("unknown type for 'empty': " + getType(o));
}
static boolean empty(Iterator i) { return i == null || !i.hasNext(); }
static boolean empty(double[] a) { return a == null || a.length == 0; }
static boolean empty(float[] a) { return a == null || a.length == 0; }
static boolean empty(int[] a) { return a == null || a.length == 0; }
static boolean empty(long[] a) { return a == null || a.length == 0; }
static boolean empty(byte[] a) { return a == null || a.length == 0; }
static boolean empty(short[] a) { return a == null || a.length == 0; }
static boolean empty(File f) { return getFileSize(f) == 0; }
static long unsafe_objectFieldOffset(Field f) {
return (long) call(theUnsafe_gen(), "objectFieldOffset", f);
}
static class guessDeepObjectSize_recursive_Data {
long size;
List stack = new ArrayList();
Set seen = identityHashSet(); // add objects here to ignore them
Set fieldsToIgnore;
Set realmsToIgnore;
VF1