我有这个代码(暂时搁置它的适当性):
Class<?> cacheClass = Class.forName("java.lang.Integer$IntegerCache");
Field cacheField = cacheClass.getDeclaredField("cache");
cacheField.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(cacheField, cacheField.getModifiers() & ~Modifier.FINAL);
Integer betterCache[] = new Integer[255];
for (int i = 0; i < betterCache.length; i++) {
betterCache[i] = 20;
}
cacheField.set(null, betterCache);
System.out.println(10);
System.out.println((Integer) 10);
Run Code Online (Sandbox Code Playgroud)
我希望第二个println打印20,因为我Integers用20 替换缓存.当我在Eclipse中调试程序它按预期执行时,它从缓存中获取值并打印20,而在我运行它时它在两种情况下打印10从IDE或通过调用java.如何解释这种行为?
UPD:如果使用1.8 javac编译,它会以这种方式工作.如果使用1.6版本编译,则打印10和20.
让我们有变量
char *s;
我知道如果它在全局范围内声明,它的值应为0;
如果它在本地范围内声明,则其值未定义(尽管可能为0).
我在测试中有一个问题听起来像'定义为指针的值是什么
char* s
Run Code Online (Sandbox Code Playgroud)
a)null
b)空字符串
c)未定义
我真的很困惑我应该选择什么答案,因为如果它在全局范围内声明,那么该值将为null(我猜).如果它在本地范围内声明,未定义(虽然当我尝试它为零时),当我尝试cout它时,没有打印任何内容(没有分段错误,为什么?),这意味着它是一个空字符串(或者是cout那么棒?).
请参阅NFC阅读器"SELECT(通过AID)"APDU未在调试和最终结果时路由到Android设备.TL; DR读者可能只是已经不复存在了.
我有ACR122U nfc阅读器.我尝试在我的Ubuntu机器上运行此示例http://www.nfc-tools.org/index.php?title=Libnfc:APDU_example#apdu_example.c.
这是我点击Android设备(应该处于HCE模式)时读取的日志输出:
./apdu_example
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to true
debug libnfc.general allow_intrusive_scan is set to false
debug libnfc.general 0 device(s) defined by user
./apdu_example uses libnfc libnfc-1.7.1
debug libnfc.driver.acr122_usb device found: Bus 001 Device 088 Name ACS ACR122
debug libnfc.general 1 device(s) found using acr122_usb driver
debug libnfc.driver.acr122_usb 3 element(s) have been decoded from "acr122_usb:001:088"
debug libnfc.driver.acr122_usb TX: 62 00 00 00 00 …Run Code Online (Sandbox Code Playgroud)