List of usage examples for java.lang.reflect Modifier VOLATILE
int VOLATILE
To view the source code for java.lang.reflect Modifier VOLATILE.
Click Source Link
From source file:Main.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("java.lang.String"); Constructor[] allConstructors = c.getDeclaredConstructors(); for (Constructor ctor : allConstructors) { int searchMod = Modifier.VOLATILE; int mods = accessModifiers(ctor.getModifiers()); if (searchMod == mods) { System.out.println(ctor); }//from www .j a v a 2 s . c o m } }
From source file:Main.java
private static int accessModifiers(int m) { return m & Modifier.VOLATILE; }
From source file:Spy.java
private static int modifierFromString(String s) { int m = 0x0;/*from w w w. j a v a 2 s . c o m*/ if ("public".equals(s)) m |= Modifier.PUBLIC; else if ("protected".equals(s)) m |= Modifier.PROTECTED; else if ("private".equals(s)) m |= Modifier.PRIVATE; else if ("static".equals(s)) m |= Modifier.STATIC; else if ("final".equals(s)) m |= Modifier.FINAL; else if ("transient".equals(s)) m |= Modifier.TRANSIENT; else if ("volatile".equals(s)) m |= Modifier.VOLATILE; return m; }
From source file:hu.bme.mit.sette.common.model.snippet.SnippetContainer.java
/** * Validates the fields of the class.//from w w w. j a va 2s . c o m * * @param validator * a validator */ private void validateFields(final AbstractValidator<?> validator) { // check: only constant ("public static final") or synthetic fields for (Field field : javaClass.getDeclaredFields()) { if (field.isSynthetic()) { // skip for synthetic fields (e.g. switch for enum generates // synthetic methods and fields) continue; } FieldValidator v = new FieldValidator(field); v.withModifiers(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL); v.withoutModifiers(Modifier.SYNCHRONIZED | Modifier.TRANSIENT | Modifier.VOLATILE); validator.addChildIfInvalid(v); } }
From source file:com.link_intersystems.lang.reflect.criteria.MemberCriteria.java
/** * Set the criterion that selects only {@link Member}s that exactly have the * specified modifiers. The access modifiers are set separately. Use * {@link #withAccess(AccessType...)} to set access modifiers. * * @param modifiers//from w w w .j a va 2s.c om * @since 1.0.0.0 */ public void withModifiers(int modifiers) { if (Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers) || Modifier.isPrivate(modifiers)) { throw new IllegalArgumentException( "access modifiers are not allowed as argument. Use withAccess() instead."); } int allowedModifiers = Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT | Modifier.VOLATILE | Modifier.SYNCHRONIZED | Modifier.NATIVE | Modifier.STRICT | Modifier.INTERFACE; if ((modifiers & allowedModifiers) == 0) { throw new IllegalArgumentException( "modifiers must be one of [" + Modifier.toString(allowedModifiers) + "]"); } this.modifiers = modifiers; }
From source file:net.redstoneore.legacyfactions.Factions.java
public GsonBuilder getGsonBuilder() { if (this.gsonBuilder == null) { Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>() { }.getType();// w ww . j a v a 2 s .c o m Type mapLocalityToStringSetType = new TypeToken<Map<Locality, Set<String>>>() { }.getType(); GsonBuilder builder = new GsonBuilder().setPrettyPrinting(); try { builder.setLenient(); } catch (NoSuchMethodError e) { // older minecraft plugins don't have this in their version of Gson } this.gsonBuilder = builder.disableHtmlEscaping() .excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE) .registerTypeAdapter(LazyLocation.class, new LazyLocationAdapter()) .registerTypeAdapter(mapFLocToStringSetType, new MapFlocationSetAdapter()) .registerTypeAdapter(mapLocalityToStringSetType, new MapLocalitySetAdapter()) .registerTypeAdapter(CrossColour.class, new CrossColourAdapter()) .registerTypeAdapter(CrossEntityType.class, new CrossEntityTypeAdapter()) ; } return this.gsonBuilder; }
From source file:com.industrieit.ohr.OHRJavassister.java
private static void setBaseMixinsPre(CtClass cc, boolean includeChecks) throws CannotCompileException, IOException, NotFoundException { //add fields/*from w ww . j ava 2 s . c o m*/ //add basePtr //CtField cf = new CtField(CtClass.longType, "crapField", cc); //cf.setModifiers(Modifier.PRIVATE | Modifier.VOLATILE); //cc.addField(cf); //add basePtr CtField f = new CtField(CtClass.longType, "basePtr", cc); f.setModifiers(Modifier.PRIVATE | Modifier.VOLATILE); cc.addField(f); //add instmarker CtField fm = new CtField(CtClass.intType, "instmarker", cc); fm.setModifiers(Modifier.PRIVATE | Modifier.VOLATILE); cc.addField(fm); CtClass cu = getDefault().get("sun.misc.Unsafe"); CtField f2 = new CtField(cu, "u", cc); f2.setModifiers(Modifier.STATIC | Modifier.PRIVATE); cc.addField(f2); //add check method String checkmeth = "public void doOHRCheck() { if (u.getInt(basePtr+4)!=instmarker) throw new com.industrieit.ohr.StaleHandleException(\"bad instmarker\"); }"; //PL.pl(checkmeth); CtMethod cm = CtNewMethod.make(checkmeth, cc); cc.addMethod(cm); String str = IOUtils.toString(OHRJavassister.class.getResourceAsStream("/ohr/base/basemethodspre.txt")); String checkplace = ""; if (includeChecks) { checkplace = "doOHRCheck();"; } //place in prechecks if desired str = str.replace("<<READCHECK>>", checkplace); str = str.replace("<<WRITECHECK>>", checkplace); StringTokenizer st = new StringTokenizer(str, "~~~"); while (st.hasMoreElements()) { String meth = st.nextToken(); //PL.pl("adding method: " + meth); CtMethod wmethod = CtNewMethod.make(meth, cc); cc.addMethod(wmethod); } }