public void set(Object obj, boolean value) { try { this.field.setBoolean(obj, value); } catch (Exception e) { //Ignore } } }
try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ignored) { }
private void makeActionOverflowMenuShown() { //devices with hardware menu button (e.g. Samsung Note) don't show action overflow menu try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { Log.d(TAG, e.getLocalizedMessage()); } }
public static boolean callSetBoolean(Field thiz, Object obj) throws IllegalArgumentException, IllegalAccessException { thiz.setBoolean(obj, true); return thiz.getBoolean(obj); }
public void setIntZ() throws Exception { f_z.setAccessible(true); f_z.setBoolean(t, false); }
try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { // presumably, not relevant }
public static boolean callSetAndGetBoolean(Field thiz, Object obj) throws IllegalArgumentException, IllegalAccessException { thiz.setBoolean(obj, !thiz.getBoolean(obj)); return thiz.getBoolean(obj); }
public final void setBooleanValue(Object newObj, boolean i1) throws IllegalAccessException { if (!isAndroid && memOffset >= 0) { FSTUtil.unFlaggedUnsafe.putBoolean(newObj, memOffset, i1); return; } field.setBoolean(newObj, i1); }
private void getOverflowMenu() { try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if(menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { e.printStackTrace(); } }
private void setField(String fieldName, boolean value) { try { Field f = FilterCommandLine.class.getField(fieldName); f.setBoolean(this, value); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
private static void disablePrimitiveOptimization(Object self) { Field sdyn; Class c = self.getClass(); try { sdyn = c.getDeclaredField(Verifier.STATIC_METACLASS_BOOL); sdyn.setBoolean(null, true); } catch (Throwable e) { //DO NOTHING } }
@VisibleForTesting static void resetRocksDBLoadedFlag() throws Exception { final Field initField = org.rocksdb.NativeLibraryLoader.class.getDeclaredField("initialized"); initField.setAccessible(true); initField.setBoolean(null, false); } }
private static void setMiUI_International(boolean flag) { try { Class BuildForMi = Class.forName("miui.os.Build"); Field isInternational = BuildForMi.getDeclaredField("IS_INTERNATIONAL_BUILD"); isInternational.setAccessible(true); isInternational.setBoolean(null, flag); } catch (Exception e) { e.printStackTrace(); } }
public static void setFieldValue(String name, Object instance, boolean value, Class cl) { try { getReflectField(name, instance, cl).setBoolean(instance, value); } catch (Exception e) { e.printStackTrace(); if (isThrowable) { throw new RuntimeException("setFieldValue boolean error " + name + " target " + instance + " value " + value); } } }
public static void setStaticFieldValue(String name, Class clazz, boolean value) { try { getReflectStaticField(name, clazz).setBoolean(null, value); } catch (Exception e) { e.printStackTrace(); if (isThrowable) { throw new RuntimeException("setStaticFieldValue boolean error " + name + " Class " + clazz + " value " + value); } } }
@Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { boolean value = false; try { value = in.readBoolean(); _field.setBoolean(obj, value); } catch (Exception e) { logDeserializeError(_field, obj, value, e); } } }
/** * Prevent the client from automatically reconnecting if the connection to the * server is lost */ public void dontReconnect() throws Exception { java.lang.reflect.Field f = cnxn.getClass().getDeclaredField("closing"); f.setAccessible(true); f.setBoolean(cnxn, true); } }
private void setSaslFailureFlag(ZooKeeper zk) throws Exception { Field cnxnField = zk.getClass().getDeclaredField("cnxn"); cnxnField.setAccessible(true); ClientCnxn clientCnxn = (ClientCnxn) cnxnField.get(zk); Field sendThreadField = clientCnxn.getClass().getDeclaredField("sendThread"); sendThreadField.setAccessible(true); SendThread sendThread = (SendThread) sendThreadField.get(clientCnxn); Field saslLoginFailedField = sendThread.getClass().getDeclaredField("saslLoginFailed"); saslLoginFailedField.setAccessible(true); saslLoginFailedField.setBoolean(sendThread, true); }
public DatePatternConverterTest(final Boolean threadLocalEnabled) throws Exception { // Setting the system property does not work: the Constant field has already been initialized... //System.setProperty("log4j2.enable.threadlocals", threadLocalEnabled.toString()); final Field field = Constants.class.getDeclaredField("ENABLE_THREADLOCALS"); field.setAccessible(true); // make non-private final Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); // make non-final field.setBoolean(null, threadLocalEnabled.booleanValue()); }
@BeforeClass public static void classSetup() throws Exception { try { Field f = RandomIntProvider.class.getDeclaredField("useBtraceEnter"); f.setAccessible(true); f.setBoolean(null, false); } catch (Exception e) { e.printStackTrace(); } }