当前位置: 首页>>代码示例>>Java>>正文


Java Modifier.isFinal方法代码示例

本文整理汇总了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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:ObjectStreamClass.java

示例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);
   }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:17,代码来源:ObjectReader.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TypesParser.java

示例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);
}
 
开发者ID:EixoX,项目名称:jetfuel,代码行数:15,代码来源:Aspect.java

示例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;
}
 
开发者ID:EixoX,项目名称:jetfuel,代码行数:16,代码来源:ListStorage.java

示例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;
}
 
开发者ID:24solar,项目名称:pay4j,代码行数:16,代码来源:ReflectionUtil.java

示例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);
		}
	}
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:11,代码来源:InjectionHandler.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:JavaAdapterFactory.java

示例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;
}
 
开发者ID:michaelliao,项目名称:crypto-exchange,代码行数:15,代码来源:EntityInfo.java

示例10: isOverridable

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@Override
public final boolean isOverridable() {
  return !(isFinal()
      || isPrivate()
      || isStatic()
      || Modifier.isFinal(getDeclaringClass().getModifiers()));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:Invokable.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:RuntimeModeler.java

示例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();
}
 
开发者ID:austinv11,项目名称:ETF-Java,代码行数:46,代码来源:ReflectionUtils.java

示例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);
        }

    }
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:64,代码来源:CmdParams.java

示例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);
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:45,代码来源:WebappClassLoaderBase.java

示例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();
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:7,代码来源:ReflectUtils.java


注:本文中的java.lang.reflect.Modifier.isFinal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。