以下是一些示例代码来说明我们的问题:
A a = null;
try {
a = new A();
a = doSomethingThatWillThrowAnException();
} finally {
System.out.println("A = " + a);
}
Run Code Online (Sandbox Code Playgroud)
问题是,finally块中打印的“ a”的值是什么?
我不确定,我想我偶然发现了一些可能无法完全描述的东西。我在笔记本电脑(x86上为jdk1.6.0.16)上观察到“ a”等于A()。但是,对于Solaris上的JDK 1.4,我认为该值为null(就像即使抛出异常也会执行分配一样)。显然,这与错误有关,我们将部署一个没有分配的版本,只是为了确保,但是我们想知道你们中的一个人是否也注意到了这一点,或者提出了某种解释。
我们还将做的是编写一个示例程序,以在有问题的JDK上对此进行演示……然后我们将发布结果。
我安装了IBM的J9 VM(build 2.3,J2RE 1.5.0 IBM J9 2.3).获得OOM后,堆转储的大小为383MB.JVM有多少堆?
我问的原因是400MB堆转储似乎对我预期的默认64MB堆有点多,但我没有指定任何-Xm选项.J9是否使用不同的默认堆大小?如果是这样,我怎么知道它是什么?
我有一个像这样的分区表:
create table demo (
ID NUMBER(22) not null,
TS TIMESTAMP not null,
KEY VARCHAR2(5) not null,
...lots more columns...
)
Run Code Online (Sandbox Code Playgroud)
分区位于TS列上(每年一个分区).
由于我通过时间戳搜索了很多,我创建了一个组合索引:
create index demo.x1 on demo (ts, key);
Run Code Online (Sandbox Code Playgroud)
查询如下所示:
select *
from demo t
where t.TS = to_timestamp('2009-06-30 07:47:57', 'YYYY-MM-DD HH24:MI:SS')
Run Code Online (Sandbox Code Playgroud)
我也尝试添加,and t.KEY = '00101'但这没有帮助.
但是EXPLAIN PLAN说TABLE ACCESS和FULL:
# Operation Options Object Mode Cost Bytes Cardinality
0 SELECT STATEMENT ALL_ROWS 583804 287145 2127
1 PARTITION RANGE ALL 583804 …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个很好的模板引擎或一小段代码来在Java中的字符串中扩展类似Ant的变量.例:
String result = expand ("${firstName} ${familyName}", map);
Run Code Online (Sandbox Code Playgroud)
它至少应该支持,java.util.Map但是也可以使用能够处理bean或递归查找或查找地图/对象列表的东西.
建议?
[编辑]回复TofuBeer:没有嵌套,只有有效的Java标识符{}.除了之外的任何内容都${}应该逐字复制.$$应该成为$``. If that's not possible ${dollar}应该扩展到单一$(所以你可以表达15.00 $).
从1到10的等级,从安全编程实践的角度来看,以下有多糟糕?如果你发现它比五更糟糕,你会做什么呢?
下面我的目标是获得的地图列表中的数据在B插入A.在这种情况下,对我来说,这是确定的,如果它要么是一个数据的副本或原始数据的参考.我发现这种方法最快,但我对此感到不安.
public class A {
private List<Map<String, String>> _list = null;
public A(B b) {
_list = b.getList();
}
}
public class B {
private List<Map<String, String>> _list = new ArrayList<Map<String, String>>();
public List<Map<String, String>> getList() {
// Put some data in _list just for the sake of this example...
_list.add(new HashMap<String, String>());
return _list;
}
}
Run Code Online (Sandbox Code Playgroud) 如何使该单元测试在所有时区都通过,与DST是否处于活动状态无关?
import static org.junit.Assert.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.joda.time.DateTime;
import org.junit.Test;
public class TimeZoneTest {
private final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( "yyyy.MM.dd'T'HH:mm.ss:SSSZZ" );
@Test
public void testUtilDateMillis() throws Exception {
assertEquals( "1970.01.01T00:00.00:000+0000", DATE_FORMAT.format( new Date( 0L ) ) );
}
@Test
public void testDateTimeMillis() throws Exception {
assertEquals( "1970-01-01T00:00:00.000+00:00", new DateTime( 0L ).toString() );
}
}
Run Code Online (Sandbox Code Playgroud) 我试图在Linux中编写一个非常简单的脚本.
我先告诉你代码:
#!/bin/bash
# The shell program uses glob constructs and ls
# to list all entries in testfiles, that have 2
# or more dots "." in their name.
ls -l /path/to/file/*.*.*
Run Code Online (Sandbox Code Playgroud)
当我使用bash myscript命令运行此代码时,我得到类似:/ path/to/file/file.with.three.dots
但我不想要这个.我只想显示文件名,而不是路径.
然后我尝试了:
ls -l *.*.*
Run Code Online (Sandbox Code Playgroud)
但是这次只显示我在/ path/to/file /中的文件.
如何设置路径,所以当从任何地方运行脚本时,它会将/ path /中的文件名输出到/ file /?
谢谢!
我相信很多人都注意到,当你有一个大型应用程序(即需要几MB的DLL)时,它第二次加载的速度比第一次快得多.如果您在应用程序中读取大文件,也会发生同样的情况.第一次播放后它的读取速度要快得多.
这有什么影响?我想这是硬盘驱动器缓存,或者操作系统增加了一些自己的内存缓存.
您使用什么技术来加速大型应用程序和文件的加载时间?
提前致谢
注意:问题涉及Windows
补充:影响操作系统缓存大小的因素是什么?在某些应用程序中,文件在一分钟左右后再次缓慢加载,因此缓存填写一分钟?
这是一个非常好的例子,说明了如何使用graphviz生成复杂的图形.此处列出了点文件.
digraph G {
compound=true;
ranksep=1.25;
label="From Past to Future...";
node [shape=plaintext, fontsize=16];
bgcolor=white;
edge [arrowsize=1, color=black];
/* Nodes */
subgraph cluster_Computers {label="Computers"; labelloc="b"; Computers_icon};
Computers_icon [label="", shape=box, style=invis, shapefile="Computers.png"];
subgraph cluster_Semantic_Web {label="Semantic Web"; labelloc="b"; Semantic_Web_icon};
Semantic_Web_icon [label="", shape=box, style=invis, shapefile="Semantic_Web.png"];
subgraph cluster_Cryptography {label="Cryptography"; labelloc="b"; Cryptography_icon};
Cryptography_icon [label="", shape=box, style=invis, shapefile="Cryptography.png"];
subgraph cluster_Automata {label="Automata"; labelloc="b"; Automata_icon};
Automata_icon [label="", shape=box, style=invis, shapefile="Automata.png"];
subgraph cluster_AI {label="A.I."; labelloc="b"; AI_icon};
AI_icon [label="", shape=box, style=invis, shapefile="AI.png"];
subgraph cluster_Chaos {label="Chaos / Fractals"; labelloc="b"; Chaos_icon};
Chaos_icon …Run Code Online (Sandbox Code Playgroud) 这行代码给出了弃用警告:
mapper.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
Run Code Online (Sandbox Code Playgroud)
这不能编译
mapper.configure(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS, true);
Run Code Online (Sandbox Code Playgroud)
因为JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS这四种Feature类型中任何一种的子类都不ObjectMapper支持。
在 Jackson 2.12 中启用此功能的正确做法是什么?