當前位置: 首頁>>代碼示例>>Java>>正文


Java Field.getBoolean方法代碼示例

本文整理匯總了Java中java.lang.reflect.Field.getBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java Field.getBoolean方法的具體用法?Java Field.getBoolean怎麽用?Java Field.getBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.Field的用法示例。


在下文中一共展示了Field.getBoolean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.lang.reflect.Field; //導入方法依賴的package包/類
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");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:VMSupportsCS8.java

示例2: copyPrivateDataInto

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:AWTEvent.java

示例3: setDevEnvironment

import java.lang.reflect.Field; //導入方法依賴的package包/類
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.");
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:26,代碼來源:ExPetrum.java

示例4: xtestEnvironment

import java.lang.reflect.Field; //導入方法依賴的package包/類
@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);
}
 
開發者ID:Wangsu-Cloud-Storage,項目名稱:wcs-android-sdk,代碼行數:8,代碼來源:Validate.java

示例5: main

import java.lang.reflect.Field; //導入方法依賴的package包/類
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");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:NoNTLM.java

示例6: getBoolean

import java.lang.reflect.Field; //導入方法依賴的package包/類
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;
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:12,代碼來源:StorageUtils.java

示例7: serialize

import java.lang.reflect.Field; //導入方法依賴的package包/類
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);
   }
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:14,代碼來源:JavaSerializer.java

示例8: isJumping

import java.lang.reflect.Field; //導入方法依賴的package包/類
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;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:12,代碼來源:CustomGroundArmorstand.java

示例9: isJumping

import java.lang.reflect.Field; //導入方法依賴的package包/類
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;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:13,代碼來源:CustomGroundArmorstand.java

示例10: isJumping

import java.lang.reflect.Field; //導入方法依賴的package包/類
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;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:12,代碼來源:CustomGroundArmorstand.java

示例11: isJumping

import java.lang.reflect.Field; //導入方法依賴的package包/類
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;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:12,代碼來源:CustomGroundArmorstand.java

示例12: isJumping

import java.lang.reflect.Field; //導入方法依賴的package包/類
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;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:12,代碼來源:CustomGroundArmorstand.java

示例13: getActivity

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 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!");
}
 
開發者ID:ykarim,項目名稱:FTC2016,代碼行數:33,代碼來源:Util.java

示例14: getActivity

import java.lang.reflect.Field; //導入方法依賴的package包/類
@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;
}
 
開發者ID:dhbw-timetable,項目名稱:dhbw-timetable-android,代碼行數:29,代碼來源:ActivityHelper.java

示例15: getBoolean

import java.lang.reflect.Field; //導入方法依賴的package包/類
public static boolean getBoolean(Object instance, Field f)
{
    try {
        return f.getBoolean(instance);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:10,代碼來源:TypeAdapters.java


注:本文中的java.lang.reflect.Field.getBoolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。