本文整理汇总了Java中java.lang.reflect.Modifier.isFinal方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.isFinal方法的具体用法?Java Modifier.isFinal怎么用?Java Modifier.isFinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.Modifier
的用法示例。
在下文中一共展示了Modifier.isFinal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeValue
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
protected ObjectStreamField[] computeValue(Class<?> type) {
try {
Field pf = type.getDeclaredField("serialPersistentFields");
int mods = pf.getModifiers();
if (Modifier.isPrivate(mods) && Modifier.isStatic(mods) &&
Modifier.isFinal(mods)) {
pf.setAccessible(true);
java.io.ObjectStreamField[] fields =
(java.io.ObjectStreamField[])pf.get(type);
return translateFields(fields);
}
} catch (NoSuchFieldException | IllegalAccessException |
IllegalArgumentException | ClassCastException e) {
}
return null;
}
示例2: doOop
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public void doOop(OopField field, boolean isVMField) {
OopHandle handle = field.getValueAsOopHandle(getObj());
if (! isRobust(handle) ) {
return;
}
java.lang.reflect.Field f = null;
try {
f = readField(field);
if (Modifier.isFinal(f.getModifiers())) return;
f.setAccessible(true);
f.set(obj, readObject(field.getValue(getObj())));
} catch (Exception ex) {
printFieldSetError(f, ex);
}
}
示例3: getMethodFlags
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private static int getMethodFlags(Executable method) {
int flags = FunctionInfo.NONE;
int modifiers = method.getModifiers();
if (Modifier.isAbstract(modifiers)) {
flags |= FunctionInfo.ABSTRACT;
}
if (Modifier.isFinal(modifiers)) {
flags |= FunctionInfo.FINAL;
}
if (Modifier.isPublic(modifiers)) {
flags |= FunctionInfo.PUBLIC;
} else if (Modifier.isProtected(modifiers)) {
flags |= FunctionInfo.PROTECTED;
} else if (Modifier.isPrivate(modifiers)) {
flags |= FunctionInfo.PRIVATE;
} else {
flags |= FunctionInfo.DEFAULT;
}
if (Modifier.isStatic(modifiers)) {
flags |= FunctionInfo.STATIC;
}
if (Modifier.isSynchronized(modifiers)) {
flags |= FunctionInfo.SYNCHRONIZED;
}
return flags;
}
示例4: isDecoratable
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* Indicates that a given field is decoratable (default = is public AND is
* not static AND is not transient);
*
* @param field
* @return
*/
protected boolean isDecoratable(Field field) {
int modifiers = field.getModifiers();
return Modifier.isPublic(modifiers) &&
!Modifier.isStatic(modifiers) &&
!Modifier.isTransient(modifiers) &&
!Modifier.isFinal(modifiers);
}
示例5: ListStorage
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public ListStorage(Class<T> claz, List<T> innerList) {
this.aspect = new DataAspect<T, DataAspectField>(claz, null) {
@Override
protected DataAspectField decorate(Field field) throws Exception {
int modifiers = field.getModifiers();
return Modifier.isFinal(modifiers) ||
Modifier.isStatic(modifiers) ||
Modifier.isTransient(modifiers) ||
!Modifier.isPublic(modifiers)
? null
: new DataAspectField(aspect, field);
}
};
this.list = innerList;
}
示例6: getAllField
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static Set<Field> getAllField(Class<?> clazz) {
Set<Field> fieldSet = new HashSet<Field>();
while (clazz != Object.class) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
int modifier = field.getModifiers();
if (Modifier.isFinal(modifier) || Modifier.isStatic(modifier)) {
continue;
}
fieldSet.add(field);
}
clazz = clazz.getSuperclass();
}
return fieldSet;
}
示例7: copyAllFieldsFrom
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static <T> void copyAllFieldsFrom(T dest, T origin, Class<T> c)
{
for (Field f : FieldUtils.getAllFields(c))
{
if (!Modifier.isStatic(f.getModifiers()) && !Modifier.isFinal(f.getModifiers()))
{
copyField(f, dest, origin);
}
}
}
示例8: createAdapterInfo
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* For a given class, create its adapter class and associated info.
* @param type the class for which the adapter is created
* @return the adapter info for the class.
*/
private static AdapterInfo createAdapterInfo(final Class<?>[] types, final ClassAndLoader definingClassAndLoader) {
Class<?> superClass = null;
final List<Class<?>> interfaces = new ArrayList<>(types.length);
for(final Class<?> t: types) {
final int mod = t.getModifiers();
if(!t.isInterface()) {
if(superClass != null) {
return new AdapterInfo(AdaptationResult.Outcome.ERROR_MULTIPLE_SUPERCLASSES, t.getCanonicalName() + " and " + superClass.getCanonicalName());
}
if (Modifier.isFinal(mod)) {
return new AdapterInfo(AdaptationResult.Outcome.ERROR_FINAL_CLASS, t.getCanonicalName());
}
superClass = t;
} else {
if (interfaces.size() > 65535) {
throw new IllegalArgumentException("interface limit exceeded");
}
interfaces.add(t);
}
if(!Modifier.isPublic(mod)) {
return new AdapterInfo(AdaptationResult.Outcome.ERROR_NON_PUBLIC_CLASS, t.getCanonicalName());
}
}
final Class<?> effectiveSuperClass = superClass == null ? Object.class : superClass;
return AccessController.doPrivileged(new PrivilegedAction<AdapterInfo>() {
@Override
public AdapterInfo run() {
try {
return new AdapterInfo(effectiveSuperClass, interfaces, definingClassAndLoader);
} catch (final AdaptationException e) {
return new AdapterInfo(e.getAdaptationResult());
}
}
}, CREATE_ADAPTER_INFO_ACC_CTXT);
}
示例9: isPersistableField
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* Is this field persistable.
*/
static boolean isPersistableField(Field f) {
if (f.isAnnotationPresent(Transient.class)) {
return false;
}
int mod = f.getModifiers();
if (Modifier.isFinal(mod) || Modifier.isTransient(mod) || Modifier.isStatic(mod)) {
return false;
}
getSqlType(f);
return true;
}
示例10: isOverridable
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@Override
public final boolean isOverridable() {
return !(isFinal()
|| isPrivate()
|| isStatic()
|| Modifier.isFinal(getDeclaringClass().getModifiers()));
}
示例11: isWebMethod
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private boolean isWebMethod(Method method) {
int modifiers = method.getModifiers();
if (Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers))
return false;
Class clazz = method.getDeclaringClass();
boolean declHasWebService = getAnnotation(clazz, WebService.class) != null;
WebMethod webMethod = getAnnotation(method, WebMethod.class);
if (webMethod != null && !webMethod.exclude() && declHasWebService)
return true;
return declHasWebService && !classUsesWebMethod.contains(clazz);
}
示例12: PropertyManager
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public PropertyManager(Object instance, Field field) {
this.instance = instance;
field.setAccessible(true);
IPropertyAccessor accessor = null;
boolean isFinal = Modifier.isFinal(field.getModifiers());
IPropertyMutator mutator = isFinal ? NOPAccessorAndMutator.INSTANCE : null;
for (Method m : getAllMethods(instance.getClass())) {
if (mutator != null && accessor != null)
break;
m.setAccessible(true);
if (m.getName().equals(String.format("get%s", capitalize(field.getName())))) {
accessor = new MethodAccessorAndMutator(instance, m);
continue;
} else if (!isFinal
&& m.getName().equals(String.format("set%s", capitalize(field.getName())))
&& m.getParameterCount() == 1 && m.getParameterTypes()[0].equals(field.getType())) {
mutator = new MethodAccessorAndMutator(instance, m);
continue;
} else if (m.getDeclaredAnnotation(GetterMethod.class) != null) {
if (m.getDeclaredAnnotation(GetterMethod.class).value().equals(field.getName())) {
accessor = new MethodAccessorAndMutator(instance, m);
continue;
}
} else if (!isFinal && m.getDeclaredAnnotation(SetterMethod.class) != null
&& m.getParameterCount() == 1) {
if (m.getDeclaredAnnotation(SetterMethod.class).value().equals(field.getName())) {
mutator = new MethodAccessorAndMutator(instance, m);
continue;
}
}
}
if (accessor == null)
accessor = new FieldAccessorAndMutator(instance, field);
if (mutator == null)
mutator = new FieldAccessorAndMutator(instance, field);
this.accessor = accessor;
this.mutator = mutator;
this.name = field.getName();
}
示例13: initFromString
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public final void initFromString(String params) {
if (params == null || params.isEmpty()) {
return;
}
for (String str : params.split("&")) {
final String[] pp = str.split("=");
final Field[] fs = getClass().getDeclaredFields();
try {
for (Field field : fs) {
if (Modifier.isStatic(field.getModifiers()) && Modifier
.isFinal(field.getModifiers())) {
continue;
}
if (pp[0].equals(field.getName())) {
field.setAccessible(true);
if ("properties".equals(field.getName())) {
final List<QProperty> list = new LinkedList<>();
String lst = URLDecoder.decode(pp[1], "utf-8");
lst = lst.substring(1, lst.length() - 1);
final String[] ll = lst.split("\\}\\{");
for (String el : ll) {
final String[] ss = el.split("\\[|\\]|:");
if (ss.length == 4) {
list.add(new QProperty(ss[1], ss[2], ss[3]));
}
}
field.set(this, list);
continue;
}
switch (field.getType().getSimpleName().toLowerCase(Locale.US)) {
case "int":
field.set(this, Integer.parseInt(pp[1]));
break;
case "integer":
field.set(this, Integer.parseInt(pp[1]));
break;
case "string":
field.set(this, URLDecoder.decode(pp[1], "utf-8"));
break;
case "boolean":
field.set(this, Boolean.parseBoolean(pp[1]));
break;
case "long":
field.set(this, Long.parseLong(pp[1]));
break;
default:
throw new AssertionError();
}
}
}
}
catch (IllegalArgumentException | IllegalAccessException
| UnsupportedEncodingException ex) {
System.err.println(ex);
}
}
}
示例14: nullInstance
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private void nullInstance(Object instance) {
if (instance == null) {
return;
}
Field[] fields = instance.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
int mods = field.getModifiers();
if (field.getType().isPrimitive() || (field.getName().indexOf('$') != -1)) {
continue;
}
try {
field.setAccessible(true);
if (Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
// Doing something recursively is too risky
continue;
}
Object value = field.get(instance);
if (null != value) {
Class<? extends Object> valueClass = value.getClass();
if (!loadedByThisOrChild(valueClass)) {
if (log.isDebugEnabled()) {
log.debug("Not setting field " + field.getName() + " to null in object of class "
+ instance.getClass().getName() + " because the referenced object was of type "
+ valueClass.getName()
+ " which was not loaded by this web application class loader.");
}
} else {
field.set(instance, null);
if (log.isDebugEnabled()) {
log.debug("Set field " + field.getName() + " to null in class "
+ instance.getClass().getName());
}
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
if (log.isDebugEnabled()) {
log.debug("Could not set field " + field.getName() + " to null in object instance of class "
+ instance.getClass().getName(), t);
}
}
}
}
示例15: isPublicInstanceField
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static boolean isPublicInstanceField(Field field) {
return Modifier.isPublic(field.getModifiers())
&& !Modifier.isStatic(field.getModifiers())
&& !Modifier.isFinal(field.getModifiers())
&& !field.isSynthetic();
}