Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode

Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode

 2014/11/24 13:24:37  Rainbow702  程序员俱乐部  我要评论(0)
  • 摘要:今天在使用Sonarqube检测代码的时候,报了一个错,错误信息为:CannotusethediamondgenericnotationwhenrunninginJDKinferiorto1.7mode!后在网上查了一下,是因为在sonar-project.properties这份配置文件中,没有明确指定JDK版本的原因。所以,须像如下一样进行指定:#settingthejavaclassversionsonar.java.source=1.7然后就可以啦!附:stack信息为:09:02
  • 标签:can jdk not

今天在使用Sonar qube 检测代码的时候,报了一个错,错误信息为:

Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode!

?

后在网上查了一下,是因为在sonar-project.properties 这份配置文件中,没有明确指定 JDK 版本的原因。所以,须像如下一样进行指定:

class="java" name="code"># setting the java class version
sonar.java.source=1.7

?然后就可以啦!

?

附: stack信息为:

09:02:47.184 INFO  - Sensor PmdSensor...
09:02:47.187 INFO  - Execute PMD 4.3...
09:02:47.226 INFO  - Java version: 1.5
09:02:47.271 INFO  - PMD configuration: D:\ppp\.sonar\pmd.xml
09:02:48.465 ERROR - Fail to execute PMD. Following file is ignored: D:\ppp\src\com\ppm\dao\implement\ParentInfo_DAL.java
net.sourceforge.pmd.ast.ParseException: Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode!
        at net.sourceforge.pmd.ast.JavaParser.checkForBadDiamondUsage(JavaParser.java:75) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.TypeArguments(JavaParser.java:2017) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ClassOrInterfaceType(JavaParser.java:1945) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.AllocationExpression(JavaParser.java:3875) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.PrimaryPrefix(JavaParser.java:3535) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.PrimaryExpression(JavaParser.java:3433) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.PostfixExpression(JavaParser.java:3337) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.UnaryExpressionNotPlusMinus(JavaParser.java:3237) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.UnaryExpression(JavaParser.java:3098) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.MultiplicativeExpression(JavaParser.java:2989) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.AdditiveExpression(JavaParser.java:2934) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ShiftExpression(JavaParser.java:2881) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.RelationalExpression(JavaParser.java:2816) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.InstanceOfExpression(JavaParser.java:2779) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.EqualityExpression(JavaParser.java:2724) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.AndExpression(JavaParser.java:2683) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ExclusiveOrExpression(JavaParser.java:2642) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.InclusiveOrExpression(JavaParser.java:2601) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ConditionalAndExpression(JavaParser.java:2560) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ConditionalOrExpression(JavaParser.java:2519) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ConditionalExpression(JavaParser.java:2479) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Expression(JavaParser.java:2340) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.VariableInitializer(JavaParser.java:1278) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.VariableDeclarator(JavaParser.java:1180) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.LocalVariableDeclaration(JavaParser.java:4269) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.BlockStatement(JavaParser.java:4198) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Block(JavaParser.java:4162) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Statement(JavaParser.java:4025) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.IfStatement(JavaParser.java:4517) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Statement(JavaParser.java:4061) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.BlockStatement(JavaParser.java:4201) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Block(JavaParser.java:4162) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Statement(JavaParser.java:4025) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.IfStatement(JavaParser.java:4517) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Statement(JavaParser.java:4061) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.BlockStatement(JavaParser.java:4201) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Block(JavaParser.java:4162) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Statement(JavaParser.java:4025) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.IfStatement(JavaParser.java:4522) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Statement(JavaParser.java:4061) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.BlockStatement(JavaParser.java:4201) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.Block(JavaParser.java:4162) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.MethodDeclaration(JavaParser.java:1416) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ClassOrInterfaceBodyDeclaration(JavaParser.java:1085) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ClassOrInterfaceBody(JavaParser.java:1004) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ClassOrInterfaceDeclaration(JavaParser.java:514) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.TypeDeclaration(JavaParser.java:406) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.CompilationUnit(JavaParser.java:164) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.parsers.Java15Parser.parse(Java15Parser.java:24) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.PMD.processFile(PMD.java:98) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.PMD.processFile(PMD.java:75) ~[pmd-4.3.jar:na]
        at net.sourceforge.pmd.PMD.processFile(PMD.java:210) ~[pmd-4.3.jar:na]
        at org.sonar.plugins.pmd.PmdTemplate.process(PmdTemplate.java:71) ~[sonar-pmd-plugin-1.5.jar:na]
        at org.sonar.plugins.pmd.PmdExecutor.executeRules(PmdExecutor.java:100) [sonar-pmd-plugin-1.5.jar:na]
        at org.sonar.plugins.pmd.PmdExecutor.executePmd(PmdExecutor.java:75) [sonar-pmd-plugin-1.5.jar:na]
        at org.sonar.plugins.pmd.PmdExecutor.execute(PmdExecutor.java:61) [sonar-pmd-plugin-1.5.jar:na]
        at org.sonar.plugins.pmd.PmdSensor.analyse(PmdSensor.java:52) [sonar-pmd-plugin-1.5.jar:na]
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:72) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:114) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:150) [sonar-batch-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:211) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:206) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:199) [sonar-batch-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:58) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82) [sonar-batch-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:144) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:132) [sonar-batch-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) [sonar-plugin-api-4.1.1.jar:na]
        at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92) [sonar-batch-4.1.1.jar:na]
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74) [sonar-batch-4.1.1.jar:na]
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45) [sonar-runner-batch6119497299030140902.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_13]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_13]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_13]
        at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_13]
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) [sonar-runner-dist-2.3.jar:na]
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) [sonar-runner-dist-2.3.jar:na]
        at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_13]
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) [sonar-runner-dist-2.3.jar:na]
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) [sonar-runner-dist-2.3.jar:na]
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) [sonar-runner-dist-2.3.jar:na]
        at org.sonar.runner.api.Runner.execute(Runner.java:90) [sonar-runner-dist-2.3.jar:na]
        at org.sonar.runner.Main.executeTask(Main.java:70) [sonar-runner-dist-2.3.jar:na]
        at org.sonar.runner.Main.execute(Main.java:59) [sonar-runner-dist-2.3.jar:na]
        at org.sonar.runner.Main.main(Main.java:41) [sonar-runner-dist-2.3.jar:na]

?

发表评论
用户名: 匿名