Java Code Examples for java.lang.reflect.Field#getBoolean()
The following examples show how to use
java.lang.reflect.Field#getBoolean() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ranger File: buildks.java License: Apache License 2.0 | 6 votes |
private static boolean isCredentialShellInteractiveEnabled() { boolean ret = false; String fieldName = "interactive"; CredentialShell cs = new CredentialShell(); try { Field interactiveField = cs.getClass().getDeclaredField(fieldName); if (interactiveField != null) { interactiveField.setAccessible(true); ret = interactiveField.getBoolean(cs); System.out.println("FOUND value of [" + fieldName + "] field in the Class [" + cs.getClass().getName() + "] = [" + ret + "]"); } } catch (Throwable e) { System.out.println("Unable to find the value of [" + fieldName + "] field in the Class [" + cs.getClass().getName() + "]. Skiping -f option"); e.printStackTrace(); ret = false; } return ret; }
Example 2
Source Project: jdk1.8-source-analysis File: AWTEvent.java License: Apache License 2.0 | 6 votes |
/** * Copies all private data from this event into that. * Space is allocated for the copied data that will be * freed when the that is finalized. Upon completion, * this event is not changed. */ void copyPrivateDataInto(AWTEvent that) { that.bdata = this.bdata; // Copy canAccessSystemClipboard value from this into that. if (this instanceof InputEvent && that instanceof InputEvent) { Field field = get_InputEvent_CanAccessSystemClipboard(); if (field != null) { try { boolean b = field.getBoolean(this); field.setBoolean(that, b); } catch(IllegalAccessException e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e); } } } } that.isSystemGenerated = this.isSystemGenerated; }
Example 3
Source Project: stash-token-auth File: PathMatcher.java License: GNU General Public License v3.0 | 6 votes |
private void init(Paths p) { Class cls = p.getClass(); try { for (Field f : cls.getDeclaredFields()) { Matches m = f.getAnnotation(Matches.class); if (m != null) { f.setAccessible(true); boolean allowed = f.getBoolean(p); for (String str : m.value()) { paths.put(Utils.createRegexFromGlob(str), new PathInfo(allowed, Pattern.compile(Utils.createRegexFromGlob(str)))); } } } } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
Example 4
Source Project: dragonwell8_jdk File: VMSupportsCS8.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (System.getProperty("sun.cpu.isalist").matches (".*\\b(sparcv9|pentium_pro|ia64|amd64).*") || System.getProperty("os.arch").matches (".*\\b(ia64|amd64).*")) { System.out.println("This system is known to have hardware CS8"); Class klass = Class.forName("java.util.concurrent.atomic.AtomicLong"); Field field = klass.getDeclaredField("VM_SUPPORTS_LONG_CAS"); field.setAccessible(true); boolean VMSupportsCS8 = field.getBoolean(null); if (! VMSupportsCS8) throw new Exception("Unexpected value for VMSupportsCS8"); } }
Example 5
Source Project: jdk-1.7-annotated File: AWTEvent.java License: Apache License 2.0 | 6 votes |
/** * Copies all private data from this event into that. * Space is allocated for the copied data that will be * freed when the that is finalized. Upon completion, * this event is not changed. */ void copyPrivateDataInto(AWTEvent that) { that.bdata = this.bdata; // Copy canAccessSystemClipboard value from this into that. if (this instanceof InputEvent && that instanceof InputEvent) { Field field = get_InputEvent_CanAccessSystemClipboard(); if (field != null) { try { boolean b = field.getBoolean(this); field.setBoolean(that, b); } catch(IllegalAccessException e) { if (log.isLoggable(PlatformLogger.FINE)) { log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e); } } } } that.isSystemGenerated = this.isSystemGenerated; }
Example 6
Source Project: TencentKona-8 File: VMSupportsCS8.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (System.getProperty("sun.cpu.isalist").matches (".*\\b(sparcv9|pentium_pro|ia64|amd64).*") || System.getProperty("os.arch").matches (".*\\b(ia64|amd64).*")) { System.out.println("This system is known to have hardware CS8"); Class klass = Class.forName("java.util.concurrent.atomic.AtomicLong"); Field field = klass.getDeclaredField("VM_SUPPORTS_LONG_CAS"); field.setAccessible(true); boolean VMSupportsCS8 = field.getBoolean(null); if (! VMSupportsCS8) throw new Exception("Unexpected value for VMSupportsCS8"); } }
Example 7
Source Project: jdk8u_jdk File: AWTEvent.java License: GNU General Public License v2.0 | 6 votes |
/** * Copies all private data from this event into that. * Space is allocated for the copied data that will be * freed when the that is finalized. Upon completion, * this event is not changed. */ void copyPrivateDataInto(AWTEvent that) { that.bdata = this.bdata; // Copy canAccessSystemClipboard value from this into that. if (this instanceof InputEvent && that instanceof InputEvent) { Field field = get_InputEvent_CanAccessSystemClipboard(); if (field != null) { try { boolean b = field.getBoolean(this); field.setBoolean(that, b); } catch(IllegalAccessException e) { if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e); } } } } that.isSystemGenerated = this.isSystemGenerated; }
Example 8
Source Project: DevUtils File: DevUtils.java License: Apache License 2.0 | 6 votes |
/** * 反射获取栈顶 Activity * @return {@link Activity} */ private Activity getTopActivityByReflect() { try { @SuppressLint("PrivateApi") Class<?> activityThreadClass = Class.forName("android.app.ActivityThread"); Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null); Field activitiesField = activityThreadClass.getDeclaredField("mActivityLists"); activitiesField.setAccessible(true); Map activities = (Map) activitiesField.get(activityThread); if (activities == null) return null; for (Object activityRecord : activities.values()) { Class activityRecordClass = activityRecord.getClass(); Field pausedField = activityRecordClass.getDeclaredField("paused"); pausedField.setAccessible(true); if (!pausedField.getBoolean(activityRecord)) { Field activityField = activityRecordClass.getDeclaredField("activity"); activityField.setAccessible(true); return (Activity) activityField.get(activityRecord); } } } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "getTopActivityByReflect"); } return null; }
Example 9
Source Project: Bats File: BoundsChecking.java License: Apache License 2.0 | 5 votes |
private static boolean getStaticBooleanField(Class cls, String name, boolean def) { try { Field field = cls.getDeclaredField(name); field.setAccessible(true); return field.getBoolean(null); } catch (ReflectiveOperationException e) { return def; } }
Example 10
Source Project: ignite File: ClusterStateXmlPropertiesTest.java License: Apache License 2.0 | 5 votes |
/** * Gets from given config {@code cfg} field with name {@code fieldName} and type boolean. * * @param cfg Config. * @param fieldName Name of field. * @return Value of field. */ private boolean getBooleanFieldFromConfig(IgniteConfiguration cfg, String fieldName) throws IllegalAccessException { A.notNull(cfg, "cfg"); A.notNull(fieldName, "fieldName"); Field field = U.findField(IgniteConfiguration.class, fieldName); field.setAccessible(true); return field.getBoolean(cfg); }
Example 11
Source Project: openjdk-jdk9 File: UseCodebaseOnlyDefault.java License: GNU General Public License v2.0 | 5 votes |
/** * Gets the actual useCodebaseOnly value by creating an instance * of MarshalInputStream and reflecting on the useCodebaseOnly field. */ static boolean getActualValue() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject("foo"); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); MarshalInputStream mis = new MarshalInputStream(bais); Field f = MarshalInputStream.class.getDeclaredField("useCodebaseOnly"); f.setAccessible(true); return f.getBoolean(mis); }
Example 12
Source Project: hottub File: UseCodebaseOnlyDefault.java License: GNU General Public License v2.0 | 5 votes |
/** * Gets the actual useCodebaseOnly value by creating an instance * of MarshalInputStream and reflecting on the useCodebaseOnly field. */ static boolean getActualValue() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject("foo"); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); MarshalInputStream mis = new MarshalInputStream(bais); Field f = MarshalInputStream.class.getDeclaredField("useCodebaseOnly"); f.setAccessible(true); return f.getBoolean(mis); }
Example 13
Source Project: dubbo-hessian-lite File: JavaSerializer.java License: Apache License 2.0 | 5 votes |
@Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { boolean value = false; try { value = field.getBoolean(obj); } catch (IllegalAccessException e) { log.log(Level.FINE, e.toString(), e); } out.writeBoolean(value); }
Example 14
Source Project: joyrpc File: JavaSerializer.java License: Apache License 2.0 | 5 votes |
void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { boolean value = false; try { value = field.getBoolean(obj); } catch (IllegalAccessException e) { log.log(Level.FINE, e.toString(), e); } out.writeBoolean(value); }
Example 15
Source Project: AndroidUtilCode File: UtilsActivityLifecycleImpl.java License: Apache License 2.0 | 5 votes |
/** * @return the activities which topActivity is first position */ private List<Activity> getActivitiesByReflect() { LinkedList<Activity> list = new LinkedList<>(); Activity topActivity = null; try { Object activityThread = getActivityThread(); Field mActivitiesField = activityThread.getClass().getDeclaredField("mActivities"); mActivitiesField.setAccessible(true); Object mActivities = mActivitiesField.get(activityThread); if (!(mActivities instanceof Map)) { return list; } Map<Object, Object> binder_activityClientRecord_map = (Map<Object, Object>) mActivities; for (Object activityRecord : binder_activityClientRecord_map.values()) { Class activityClientRecordClass = activityRecord.getClass(); Field activityField = activityClientRecordClass.getDeclaredField("activity"); activityField.setAccessible(true); Activity activity = (Activity) activityField.get(activityRecord); if (topActivity == null) { Field pausedField = activityClientRecordClass.getDeclaredField("paused"); pausedField.setAccessible(true); if (!pausedField.getBoolean(activityRecord)) { topActivity = activity; } else { list.add(activity); } } else { list.add(activity); } } } catch (Exception e) { Log.e("UtilsActivityLifecycle", "getActivitiesByReflect: " + e.getMessage()); } if (topActivity != null) { list.addFirst(topActivity); } return list; }
Example 16
Source Project: jdk8u60 File: UseCodebaseOnlyDefault.java License: GNU General Public License v2.0 | 5 votes |
/** * Gets the actual useCodebaseOnly value by creating an instance * of MarshalInputStream and reflecting on the useCodebaseOnly field. */ static boolean getActualValue() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject("foo"); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); MarshalInputStream mis = new MarshalInputStream(bais); Field f = MarshalInputStream.class.getDeclaredField("useCodebaseOnly"); f.setAccessible(true); return f.getBoolean(mis); }
Example 17
Source Project: netbeans File: NavigatorHandlerTest.java License: Apache License 2.0 | 5 votes |
private void waitForProviders(NavigatorTC navTC) throws NoSuchFieldException, SecurityException, InterruptedException, IllegalArgumentException, IllegalAccessException { Field field = NavigatorController.class.getDeclaredField("inUpdate"); field.setAccessible(true); while (field.getBoolean(navTC.getController())) { Thread.sleep(100); } }
Example 18
Source Project: openjdk-jdk8u File: UseCodebaseOnlyDefault.java License: GNU General Public License v2.0 | 5 votes |
/** * Gets the actual useCodebaseOnly value by creating an instance * of MarshalInputStream and reflecting on the useCodebaseOnly field. */ static boolean getActualValue() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject("foo"); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); MarshalInputStream mis = new MarshalInputStream(bais); Field f = MarshalInputStream.class.getDeclaredField("useCodebaseOnly"); f.setAccessible(true); return f.getBoolean(mis); }
Example 19
Source Project: Hyperium File: MotionBlurMod.java License: GNU Lesser General Public License v3.0 | 5 votes |
static boolean isFastRenderEnabled() { try { Field fastRender = GameSettings.class.getDeclaredField("ofFastRender"); return fastRender.getBoolean(Minecraft.getMinecraft().gameSettings); } catch (Exception var1) { return false; } }
Example 20
Source Project: julongchain File: SM2X509CertImpl.java License: Apache License 2.0 | 5 votes |
private boolean isReadOnly() { try { Field field = X509CertImpl.class.getDeclaredField("readOnly"); field.setAccessible(true); return field.getBoolean(this); } catch (Exception e) { log.warn("reflect get field readOnly failed: {}", e); } return true; }