當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。