gpt4 book ai didi

intellij-idea - 在intellij idea中设置aspectj weaver的编译级别

转载 作者:行者123 更新时间:2023-12-01 15:26:14 26 4
gpt4 key购买 nike

我向项目添加了简单的注释驱动方面,IntelliJ 无法编译它:

annotation type patterns are only supported at Java 5 compliance level or above

请建议,应该在哪里配置编译级别(在项目设置中,整个项目和所有模块都设置为 Java 6),在设置->aspectj weaver 中,只能启用 weaver 并查看方面列表。

UPD 该问题与 OpenJDK 有关,因为aspectJ weaver 插件无法正确识别其版本。补丁已提交给维护者。

--- src/common/se/expertsystem/intellij/PluginUtils.java.orig   2012-04-11 14:03:35.000000000 +0300
+++ src/common/se/expertsystem/intellij/PluginUtils.java 2012-04-11 14:47:11.000000000 +0300
@@ -31,32 +31,34 @@
*/
package se.expertsystem.intellij;

+import com.intellij.openapi.application.ApplicationInfo;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
-import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.application.ApplicationInfo;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.OrderRootType;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ActionRunner;

-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.io.IOException;
import java.io.File;
-import java.lang.reflect.Method;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;

/**
* Class containing useful utility methods for IntelliJ IDEA plugins.
@@ -68,6 +70,8 @@

private static final Class[] NO_PARAMETERS = new Class[] {};

+ private static final Pattern jdkVersionResolver = Pattern.compile("(java|openjdk)\\s+version\\s+\"(\\d+)\\.(\\d+)");
+
/**
* Find classpath for module. Returns list of <code>File</code>s.
* @param project Project to get classpath for.
@@ -296,13 +300,21 @@
*/
public static boolean isJava5(Module module) {
final String versionString = getJdkVersionString(module); // Example: java version "1.5.0_07"
- if(versionString.startsWith("java version \"1.") && versionString.length() > "java version \"1.".length())
- return versionString.charAt("java version \"1.".length()) >= '5';
- LOG.error("Unparsable version string: " + versionString);
- return false;
+ final Matcher versionMatcher = jdkVersionResolver.matcher(versionString);
+ if (!versionMatcher.find()) {
+ LOG.error("Unparsable version string (regex failed): " + versionString);
+ return false;
+ } else if (!("1".equals(versionMatcher.group(2))
+ && versionMatcher.group(3).charAt(0) >= '5')) {
+ LOG.error("Version invalid: major "+versionMatcher.group(2)+
+ " , minor "+versionMatcher.group(3));
+ return false;
+ }
+ LOG.info("Detected JDK: "+versionString);
+ return true;
}

- /////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////
// Methods for progress indication
/////////////////////////////////////////////////////////////////////////////

@@ -382,4 +394,4 @@
return modules;
}
}
-}
\ No newline at end of file
+}

最佳答案

尝试

source="1.5"

插入到 build.xml 中的 iajc 任务中

关于intellij-idea - 在intellij idea中设置aspectj weaver的编译级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10103994/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com