compiled code in JVM?

有什么方法可以查看JVM在JVM中生成的本机代码? Assuming you're using the Sun Hotspot JVM (ie the one provided on java.com by Oracle), you can add the flag -XX:+PrintOptoAssembly when running your code. This will print out the optimized code generated by the JIT compiler and leaves out the rest. If you want see the entire bytecode, including the unoptimized parts, add -XX:CompileThresho

在JVM中编译代码?

有什么方法可以查看JVM在JVM中生成的本机代码? 假设您使用Sun Hotspot JVM(即Oracle提供的java.com上的那个),则可以添加标志 -XX:+ PrintOptoAssembly 运行代码时。 这将打印出由JIT编译器生成的优化代码,并将剩下的代码排除在外。 如果你想看到整个字节码,包括未优化的部分,请添加 -XX:CompileThreshold =# 当你运行你的代码。 在这里你可以阅读更多关于这个命令和JIT的功能。 一般用法 正如其他答

How do I create a file and write to it in Java?

用Java创建和写入(文本)文件的最简单方法是什么? Note that each of the code samples below may throw IOException . Try/catch/finally blocks have been omitted for brevity. See this tutorial for information about exception handling. Creating a text file (note that this will overwrite the file if it already exists): PrintWriter writer = new PrintWriter("the-file-name.txt", "UTF-8"); writer.print

我如何创建一个文件并在Java中写入文件?

用Java创建和写入(文本)文件的最简单方法是什么? 请注意,下面的每个代码示例可能会抛出IOException 。 为简洁起见,try / catch / finally块已被省略。 有关异常处理的信息,请参阅本教程。 创建一个文本文件(注意,如果文件已存在,将覆盖该文件): PrintWriter writer = new PrintWriter("the-file-name.txt", "UTF-8"); writer.println("The first line"); writer.println("The second line"); writer.close();

How can I measure time with microsecond precision in Java?

I saw on the Internet that I was supposed to use System.nanoTime() but that doesn't work for me - it gives me the time with milliseconds precision. I just need the microseconds before and after my function executes so that I know how long it takes. I'm using Windows XP. Basically, I have this code that, for example, does 1 million up to 10 millions of insertions in a java linked list.

我如何在Java中以微秒精度测量时间?

我在互联网上看到我应该使用System.nanoTime(),但这对我不起作用 - 它为我提供了毫秒精度的时间。 我只需要执行函数前后的微秒,以便知道需要多长时间。 我正在使用Windows XP。 基本上,我有这样的代码,例如,在Java链接列表中有100万到10百万的插入。 问题是我无法测量精确度; 有时候将更少的时间插入到较小的列表中。 这是一个例子: class test { public static void main(String args[]) { for

Is stopwatch benchmarking acceptable?

Does anyone ever use stopwatch benchmarking, or should a performance tool always be used? Are there any good free tools available for Java? What tools do you use? To clarify my concerns, stopwatch benchmarking is subject to error due to operating system scheduling. On a given run of your program the OS might schedule another process (or several) in the middle of the function you're timin

秒表基准测试是否可以接受?

有没有人使用过秒表基准测试,或者应该使用性能测试工具? 是否有任何可用于Java的免费工具? 你用什么工具? 为了澄清我的担忧,秒表基准测试由于操作系统调度而出现错误。 在您的程序运行过程中,操作系统可能会安排另一个进程(或几个进程)处于您计时功能的中间。 在Java中,如果您尝试使用线程化应用程序,则情况会更糟糕,因为JVM调度程序甚至会将混乱中的一些随机性引入更多。 基准测试时如何解决操作系统调度问

Automatically add private qualifier to fields in eclipse

Is there a way to automatically add the private qualifier while new variables are declared in Eclipse? In a way I would like to override the default access to private I don't know of a way to do this. However, the way i write code, it would rarely be necessary. That's because i rarely define fields by hand; instead, i let Eclipse create them, and when it does that, it makes them p

在eclipse中自动添加专用限定符到字段

有没有办法在Eclipse中声明新变量时自动添加私有限定符? 在某种程度上,我想重写对私有的默认访问 我不知道有办法做到这一点。 但是,我编写代码的方式很少有必要。 那是因为我很少手工定义字段; 相反,我让Eclipse创建它们,当它这样做时,它使它们变成私有的。 假设我想用一个int类型的单个栏位bar创建一个Foo类。 从...开始: public class Foo { } 将光标置于类体中,命中控制空间,然后从提议菜单中选择“默认

JNLP, Webstart, and Maven

I created a simple Hello World Swing application that compiles and runs just fine in Eclipse. I'm now trying to transfer this application over to a Maven package structure and run it as a Java Web-Start application, which is causing me great pain. After running "mvn clean install", javaws appears to load for several seconds and then quit. Here are a few things for reference. My

JNLP,Webstart和Maven

我创建了一个简单的Hello World Swing应用程序,它可以在Eclipse中编译和运行。 我现在试图将这个应用程序转移到Maven包结构中,并将其作为Java Web-Start应用程序运行,这给我带来了很大的痛苦。 运行“mvn clean install”后,javaws似乎会加载几秒钟,然后退出。 这里有几点需要参考。 我的(非常简单)项目应该是完全可重复的: 包结构(从树中): ├── pom.xml ├── readme.txt ├── SwingWebstartMaven-Client │   ├──

What could make the loading slow in android 4.1.X and not on 4.2?

I am using UrlImageViewHelper in order to load pictures in an adapterview. My adapter is: @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView==null){ convertView=new SquaredImageView(getContext()); } SquaredImageView view= (SquaredImageView) convertView; final long time=System.currentTimeMillis(); UrlImageV

什么可以使加载缓慢的android 4.1.X而不是4.2?

我正在使用UrlImageViewHelper为了加载适配器视图中的图片。 我的适配器是: @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView==null){ convertView=new SquaredImageView(getContext()); } SquaredImageView view= (SquaredImageView) convertView; final long time=System.currentTimeMillis(); UrlImageViewHelper.setUrlDr

NEW is internal proprietary API

During build of our project we get a rather unexplained warning: [javac] (...)SessionKeeper.java:39: warning: NEW is internal proprietary API and may be removed in a future release [javac] private static final int timeOfInactivity = 1000 * 60 * 9; // allowed time of inactivity [javac] ^ Additional info: Apache Ant(TM) version 1.8.4 compiled on May

NEW是内部专有API

在我们项目的构建过程中,我们得到了一个无法解释的警告: [javac] (...)SessionKeeper.java:39: warning: NEW is internal proprietary API and may be removed in a future release [javac] private static final int timeOfInactivity = 1000 * 60 * 9; // allowed time of inactivity [javac] ^ 附加信息: Apache Ant(TM)1.8.4版于2012年5月22日编译 Java(TM)SE运

JUnit Ant task won't output to screen

Context I am using ant1-9-0.jar , ant-junit-1.9.0.jar and ant-launcher-1.9.0.jar to run JUnit tests programmatically. In my code, I have this function that returns the JUnit Task: /** * Generates a JUnit task which runs every single test in a new JVM * @return task The JUnit task * @throws Exception */ public JUnitTask generateRunTestsTask() throws Exception { /* New JUnit task */

JUnit Ant任务不会输出到屏幕

上下文 我正在使用ant1-9-0.jar , ant-junit-1.9.0.jar和ant-launcher-1.9.0.jar以编程方式运行JUnit测试。 在我的代码中,我有这个函数返回JUnit Task: /** * Generates a JUnit task which runs every single test in a new JVM * @return task The JUnit task * @throws Exception */ public JUnitTask generateRunTestsTask() throws Exception { /* New JUnit task */ JUnitTask task = new JUnitTask();

JVM crash reason

this is the crash log # # An unexpected error has been detected by HotSpot Virtual Machine: # #  SIGSEGV (0xb) at pc=0xf7754a07, pid=20403, tid=2813246368 # # Java VM: Java HotSpot(TM) Server VM (1.5.0_06-b05 mixed mode) # Problematic frame: # V  [libjvm.so+0x152a07] # ---------------  T H R E A D  --------------- Current thread (0x08145b

JVM崩溃的原因

这是崩溃日志 # # An unexpected error has been detected by HotSpot Virtual Machine: # #  SIGSEGV (0xb) at pc=0xf7754a07, pid=20403, tid=2813246368 # # Java VM: Java HotSpot(TM) Server VM (1.5.0_06-b05 mixed mode) # Problematic frame: # V  [libjvm.so+0x152a07] # ---------------  T H R E A D  --------------- Current thread (0x08145b60):  Jav