当前位置: 首页>>代码示例>>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;未经允许,请勿转载。