java mutilcatch,为什么java 7不能使用diamond运算符和multi-catch语句

um using Java 7 (1.7.0_67) and Project language level is set to 7-Diamonds,ARM, multi-catch. My code is as follows, the lines that throw the compilation errors while building using maven.

private Map> classMap = new HashMap<>(); //line 36 in InstrumentingAgent

Multi-catch block in InstrumentingAgent line 63

} catch (InstrumentationException | JAXBException e){

e.getMessage();

}

I am getting following errors when compiling. Why doesn't it work? What am I doing wrong. I am working on 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)

According to what I read diamond operator should work with Java 7. But why am I getting this. If I fill the diamonds with relevant types then the IDE turn them gray and say it could have replaced with diamond operator. But when I replace it gives following errors.

解决方案

Adding following to the pom solved the compilation error,

maven-compiler-plugin

3.2

1.7

1.7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值