本文整理匯總了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");
}
}
示例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;
}
示例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.");
}
}
示例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);
}
示例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");
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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!");
}
示例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;
}
示例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;
}