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


Java Modifier.isVolatile方法代码示例

本文整理汇总了Java中java.lang.reflect.Modifier.isVolatile方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.isVolatile方法的具体用法?Java Modifier.isVolatile怎么用?Java Modifier.isVolatile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.Modifier的用法示例。


在下文中一共展示了Modifier.isVolatile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public void write(Object object) throws IllegalArgumentException, IllegalAccessException {

		alreadyWritten.clear();
		alreadyWritten.put(object, object);

		Class<?> clazz = object.getClass();
		while (clazz != Object.class) {
			Field[] fields = clazz.getDeclaredFields();
			for (Field field : fields) {
				field.setAccessible(true);
				int modifiers = field.getModifiers();
				if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || Modifier.isVolatile(modifiers)) {
					// Skip
					continue;
				}
				if (field.isSynthetic()) {
					// Skip
					continue;
				}

				writeProperty(field.getName(), field.get(object));
			}

			clazz = clazz.getSuperclass();
		}
	}
 
开发者ID:Puppygames,项目名称:thjson,代码行数:27,代码来源:POJOtoTHJSONConverter.java

示例2: writeObject

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private void writeObject(String key, Object object) throws IllegalArgumentException, IllegalAccessException {
	if (alreadyWritten.containsKey(object)) {
		throw new IllegalArgumentException("Object " + object + " is already present in the stream");
	}
	alreadyWritten.put(object, object);

	writer.beginObject(key, object.getClass().getName());

	Class<?> clazz = object.getClass();
	while (clazz != Object.class) {
		Field[] fields = clazz.getDeclaredFields();
		for (Field field : fields) {
			field.setAccessible(true);

			int modifiers = field.getModifiers();
			if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || Modifier.isVolatile(modifiers)) {
				// Skip
				continue;
			}
			if (field.isSynthetic()) {
				// Skip
				continue;
			}

			writeProperty(field.getName(), field.get(object));
		}

		clazz = clazz.getSuperclass();
	}

	writer.endObject();
}
 
开发者ID:Puppygames,项目名称:thjson,代码行数:33,代码来源:POJOtoTHJSONConverter.java

示例3: CASUpdater

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
CASUpdater(final Class<T> tclass, final String fieldName,
           final Class<?> caller) {
    final Field field;
    final int modifiers;
    try {
        field = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Field>() {
                public Field run() throws NoSuchFieldException {
                    return tclass.getDeclaredField(fieldName);
                }
            });
        modifiers = field.getModifiers();
        sun.reflect.misc.ReflectUtil.ensureMemberAccess(
            caller, tclass, null, modifiers);
        ClassLoader cl = tclass.getClassLoader();
        ClassLoader ccl = caller.getClassLoader();
        if ((ccl != null) && (ccl != cl) &&
            ((cl == null) || !isAncestor(cl, ccl))) {
          sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
        }
    } catch (PrivilegedActionException pae) {
        throw new RuntimeException(pae.getException());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    Class<?> fieldt = field.getType();
    if (fieldt != long.class)
        throw new IllegalArgumentException("Must be long type");

    if (!Modifier.isVolatile(modifiers))
        throw new IllegalArgumentException("Must be volatile type");

    this.cclass = (Modifier.isProtected(modifiers) &&
                   caller != tclass) ? caller : null;
    this.tclass = tclass;
    offset = unsafe.objectFieldOffset(field);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:AtomicLongFieldUpdater.java

示例4: AtomicIntegerFieldUpdaterImpl

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
AtomicIntegerFieldUpdaterImpl(final Class<T> tclass,
                              final String fieldName,
                              final Class<?> caller) {
    final Field field;
    final int modifiers;
    try {
        field = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Field>() {
                public Field run() throws NoSuchFieldException {
                    return tclass.getDeclaredField(fieldName);
                }
            });
        modifiers = field.getModifiers();
        sun.reflect.misc.ReflectUtil.ensureMemberAccess(
            caller, tclass, null, modifiers);
        ClassLoader cl = tclass.getClassLoader();
        ClassLoader ccl = caller.getClassLoader();
        if ((ccl != null) && (ccl != cl) &&
            ((cl == null) || !isAncestor(cl, ccl))) {
          sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
        }
    } catch (PrivilegedActionException pae) {
        throw new RuntimeException(pae.getException());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    Class<?> fieldt = field.getType();
    if (fieldt != int.class)
        throw new IllegalArgumentException("Must be integer type");

    if (!Modifier.isVolatile(modifiers))
        throw new IllegalArgumentException("Must be volatile type");

    this.cclass = (Modifier.isProtected(modifiers) &&
                   caller != tclass) ? caller : null;
    this.tclass = tclass;
    offset = unsafe.objectFieldOffset(field);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:AtomicIntegerFieldUpdater.java

示例5: LockedUpdater

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
LockedUpdater(final Class<T> tclass, final String fieldName,
              final Class<?> caller) {
    final Field field;
    final int modifiers;
    try {
        field = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Field>() {
                public Field run() throws NoSuchFieldException {
                    return tclass.getDeclaredField(fieldName);
                }
            });
        modifiers = field.getModifiers();
        sun.reflect.misc.ReflectUtil.ensureMemberAccess(
            caller, tclass, null, modifiers);
        ClassLoader cl = tclass.getClassLoader();
        ClassLoader ccl = caller.getClassLoader();
        if ((ccl != null) && (ccl != cl) &&
            ((cl == null) || !isAncestor(cl, ccl))) {
            sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
        }
    } catch (PrivilegedActionException pae) {
        throw new RuntimeException(pae.getException());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    if (field.getType() != long.class)
        throw new IllegalArgumentException("Must be long type");

    if (!Modifier.isVolatile(modifiers))
        throw new IllegalArgumentException("Must be volatile type");

    // Access to protected field members is restricted to receivers only
    // of the accessing class, or one of its subclasses, and the
    // accessing class must in turn be a subclass (or package sibling)
    // of the protected member's defining class.
    // If the updater refers to a protected field of a declaring class
    // outside the current package, the receiver argument will be
    // narrowed to the type of the accessing class.
    this.cclass = (Modifier.isProtected(modifiers) &&
                   tclass.isAssignableFrom(caller) &&
                   !isSamePackage(tclass, caller))
                  ? caller : tclass;
    this.tclass = tclass;
    this.offset = U.objectFieldOffset(field);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:AtomicLongFieldUpdater.java

示例6: isAllModifiersContainSpecificModifier

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static boolean isAllModifiersContainSpecificModifier(int allModifiers, int specificModifier) {
    if (Modifier.isAbstract(allModifiers) && Modifier.isAbstract(specificModifier))
        return true;

    if (Modifier.isFinal(allModifiers) && Modifier.isFinal(specificModifier))
        return true;

    if (Modifier.isInterface(allModifiers) && Modifier.isInterface(specificModifier))
        return true;

    if (Modifier.isNative(allModifiers) && Modifier.isNative(specificModifier))
        return true;

    if (Modifier.isPrivate(allModifiers) && Modifier.isPrivate(specificModifier))
        return true;

    if (Modifier.isProtected(allModifiers) && Modifier.isProtected(specificModifier))
        return true;

    if (Modifier.isPublic(allModifiers) && Modifier.isPublic(specificModifier))
        return true;

    if (Modifier.isStatic(allModifiers) && Modifier.isStatic(specificModifier))
        return true;

    if (Modifier.isStrict(allModifiers) && Modifier.isStrict(specificModifier))
        return true;

    if (Modifier.isSynchronized(allModifiers) && Modifier.isSynchronized(specificModifier))
        return true;

    if (Modifier.isTransient(allModifiers) && Modifier.isTransient(specificModifier))
        return true;

    if (Modifier.isVolatile(allModifiers) && Modifier.isVolatile(specificModifier))
        return true;

    if (Modifier.isVolatile(allModifiers) && Modifier.isVolatile(specificModifier))
        return true;

    return false;
}
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:43,代码来源:Solution.java

示例7: isVolatile

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
 * Return true if this field is volatile
 */
public boolean isVolatile() {
    return Modifier.isVolatile(getModifiers());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:FieldDocImpl.java

示例8: copyStruct

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private void copyStruct(String struct, List<String> children) {
    final Struct owner = structsMap.get(struct);

    if (owner == null) {
        throw new IllegalArgumentException("Owner struct [" + struct + "] not defined for copy.");
    }

    for (int count = 0; count < children.size(); ++count) {
        final Struct child = structsMap.get(children.get(count));

        if (child == null) {
            throw new IllegalArgumentException("Child struct [" + children.get(count) + "]" +
                " not defined for copy to owner struct [" + owner.name + "].");
        }

        if (!child.clazz.isAssignableFrom(owner.clazz)) {
            throw new ClassCastException("Child struct [" + child.name + "]" +
                " is not a super type of owner struct [" + owner.name + "] in copy.");
        }

        for (Map.Entry<MethodKey,Method> kvPair : child.methods.entrySet()) {
            MethodKey methodKey = kvPair.getKey();
            Method method = kvPair.getValue();
            if (owner.methods.get(methodKey) == null) {
                // sanity check, look for missing covariant/generic override
                if (owner.clazz.isInterface() && child.clazz == Object.class) {
                    // ok
                } else if (child.clazz == Spliterator.OfPrimitive.class || child.clazz == PrimitiveIterator.class) {
                    // ok, we rely on generics erasure for these (its guaranteed in the javadocs though!!!!)
                } else if (Constants.JRE_IS_MINIMUM_JAVA9 && owner.clazz == LocalDate.class) {
                    // ok, java 9 added covariant override for LocalDate.getEra() to return IsoEra:
                    // https://bugs.openjdk.java.net/browse/JDK-8072746
                } else {
                    try {
                        // TODO: we *have* to remove all these public members and use getter methods to encapsulate!
                        final Class<?> impl;
                        final Class<?> arguments[];
                        if (method.augmentation) {
                            impl = Augmentation.class;
                            arguments = new Class<?>[method.arguments.size() + 1];
                            arguments[0] = method.owner.clazz;
                            for (int i = 0; i < method.arguments.size(); i++) {
                                arguments[i + 1] = method.arguments.get(i).clazz;
                            }
                        } else {
                            impl = owner.clazz;
                            arguments = new Class<?>[method.arguments.size()];
                            for (int i = 0; i < method.arguments.size(); i++) {
                                arguments[i] = method.arguments.get(i).clazz;
                            }
                        }
                        java.lang.reflect.Method m = impl.getMethod(method.method.getName(), arguments);
                        if (m.getReturnType() != method.rtn.clazz) {
                            throw new IllegalStateException("missing covariant override for: " + m + " in " + owner.name);
                        }
                        if (m.isBridge() && !Modifier.isVolatile(method.modifiers)) {
                            // its a bridge in the destination, but not in the source, but it might still be ok, check generics:
                            java.lang.reflect.Method source = child.clazz.getMethod(method.method.getName(), arguments);
                            if (!Arrays.equals(source.getGenericParameterTypes(), source.getParameterTypes())) {
                                throw new IllegalStateException("missing generic override for: " + m + " in " + owner.name);
                            }
                        }
                    } catch (ReflectiveOperationException e) {
                        throw new AssertionError(e);
                    }
                }
                owner.methods.put(methodKey, method);
            }
        }

        for (Field field : child.members.values()) {
            if (owner.members.get(field.name) == null) {
                owner.members.put(field.name,
                    new Field(field.name, field.javaName, owner, field.type, field.modifiers, field.getter, field.setter));
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:79,代码来源:Definition.java

示例9: isVolatile

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/** Utility method to query the modifier flags of this member. */
public boolean isVolatile() {
    return Modifier.isVolatile(flags);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MemberName.java

示例10: AtomicReferenceFieldUpdaterImpl

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
AtomicReferenceFieldUpdaterImpl(final Class<T> tclass,
                                final Class<V> vclass,
                                final String fieldName,
                                final Class<?> caller) {
    final Field field;
    final Class<?> fieldClass;
    final int modifiers;
    try {
        field = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Field>() {
                public Field run() throws NoSuchFieldException {
                    return tclass.getDeclaredField(fieldName);
                }
            });
        modifiers = field.getModifiers();
        sun.reflect.misc.ReflectUtil.ensureMemberAccess(
            caller, tclass, null, modifiers);
        ClassLoader cl = tclass.getClassLoader();
        ClassLoader ccl = caller.getClassLoader();
        if ((ccl != null) && (ccl != cl) &&
            ((cl == null) || !isAncestor(cl, ccl))) {
          sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
        }
        fieldClass = field.getType();
    } catch (PrivilegedActionException pae) {
        throw new RuntimeException(pae.getException());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    if (vclass != fieldClass)
        throw new ClassCastException();
    if (vclass.isPrimitive())
        throw new IllegalArgumentException("Must be reference type");

    if (!Modifier.isVolatile(modifiers))
        throw new IllegalArgumentException("Must be volatile type");

    this.cclass = (Modifier.isProtected(modifiers) &&
                   caller != tclass) ? caller : null;
    this.tclass = tclass;
    if (vclass == Object.class)
        this.vclass = null;
    else
        this.vclass = vclass;
    offset = unsafe.objectFieldOffset(field);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:AtomicReferenceFieldUpdater.java

示例11: isVolatile

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/** Returns true if the field is volatile. */
final boolean isVolatile() {
  return Modifier.isVolatile(getModifiers());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:5,代码来源:Element.java

示例12: isVolatile

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
 * Return true if the field includes the {@code volatile} modifier.
 */
public boolean isVolatile() {
    return Modifier.isVolatile(field.getModifiers());
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:7,代码来源:Field.java

示例13: AtomicIntegerFieldUpdaterImpl

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
AtomicIntegerFieldUpdaterImpl(final Class<T> tclass,
                              final String fieldName,
                              final Class<?> caller) {
    final Field field;
    final int modifiers;
    try {
        field = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Field>() {
                public Field run() throws NoSuchFieldException {
                    return tclass.getDeclaredField(fieldName);
                }
            });
        modifiers = field.getModifiers();
        sun.reflect.misc.ReflectUtil.ensureMemberAccess(
            caller, tclass, null, modifiers);
        ClassLoader cl = tclass.getClassLoader();
        ClassLoader ccl = caller.getClassLoader();
        if ((ccl != null) && (ccl != cl) &&
            ((cl == null) || !isAncestor(cl, ccl))) {
            sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
        }
    } catch (PrivilegedActionException pae) {
        throw new RuntimeException(pae.getException());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    if (field.getType() != int.class)
        throw new IllegalArgumentException("Must be integer type");

    if (!Modifier.isVolatile(modifiers))
        throw new IllegalArgumentException("Must be volatile type");

    // Access to protected field members is restricted to receivers only
    // of the accessing class, or one of its subclasses, and the
    // accessing class must in turn be a subclass (or package sibling)
    // of the protected member's defining class.
    // If the updater refers to a protected field of a declaring class
    // outside the current package, the receiver argument will be
    // narrowed to the type of the accessing class.
    this.cclass = (Modifier.isProtected(modifiers) &&
                   tclass.isAssignableFrom(caller) &&
                   !isSamePackage(tclass, caller))
                  ? caller : tclass;
    this.tclass = tclass;
    this.offset = U.objectFieldOffset(field);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:48,代码来源:AtomicIntegerFieldUpdater.java

示例14: CASUpdater

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
CASUpdater(final Class<T> tclass, final String fieldName,
           final Class<?> caller) {
    final Field field;
    final int modifiers;
    try {
        field = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Field>() {
                public Field run() throws NoSuchFieldException {
                    return tclass.getDeclaredField(fieldName);
                }
            });
        modifiers = field.getModifiers();
        sun.reflect.misc.ReflectUtil.ensureMemberAccess(
            caller, tclass, null, modifiers);
        ClassLoader cl = tclass.getClassLoader();
        ClassLoader ccl = caller.getClassLoader();
        if ((ccl != null) && (ccl != cl) &&
            ((cl == null) || !isAncestor(cl, ccl))) {
            sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
        }
    } catch (PrivilegedActionException pae) {
        throw new RuntimeException(pae.getException());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    if (field.getType() != long.class)
        throw new IllegalArgumentException("Must be long type");

    if (!Modifier.isVolatile(modifiers))
        throw new IllegalArgumentException("Must be volatile type");

    // Access to protected field members is restricted to receivers only
    // of the accessing class, or one of its subclasses, and the
    // accessing class must in turn be a subclass (or package sibling)
    // of the protected member's defining class.
    // If the updater refers to a protected field of a declaring class
    // outside the current package, the receiver argument will be
    // narrowed to the type of the accessing class.
    this.cclass = (Modifier.isProtected(modifiers) &&
                   tclass.isAssignableFrom(caller) &&
                   !isSamePackage(tclass, caller))
                  ? caller : tclass;
    this.tclass = tclass;
    this.offset = U.objectFieldOffset(field);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:47,代码来源:AtomicLongFieldUpdater.java

示例15: LockedUpdater

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
LockedUpdater(final Class<T> tclass, final String fieldName,
              final Class<?> caller) {
    Field field = null;
    int modifiers = 0;
    try {
        field = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Field>() {
                public Field run() throws NoSuchFieldException {
                    return tclass.getDeclaredField(fieldName);
                }
            });
        modifiers = field.getModifiers();
        sun.reflect.misc.ReflectUtil.ensureMemberAccess(
            caller, tclass, null, modifiers);
        ClassLoader cl = tclass.getClassLoader();
        ClassLoader ccl = caller.getClassLoader();
        if ((ccl != null) && (ccl != cl) &&
            ((cl == null) || !isAncestor(cl, ccl))) {
            sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
        }
    } catch (PrivilegedActionException pae) {
        throw new RuntimeException(pae.getException());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    if (field.getType() != long.class)
        throw new IllegalArgumentException("Must be long type");

    if (!Modifier.isVolatile(modifiers))
        throw new IllegalArgumentException("Must be volatile type");

    // Access to protected field members is restricted to receivers only
    // of the accessing class, or one of its subclasses, and the
    // accessing class must in turn be a subclass (or package sibling)
    // of the protected member's defining class.
    // If the updater refers to a protected field of a declaring class
    // outside the current package, the receiver argument will be
    // narrowed to the type of the accessing class.
    this.cclass = (Modifier.isProtected(modifiers) &&
                   tclass.isAssignableFrom(caller) &&
                   !isSamePackage(tclass, caller))
                  ? caller : tclass;
    this.tclass = tclass;
    this.offset = U.objectFieldOffset(field);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:47,代码来源:AtomicLongFieldUpdater.java


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