本文整理汇总了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);
}
示例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);
}
}
}
示例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);
}
}
示例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";
}
示例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);
}
}
示例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;
}
};
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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());
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例15: modifiers
protected int[] modifiers() {
return new int[] {
Modifier.FINAL | SYNTHETIC,
Modifier.FINAL
};
}