Java Code Examples for java.lang.reflect.Field.getBoolean()

The following are Jave code examples for showing how to use getBoolean() of the java.lang.reflect.Field class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: VMSupportsCS8.java   View Source Code Vote up 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 2
Project: jdk8u-jdk   File: AWTEvent.java   View Source Code Vote up 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
Project: OpenJSharp   File: AWTEvent.java   View Source Code Vote up 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 4
Project: ExPetrum   File: ExPetrum.java   View Source Code Vote up 6 votes
private void setDevEnvironment()
{
	try
	{
		Class<CoreModManager> clazz = CoreModManager.class;
		Field f = clazz.getDeclaredField("deobfuscatedEnvironment");
		boolean accessibilityFlag = f.isAccessible();
		f.setAccessible(true);
		isDevEnvironment = f.getBoolean(null);
		f.setAccessible(accessibilityFlag);
		if (isDevEnvironment)
		{
			ExPMisc.modLogger.log(LogLevel.Fine, "ExPetrum has detected dev environment! Additional debug features enabled!");
			ExPMisc.modLogger.setLevel(LogLevel.Debug);
		}
		else
		{
			ExPMisc.modLogger.log(LogLevel.Fine, "ExPetrum has detected normal minecraft environment. No debug features enabled.");
		}
	}
	catch (Exception ex)
	{
		ExPMisc.modLogger.log(LogLevel.Warning, "ExPetrum was unable to determine the environment it is located in! Assuming normal minecraft instance.");
	}
}
 
Example 5
Project: wcs-android-sdk   File: Validate.java   View Source Code Vote up 5 votes
@Test
public void xtestEnvironment() throws NoSuchFieldException, IllegalAccessException, IllegalArgumentException {
    Field debuggingField = WCSLogUtil.class.getDeclaredField("DEBUGGING");
    debuggingField.setAccessible(true);
    boolean debugging = debuggingField.getBoolean(null);
    Assert.assertFalse(debugging);
}
 
Example 6
Project: openjdk-jdk10   File: NoNTLM.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws Exception {
    try {
        Class<?> ntlmProxyClass = Class.forName("sun.net.www.protocol.http.NTLMAuthenticationProxy", true, NoNTLM.class.getClassLoader());
        Field ntlmSupportedField = ntlmProxyClass.getDeclaredField("supported");
        ntlmSupportedField.setAccessible(true);
        if (ntlmSupportedField.getBoolean(null)) {
            System.out.println("NTLM is supported. Nothing to do. Exiting.");
            return;
        }
    } catch (ClassNotFoundException okay) { }

    // setup Authenticator
    Authenticator.setDefault(new Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication("user", "pass".toCharArray());
        }
    });

    // test combinations of authentication schemes
    test("Basic");
    test("Digest");
    test("Basic", "Digest");
    test("Basic", "NTLM");
    test("Digest", "NTLM");
    test("Basic", "Digest", "NTLM");

    // test NTLM only, this should fail with "401 Unauthorized"
    testNTLM();

    System.out.println();
    System.out.println("TEST PASSED");
}
 
Example 7
Project: FireFiles   File: StorageUtils.java   View Source Code Vote up 5 votes
private boolean getBoolean(Object object, String id) {
    boolean value = false;
    try {
        Field field = object.getClass().getDeclaredField(id);
        field.setAccessible(true);
        value = field.getBoolean(object);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return value;
}
 
Example 8
Project: jsf-sdk   File: JavaSerializer.java   View Source Code Vote up 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 9
Project: PetBlocks   File: CustomGroundArmorstand.java   View Source Code Vote up 5 votes
private boolean isJumping() {
    final Field jump;
    try {
        jump = EntityLiving.class.getDeclaredField("aW");
        jump.setAccessible(true);
        return jump.getBoolean(this.passenger);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e1) {
        PetBlocksPlugin.logger().log(Level.WARNING, "EntityNMS exception.", e1);
    }
    return false;
}
 
Example 10
Project: PetBlocks   File: CustomGroundArmorstand.java   View Source Code Vote up 5 votes
private boolean isJumping() {
    final Field jump;
    try {
        jump = EntityLiving.class.getDeclaredField("bc");
        jump.setAccessible(true);
        return !this.passengers.isEmpty() && jump.getBoolean(this.passengers.get(0));

    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e1) {
        PetBlocksPlugin.logger().log(Level.WARNING, "EntityNMS exception.", e1);
    }
    return false;
}
 
Example 11
Project: PetBlocks   File: CustomGroundArmorstand.java   View Source Code Vote up 5 votes
private boolean isJumping() {
    final Field jump;
    try {
        jump = EntityLiving.class.getDeclaredField("be");
        jump.setAccessible(true);
        return !this.passengers.isEmpty() && jump.getBoolean(this.passengers.get(0));
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e1) {
        PetBlocksPlugin.logger().log(Level.WARNING, "EntityNMS exception.", e1);
    }
    return false;
}
 
Example 12
Project: PetBlocks   File: CustomGroundArmorstand.java   View Source Code Vote up 5 votes
private boolean isJumping() {
    final Field jump;
    try {
        jump = EntityLiving.class.getDeclaredField("bd");
        jump.setAccessible(true);
        return !this.passengers.isEmpty() && jump.getBoolean(this.passengers.get(0));
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e1) {
        PetBlocksPlugin.logger().log(Level.WARNING, "EntityNMS exception.", e1);
    }
    return false;
}
 
Example 13
Project: dubbox-hystrix   File: JavaSerializer.java   View Source Code Vote up 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 14
Project: PetBlocks   File: CustomGroundArmorstand.java   View Source Code Vote up 5 votes
private boolean isJumping() {
    final Field jump;
    try {
        jump = EntityLiving.class.getDeclaredField("aY");
        jump.setAccessible(true);
        return jump.getBoolean(this.passenger);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e1) {
        PetBlocksPlugin.logger().log(Level.WARNING, "EntityNMS exception.", e1);
    }
    return false;
}
 
Example 15
Project: PetBlocks   File: CustomGroundArmorstand.java   View Source Code Vote up 5 votes
private boolean isJumping() {
    final Field jump;
    try {
        jump = EntityLiving.class.getDeclaredField("aY");
        jump.setAccessible(true);
        return jump.getBoolean(this.passenger);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e1) {
        PetBlocksPlugin.logger().log(Level.WARNING, "EntityNMS exception.", e1);
    }
    return false;
}
 
Example 16
Project: EatDubbo   File: JavaSerializer.java   View Source Code Vote up 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 17
Project: FTC2016   File: Util.java   View Source Code Vote up 5 votes
/**
 * Gets the primary activity without calling from an Activity class
 *
 * @return the main Activity
 */
@SuppressWarnings("unchecked")
@TargetApi(Build.VERSION_CODES.KITKAT)
public static Activity getActivity() {
    /*ActivityManager am = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE);
    ComponentName cn = am.getRunningTasks(1).get(0).topActivity;*/
    try {
        Class activityThreadClass = Class.forName("android.app.ActivityThread");
        Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
        Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
        activitiesField.setAccessible(true);
        ArrayMap activities = (ArrayMap) activitiesField.get(activityThread);
        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 (final java.lang.Throwable e) {
        // handle exception
        throw new IllegalArgumentException("No activity could be retrieved!");
    }
    throw new IllegalArgumentException("No activity could be found!");
}
 
Example 18
Project: simple-share-android   File: StorageUtils.java   View Source Code Vote up 5 votes
private boolean getBoolean(Object object, String id) {
    boolean value = false;
    try {
        Field field = object.getClass().getDeclaredField(id);
        field.setAccessible(true);
        value = field.getBoolean(object);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return value;
}
 
Example 19
Project: dhbw-timetable-android   File: ActivityHelper.java   View Source Code Vote up 5 votes
@SuppressWarnings("all")
public static Activity getActivity() {
    try {
        Class activityThreadClass = Class.forName("android.app.ActivityThread");
        Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
        Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
        activitiesField.setAccessible(true);

        Map<Object, Object> activities = (Map<Object, Object>) activitiesField.get(activityThread);
        if (activities == null)
            return null;

        for (Object activityRecord : activities.values()) {
            Class<? extends Object> activityRecordClass = activityRecord.getClass();
            Field breakField = activityRecordClass.getDeclaredField("paused");
            breakField.setAccessible(true);
            if (!breakField.getBoolean(activityRecord)) {
                Field activityField = activityRecordClass.getDeclaredField("activity");
                activityField.setAccessible(true);
                Activity activity = (Activity) activityField.get(activityRecord);
                return activity;
            }
        }
    } catch (Exception e) {
        Log.e("ERROR", "Cant get current activity :( " + e.getClass());
    }
    return null;
}
 
Example 20
Project: CustomWorldGen   File: TypeAdapters.java   View Source Code Vote up 5 votes
public static boolean getBoolean(Object instance, Field f)
{
    try {
        return f.getBoolean(instance);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}