Java Reflection Field Check getFieldSize(Class clazz)

Here you can find the source of getFieldSize(Class clazz)

Description

get Field Size

License

Open Source License

Declaration

public static int getFieldSize(Class clazz) 

Method Source Code

//package com.java2s;

import java.util.IdentityHashMap;
import java.util.Map;

public class Main {
    private static final Map primitiveSizes = new IdentityHashMap() {
        {//from ww w . j av  a2s  .  c  o  m
            put(boolean.class, new Integer(1));
            put(byte.class, new Integer(1));
            put(char.class, new Integer(2));
            put(short.class, new Integer(2));
            put(int.class, new Integer(4));
            put(float.class, new Integer(4));
            put(double.class, new Integer(8));
            put(long.class, new Integer(8));
        }
    };

    public static int getFieldSize(Class clazz) {
        Integer i = (Integer) primitiveSizes.get(clazz);
        return i != null ? i.intValue() : getPointerSize();
    }

    public static int getPointerSize() {
        return 4;
    }
}

Related

  1. addFieldClass(String fieldName, Class clazz)
  2. getAllFieldsNoCache(Class realClass, Class upperClass)
  3. getFieldAttribute(Class entityClass, String fieldName)
  4. getFields(Class klass)
  5. isFieldAutoBindable(Class clazz)
  6. isJavaClass(Field field)
  7. putCachedSerializerForClass(Class instanceType, Class customFieldSerializer)