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