當前位置: 首頁>>代碼示例>>Java>>正文


Java Modifier.FINAL屬性代碼示例

本文整理匯總了Java中java.lang.reflect.Modifier.FINAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.FINAL屬性的具體用法?Java Modifier.FINAL怎麽用?Java Modifier.FINAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.lang.reflect.Modifier的用法示例。


在下文中一共展示了Modifier.FINAL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCanSerializeField

public static Field[] getCanSerializeField(Class<?> clazz) {
	Field[] fields = clazz.getDeclaredFields();
	List<Field> canSerializeFields = new ArrayList<Field>();
	for (Field field : fields) {
		if (field.getName().equals("__PARANAMER_DATA")) {
			continue;
		}
		if (field.isEnumConstant()) {
			continue;
		}
		if (field.getType() == Date.class) {
			continue;
		}
		if ((field.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
			continue;
		}
		canSerializeFields.add(field);
	}
	Field[] newFields = new Field[canSerializeFields.size()];
	return canSerializeFields.toArray(newFields);
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:21,代碼來源:CommonUtils.java

示例2: cloneFields

protected void cloneFields(Class<? extends WizardControl> clazz, WizardControl control)
{
	Field[] declaredFields = clazz.getDeclaredFields();
	AccessibleObject.setAccessible(declaredFields, true);
	for( Field field : declaredFields )
	{
		try
		{
			if( (field.getModifiers() & (Modifier.STATIC | Modifier.FINAL)) == 0 )
			{
				field.set(control, field.get(this));
			}
		}
		catch( Exception e )
		{
			throw new RuntimeException(e);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:WizardControl.java

示例3: set

public ReflectUtils set(String name, Object value) {
    try {
        Field field = field0(name);
        if ((field.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
            Field modifiersField = Field.class.getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
        }
        field.set(object, unwrap(value));
        return this;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:ReflectUtils.java

示例4: getVKText

static String getVKText(int keyCode) {
    VKCollection vkCollect = getVKCollection();
    Integer key = Integer.valueOf(keyCode);
    String name = vkCollect.findName(key);
    if (name != null) {
        return name.substring(3);
    }
    int expected_modifiers =
        (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL);

    Field[] fields = KeyEvent.class.getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
        try {
            if (fields[i].getModifiers() == expected_modifiers
                && fields[i].getType() == Integer.TYPE
                && fields[i].getName().startsWith("VK_")
                && fields[i].getInt(KeyEvent.class) == keyCode)
            {
                name = fields[i].getName();
                vkCollect.put(name, key);
                return name.substring(3);
            }
        } catch (IllegalAccessException e) {
            assert(false);
        }
    }
    return "UNKNOWN";
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:AWTKeyStroke.java

示例5: setField

public static void setField(Class<?> cls, Object instance, String fieldName, Object value) {
  Field field = ReflectionUtils.findField(cls, fieldName);
  try {
    if ((field.getModifiers() & Modifier.FINAL) != 0) {
      MODIFIERS_FIELD.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    }
    field.setAccessible(true);
    field.set(instance, value);
  } catch (Exception e) {
    throw new Error(e);
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:12,代碼來源:ReflectUtils.java

示例6: makeAnonExtendsLocal

public Tester makeAnonExtendsLocal(final String message) {
    abstract class LocalTester extends Tester {
        public LocalTester(final int localparam) {
            super(localparam);
        }

        protected String[] names() {
            return new String[] {
                "this$1",
                "localparam",
                "val$message"
            };
        }

        protected int[] modifiers() {
            return new int[] {
                Modifier.FINAL | MANDATED,
                Modifier.FINAL,
                Modifier.FINAL | SYNTHETIC
            };
        }

        protected Class[] types() {
            return new Class[] {
                Encloser.class,
                int.class,
                String.class
            };
        }

    }

    return new LocalTester(2) {
        public String message() {
            return message;
        }
    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:38,代碼來源:CaptureTest.java

示例7: getKlassFlags

private static int getKlassFlags(Class<?> klass) {
    int flags = TypeKlass.NONE;
    if (klass.isInterface()) {
        flags = flags | TypeKlass.INTERFACE;
    } else if ((klass.getModifiers() & Modifier.ABSTRACT) != 0) {
        flags = flags | TypeKlass.ABSTRACT;
    } else if ((klass.getModifiers() & Modifier.FINAL) != 0) {
        flags = flags | TypeKlass.FINAL;
    }
    return flags;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TypesParser.java

示例8: getClassAccessFlags

@MethodSubstitution
public static int getClassAccessFlags(Class<?> aClass) {
    KlassPointer klass = ClassGetHubNode.readClass(GraalDirectives.guardingNonNull(aClass));
    if (klass.isNull()) {
        // Class for primitive type
        return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC;
    } else {
        return klass.readInt(klassAccessFlagsOffset(INJECTED_VMCONFIG), KLASS_ACCESS_FLAGS_LOCATION) & jvmAccWrittenFlags(INJECTED_VMCONFIG);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:ReflectionSubstitutions.java

示例9: findMethodByName

public static Method findMethodByName(Class<?> clazz, String methodName) {
	Method[] methods = clazz.getDeclaredMethods();
	Map<String, Method> methodMap = new HashMap<String, Method>();
	for (Method method : methods) {
		if ((method.getModifiers() & Modifier.FINAL) != 0) {
			continue;
		}
		String tempName = method.getName();
		if (methodMap.get(tempName) != null) {
			continue;
		}
		methodMap.put(method.getName(), method);
	}
	return methodMap.get(methodName);
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:15,代碼來源:CommonUtils.java

示例10: onCreateViewHolder

@Override
public VBaseHolder<T> onCreateViewHolder(ViewGroup parent, int viewType) {
    //為0的時候默認是原始布局文件
    if (viewType == 0)
        viewType = mResLayout;
    VBaseHolder<T> baseHolder = null;
    //獲取ItemView
    View inflate = LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false);
    //判斷是否是穿的VBaseHolder
    if (mClazz != null) {
        if (mClazz.isMemberClass()) {
            if ((mClazz.getModifiers() != (Modifier.PUBLIC | Modifier.STATIC)) && mClazz.getModifiers() != (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL))
                throw new RuntimeException(mClazz + " 是內部類,需要public static 修飾");
        }
        try {
            //根據VBaseHolder的構造器,反射生成VBaseHolder實體對象
            Constructor<? extends VBaseHolder> mClazzConstructor = mClazz.getConstructor(View.class);
            if (mClazzConstructor != null)
                baseHolder = mClazzConstructor.newInstance(inflate);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else
        baseHolder = new VBaseHolder<>(inflate);
    //綁定兩個監聽事件
    if (baseHolder != null) {
        baseHolder.addOnItemClickListener(mItemClickListener);
        baseHolder.getViewHolderHelper().addOnItemChildClickListener(mItemChildClickListener);
    }
    return baseHolder;
}
 
開發者ID:lvtanxi,項目名稱:BaseVLayoutAdapterHelper,代碼行數:31,代碼來源:VBaseAdapter.java

示例11: check

void check(String baseClassName, String project) throws Exception {
    File f = directoryOf(baseClassName, project);
    if (f == null) {
        return;
    }

    StringBuilder e = new StringBuilder();

    File[] files = f.listFiles();
    if (files != null) {
        for (File g : files) {
            if (g.getName().startsWith(baseClassName) && g.getName().endsWith(".java")) {
                String className = "io.reactivex." + project + ".internal.operators." + g.getName().replace(".java", "");

                Class<?> clazz = Class.forName(className);

                if ((clazz.getModifiers() & Modifier.FINAL) == 0 && (clazz.getModifiers() & Modifier.ABSTRACT) == 0) {
                    e.append("java.lang.RuntimeException: ").append(className).append(" is not final\r\n");
                    e.append(" at ").append(className).append(" (").append(g.getName()).append(":14)\r\n\r\n");
                }
            }
        }
    }

    if (e.length() != 0) {
        System.out.println(e);

        throw new AssertionError(e.toString());
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:30,代碼來源:OperatorsAreFinal.java

示例12: getDeclaredSUID

/**
 * Returns explicit serial version UID value declared by given class, or
 * null if none.
 */
private static Long getDeclaredSUID(Class<?> cl) {
    try {
        Field f = cl.getDeclaredField("serialVersionUID");
        int mask = Modifier.STATIC | Modifier.FINAL;
        if ((f.getModifiers() & mask) == mask) {
            f.setAccessible(true);
            return Long.valueOf(f.getLong(null));
        }
    } catch (Exception ex) {
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:ObjectStreamClass.java

示例13: createJava

public static String createJava(String zpackage, String name, int kind, int visibility, int modifier, boolean b) {
    String m = "";
    switch (modifier) {
        case Modifier.ABSTRACT:
            m = "abstract ";
            break;
        case Modifier.FINAL:
            m = "final ";
            break;
    }
    String v = "";
    switch (visibility) {
        case Modifier.PUBLIC:
            v = "public ";
            break;
    }
    String k = "class";
    switch (kind) {
        case 0:
            k = "class";
            break;
        case 1:
            k = "interface";
            break;
        case 2:
            k = "enum";
            break;
    }
    zpackage = zpackage.isEmpty() ? "" : "package " + zpackage + ";";

    return String.format(JAVA_TEMPLATE, v, m, k, name, zpackage);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:32,代碼來源:Template.java

示例14: getModifiers

@MethodSubstitution(isStatic = false)
public static int getModifiers(final Class<?> thisObj) {
    KlassPointer klass = ClassGetHubNode.readClass(thisObj);
    if (klass.isNull()) {
        // Class for primitive type
        return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC;
    } else {
        return klass.readInt(klassModifierFlagsOffset(INJECTED_VMCONFIG), KLASS_MODIFIER_FLAGS_LOCATION);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:HotSpotClassSubstitutions.java

示例15: modifiers

protected int[] modifiers() {
    return new int[] {
        Modifier.FINAL | SYNTHETIC,
        Modifier.FINAL
    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:CaptureTest.java


注:本文中的java.lang.reflect.Modifier.FINAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。