List of usage examples for java.lang.reflect Modifier isVolatile
public static boolean isVolatile(int mod)
From source file:Main.java
public static void main(String[] args) throws Exception { Class<?> clazz = String.class; int modifier = clazz.getModifiers(); if (Modifier.isVolatile(modifier)) { System.out.println("isVolatile"); }// ww w . j a v a2s . c o m }
From source file:DeclarationInfoDemo.java
public static void printModifiers(final Class dataType) { final int modifiers = dataType.getModifiers(); if (Modifier.isPrivate(modifiers)) { System.out.print("private "); }/* ww w. ja v a 2s. co m*/ if (Modifier.isPrivate(modifiers)) { System.out.print("private "); } if (Modifier.isPublic(modifiers)) { System.out.print("private "); } if (Modifier.isAbstract(modifiers)) { System.out.print("abstract "); } if (Modifier.isFinal(modifiers)) { System.out.print("final "); } if (Modifier.isNative(modifiers)) { System.out.print("native "); } if (Modifier.isInterface(modifiers)) { System.out.print("interface "); } if (Modifier.isStatic(modifiers)) { System.out.print("static "); } if (Modifier.isStrict(modifiers)) { System.out.print("strict "); } if (Modifier.isSynchronized(modifiers)) { System.out.print("synchronized "); } if (Modifier.isTransient(modifiers)) { System.out.print("transient "); } if (Modifier.isVolatile(modifiers)) { System.out.print("volatile "); } System.out.println(dataType.getName()); }
From source file:ModifierUtil.java
public static boolean isVolatile(Member member) { return Modifier.isVolatile(member.getModifiers()); }
From source file:com.happyblueduck.lembas.datastore.LembasEntity.java
/** * copies values from lembasEntity to this entity. skip objectKey from that. * @param that/* w ww . j ava2s . co m*/ */ public void copy(LembasEntity that) { ArrayList<Field> fields = Lists.newArrayList(that.getClass().getFields()); for (Field f : fields) { try { int modifiers = f.getModifiers(); if (Modifier.isPrivate(modifiers)) continue; if (Modifier.isStatic(modifiers)) continue; if (Modifier.isTransient(modifiers)) continue; if (Modifier.isFinal(modifiers)) continue; if (Modifier.isVolatile(modifiers)) continue; if (f.getName().equalsIgnoreCase(LembasUtil.objectKey)) continue; Object value = f.get(that); if (value != null) this.setField(f, value); } catch (IllegalAccessException exception) { exception.printStackTrace(); } } }
From source file:objenome.util.bytecode.SgUtils.java
private static void checkModifiers(int type, int modifiers) { for (int modifier = ABSTRACT; modifier <= STRICTFP; modifier++) { if (Modifier.isPrivate(modifiers) && !MODIFIERS_MATRIX[PRIVATE][type]) { throwIllegalArgument(type, PRIVATE); }/*ww w .j a v a 2 s. c om*/ if (Modifier.isProtected(modifiers) && !MODIFIERS_MATRIX[PROTECTED][type]) { throwIllegalArgument(type, PROTECTED); } if (Modifier.isPublic(modifiers) && !MODIFIERS_MATRIX[PUBLIC][type]) { throwIllegalArgument(type, PUBLIC); } if (Modifier.isStatic(modifiers) && !MODIFIERS_MATRIX[STATIC][type]) { throwIllegalArgument(type, STATIC); } if (Modifier.isAbstract(modifiers) && !MODIFIERS_MATRIX[ABSTRACT][type]) { throwIllegalArgument(type, ABSTRACT); } if (Modifier.isFinal(modifiers) && !MODIFIERS_MATRIX[FINAL][type]) { throwIllegalArgument(type, FINAL); } if (Modifier.isNative(modifiers) && !MODIFIERS_MATRIX[NATIVE][type]) { throwIllegalArgument(type, NATIVE); } if (Modifier.isSynchronized(modifiers) && !MODIFIERS_MATRIX[SYNCHRONIZED][type]) { throwIllegalArgument(type, SYNCHRONIZED); } if (Modifier.isTransient(modifiers) && !MODIFIERS_MATRIX[TRANSIENT][type]) { throwIllegalArgument(type, TRANSIENT); } if (Modifier.isVolatile(modifiers) && !MODIFIERS_MATRIX[VOLATILE][type]) { throwIllegalArgument(type, VOLATILE); } if (Modifier.isStrict(modifiers) && !MODIFIERS_MATRIX[STRICTFP][type]) { throwIllegalArgument(type, STRICTFP); } } }
From source file:org.forgerock.openam.cts.utils.blob.strategies.AttributeCompressionStrategy.java
/** * Examines the class using reflection for all declared fields which are suitable * for serialisation./* ww w .j a v a2 s . c o m*/ * * @param c Non null class to examine. * * @return A non null but possibly empty collection of Fields. */ public static Collection<Field> getAllValidFields(Class c) { List<Field> r = new ArrayList<Field>(); for (Field f : c.getDeclaredFields()) { int modifiers = f.getModifiers(); if (Modifier.isStatic(modifiers)) continue; if (Modifier.isVolatile(modifiers)) continue; if (Modifier.isTransient(modifiers)) continue; r.add(f); } return r; }
From source file:objenome.util.bytecode.SgUtils.java
/** * Checks if the modifiers are valid for a field. If any of the modifiers is * not valid an <code>IllegalArgumentException</code> is thrown. * // w ww .j av a 2s . co m * @param modifiers * Modifiers. */ public static void checkFieldModifiers(int modifiers) { // Basic checks checkModifiers(FIELD, modifiers); // Check final and volatile if (Modifier.isFinal(modifiers) && Modifier.isVolatile(modifiers)) { throw new IllegalArgumentException( FIELD_FINAL_VOLATILE_ERROR + " [" + Modifier.toString(modifiers) + ']'); } }
From source file:org.lmn.fc.common.utilities.pending.Utilities.java
/*********************************************************************************************** * Show the Member Modifiers.// w w w . j a va 2s. c om * * @param member * * @return String */ public static String showModifiers(final Member member) { final int modifiers; final StringBuffer buffer; buffer = new StringBuffer(); if (member != null) { modifiers = member.getModifiers(); if (Modifier.isAbstract(modifiers)) { buffer.append("Abstract "); } if (Modifier.isFinal(modifiers)) { buffer.append("Final "); } if (Modifier.isInterface(modifiers)) { buffer.append("Interface "); } if (Modifier.isNative(modifiers)) { buffer.append("Native "); } if (Modifier.isPrivate(modifiers)) { buffer.append("Private "); } if (Modifier.isProtected(modifiers)) { buffer.append("Protected "); } if (Modifier.isPublic(modifiers)) { buffer.append("Public "); } if (Modifier.isStatic(modifiers)) { buffer.append("Static "); } if (Modifier.isStrict(modifiers)) { buffer.append("Strict "); } if (Modifier.isSynchronized(modifiers)) { buffer.append("Synchronized "); } if (Modifier.isTransient(modifiers)) { buffer.append("Transient "); } if (Modifier.isVolatile(modifiers)) { buffer.append("Volatile "); } } return (buffer.toString().trim()); }
From source file:com.judoscript.jamaica.parser.JamaicaDumpVisitor.java
static void printAccessFlags(int flags) { if (Modifier.isPublic(flags)) out.print("public "); else if (Modifier.isProtected(flags)) out.print("protected "); else if (Modifier.isPrivate(flags)) out.print("private "); if (Modifier.isAbstract(flags)) out.print("abstract "); if (Modifier.isFinal(flags)) out.print("final "); if (Modifier.isNative(flags)) out.print("native "); if (Modifier.isStatic(flags)) out.print("static "); if (Modifier.isStrict(flags)) out.print("strict "); if (Modifier.isSynchronized(flags)) out.print("synchronized "); if (Modifier.isTransient(flags)) out.print("transient "); if (Modifier.isVolatile(flags)) out.print("volative "); }
From source file:name.yumaa.ChromeLogger4J.java
/** * Returns a nicely formatted key of the field or method name * @param mod .getModifiers()/*from ww w .j ava 2 s .co m*/ * @param end key ending * @return class member keys, converted to string */ private String getKey(int mod, String end) { StringBuilder key = new StringBuilder(""); if (Modifier.isPublic(mod)) key.append("public "); if (Modifier.isPrivate(mod)) key.append("private "); if (Modifier.isProtected(mod)) key.append("protected "); if (Modifier.isStatic(mod)) key.append("static "); if (Modifier.isTransient(mod)) key.append("transient "); if (Modifier.isVolatile(mod)) key.append("volatile "); if (Modifier.isFinal(mod)) key.append("final "); if (Modifier.isSynchronized(mod)) key.append("synchronized "); return key.append(end).toString(); }