嗯,使用 Java 7 (1.7.0_67) 并将项目语言级别设置为 7-Diamonds、ARM、multi-catch。我的代码如下,使用 maven 构建时抛出编译错误的行。
private Map<String, List<InstrumentationClassData>> classMap = new HashMap<>(); //line 36 in InstrumentingAgent
InstrumentingAgent 第 63 行中的多重捕获块
} catch (InstrumentationException | JAXBException e){
e.getMessage();
}
我在编译时遇到以下错误。为什么不起作用?我究竟做错了什么。我正在使用 IntelliJ IDE。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project instrumentation-agent: Compilation failure: Compilation failure:
[ERROR] /home/Documents/instrumentation-agent/src/main/java/org/wso2/das/javaagent/instrumentation/InstrumentingAgent.java:[36,79] error: diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /home/Documents/instrumentation-agent/src/main/java/org/wso2/das/javaagent/instrumentation/InstrumentingAgent.java:[63,47] error: multi-catch statement is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable multi-catch statement)
根据我的阅读,钻石运算符应该与 Java 7 一起使用。但为什么我会得到这个。如果我用相关类型填充菱形,那么 IDE 会将它们变成灰色,并表示它可以用菱形运算符替换。但是当我更换它时会出现以下错误。
在 pom 中添加以下内容解决了编译错误,
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)