好的 - 我知道我可以像这样运行我的java进程:
java -XX:+PrintCompilation <FooProgram>
Run Code Online (Sandbox Code Playgroud)
我可以看到如下输出:
c:\>java -XX:+PrintCompilation -jar c:\FooProgram.jar
1 java.lang.String::charAt (33 bytes)
2 java.lang.Math::max (11 bytes)
1% java.util.jar.JarFile::hasClassPathAttribute @ 78 (197 bytes)
3 java.lang.String::hashCode (60 bytes)
4 java.lang.String::indexOf (151 bytes)
5 java.util.Properties$LineReader::readLine (452 bytes)
6 java.lang.Object::<init> (1 bytes)
7 java.lang.String::indexOf (166 bytes)
8 java.lang.String::equals (88 bytes)
Run Code Online (Sandbox Code Playgroud)
让我知道哪些方法是编译的,未编译的,标记为僵尸等等.是否有监控编译这些方法的代码缓存的用法?当编译器代码缓存已满时,我看到一条消息,上面写着:"我已经满了,没有更多的编译对你......",但似乎这样的事情似乎是一个滞后指示我们遇到了问题.我知道如何打印代码缓存的最大大小,我正在寻找的是一种方式来查看它是如何填充的.
我需要在一个看起来像这样的文件中匹配和解析数据:
4801-1-21-652-1-282098
4801-1-21-652-2-282098
4801-1-21-652-3-282098
4801-1-21-652-4-282098
4801-1-21-652-5-282098
Run Code Online (Sandbox Code Playgroud)
但我下面写的模式似乎不起作用.有人可以帮我理解为什么吗?
final String patternStr = "(\\d+)-(\\d+)-(\\d+)-(\\d+)-(\\d+)-(\\d+)";
final Pattern p = Pattern.compile(patternStr);
while ((this.currentLine = this.reader.readLine()) != null) {
final Matcher m = p.matcher(this.currentLine);
if (m.matches()) {
System.out.println("SUCCESS");
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个从trunk更改的svn合并到一个分支上(2001).更改在修订版614中的主干中.
我尝试了以下内容,但没有一个能按照我的意愿行事:
svn merge
svn merge -r 614:HEAD https://secreturl/trunk
Run Code Online (Sandbox Code Playgroud)
但这似乎取了很多我不想要的改变.
我跑的时候:svn log -r 614 https://secreturl/trunk- 我看到了想要合并的一小部分更改的签到评论.我在这里错过了什么?
我正在尝试在Windows Vista服务器上试验OracleHelp for Java.我下载了Oracle帮助,我正在按照他们的安装说明说明:
在OHJ安装目录中,有一个包含Windows .cmd文件和Unix/Linux shell脚本的bin子目录.在Windows平台上,双击.cmd文件以启动它们(或在命令行上键入.cmd文件名).在Unix平台上,键入"sh scriptName.sh"以执行shell脚本.
当我在Windows上设置JAVA_HOME时,我可以使用或不使用引号来设置它.无论哪种方式失败:
C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>set JAVA_HOME="C:\Program
Files (x86)\Java\jdk1.6.0_14"
C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>ohguide.cmd
C:\Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433>""C:\Program Files (x86)\Java\
jdk1.6.0_14"\bin\java.exe" -classpath "ohj.jar;help-share.jar;oracle_ice.jar;jew
t.jar;share.jar;help-demo.jar" oracle.help.demo.ChoiceDemo "demodoc\ohguide\ohgu
ide.hs"
'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
C:\ Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin>设置JAVA_HOME = C:\ Prog iles(x86)\ Java\jdk1.6.0_14
C:\ Users\Amir\Desktop\ohj-5_0_0_433\ohj-5_0_0_433\bin> ohguide.cmd'文件'无法识别为内部或外部命令,可运行程序或批处理文件.找不到Java虚拟机; 请设置JAVA_HOME环境变量.
我有一个关于Java Generics和Collections的问题.声明像这样的集合被认为是一种好习惯:
List<String> catNames = new ArrayList<String>();
Run Code Online (Sandbox Code Playgroud)
因为你可以改变它的类型,List而不用担心破坏你的其余代码.但是当我尝试这样做时:
private static Map<IssueType, List<Issue>> orphanedAttrMap = new HashMap<IssueType, ArrayList<Issue>>();
Run Code Online (Sandbox Code Playgroud)
javac 抱怨
Type mismatch: cannot convert from HashMap<ResultsAggregator.IssueType,ArrayList<Issue>> to HashMap<ResultsAggregator.IssueType,List<Issue>>
Run Code Online (Sandbox Code Playgroud)
而且,这是完全合法的:
private static Map<IssueType, List<Issue>> orphanedAttrMap = new HashMap<IssueType, List<Issue>>();
Run Code Online (Sandbox Code Playgroud)
这似乎更令人困惑,因为它List是一个接口,而不是一个具体的类.这里发生了什么?这是一种类型擦除问题吗?
我正在使用Visual Studio在Windows上编写c/c ++代码.我想知道如何有效地计算我的过程的开始时间.我可以使用gettimeofday()吗?我从谷歌找到了以下代码,但我不明白它在做什么:
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
//I'm lost at this point
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = …Run Code Online (Sandbox Code Playgroud) 我在.gitconfig中定义了以下别名:
[alias]
teamcity = ! tc
Run Code Online (Sandbox Code Playgroud)
tc是我在我的.bashrc文件中定义的shell函数.出于某种原因,我收到以下错误:
[aafghani-03:~/git/workday amirafghani(master)]$ git teamcity
tc: tc: command not found
Run Code Online (Sandbox Code Playgroud)
有谁知道我能做些什么来解决这个问题?我想尽可能将函数保存在我的.bashrc
文件中.
我有以下ant构建目标:
<target name="analyze">
<script language="javascript">
<![CDATA[
importPackage(java.lang);
var path = project.getProperty("PROJECT_HOME") + "/oms";
System.out.println("path = " +path);
]]>
]]>
</script>
</target>
Run Code Online (Sandbox Code Playgroud)
我想以递归方式查找目录中的所有文件,如果它们以.java打印出来.这可能吗?
我正在使用Apache Compress库来读取.tar.gz文件,如下所示:
final TarArchiveInputStream tarIn = initializeTarArchiveStream(this.archiveFile);
try {
TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
while (tarEntry != null) {
byte[] btoRead = new byte[1024];
BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(destPath)); //<- I don't want this!
int len = 0;
while ((len = tarIn.read(btoRead)) != -1) {
bout.write(btoRead, 0, len);
}
bout.close();
tarEntry = tarIn.getNextTarEntry();
}
tarIn.close();
}
catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
有可能不将它提取到一个单独的文件中,并以某种方式在内存中读取它吗?也许变成一个巨大的字符串或什么?
我编写了以下程序作为使用其 MD5 哈希删除重复文件的快速实验
import java.nio.file.{Files, Paths}
import java.security.MessageDigest
object Test {
def main(args: Array[String]) = {
val startTime = System.currentTimeMillis();
val byteArray = Files.readAllBytes(Paths.get("/Users/amir/pgns/bigPGN.pgn"))
val endTime = System.currentTimeMillis();
println("Read file into byte " +byteArray+ " in " + (endTime - startTime) +" ms");
val startTimeHash = System.currentTimeMillis();
val hash = MessageDigest.getInstance("MD5").digest(byteArray)
val endTimeHash = System.currentTimeMillis();
System.out.println("hashed file into " +hash+ " in " +(endTime - startTime)+ " ms");
}
}
Run Code Online (Sandbox Code Playgroud)
我注意到当我的 pgn 文件大约有 1.5 GB 的文本数据时,读取文件大约需要 2.5 秒,散列它需要 2.5 秒。 …