我正在努力让maven输出lint级警告.我已经创建了一个小的测试程序,它应该生成一个关于从非静态上下文中使用静态方法的警告,但是尽管有许多不同的插件配置选项,但构建总是成功而没有任何警告!
在做了一些谷歌搜索后,我发现建议使用编译器插件的'compilerArgument(s)'属性,但这对我来说似乎也没有用.
这是我应该生成警告的示例程序:
package com.dahlgren;
/**
* Test space
*
*/
public class App {
public static void main( String[] args ) {
String foo = "foo";
// I want this to generate a compilation warning
System.out.println(foo.format("blah"));
}
}
Run Code Online (Sandbox Code Playgroud)
此程序应发出警告,因为Java 6 String :: format 的javadoc表示仅存在此方法的静态版本.我想特别抓住这个案例,因为它过去曾经咬过我,编译器应该检测它:-)
这是我的pom文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dahlgren</groupId>
<artifactId>JavaScratchSpace</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JavaScratchSpace</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint:all</compilerArgument>
<!--
<compilerArguments>
<Xlint:all />
</compilerArguments>
-->
<showWarnings>true</showWarnings> …Run Code Online (Sandbox Code Playgroud) 我最近一直在讨论JVM字节码,我想知道是否重构性能关键代码以利用Tload_ <n>指令(aload_0,aload_1,aload_2等)而不是两个操作数Tload指令会网任何可观的性能优势?
这完全属于"您永远不需要的微观优化"类别,但认为它是学术上的好奇心.如果一个方法可以将其局部变量表保存在7个条目下,那么性能优势(如果有的话)可以表现出来吗?我认为这可能只会导致字节码变得越来越小.
关于字节码级优化的阅读材料的质量链接的奖励点!