summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravasseur <avasseur>2005-08-12 13:38:51 +0000
committeravasseur <avasseur>2005-08-12 13:38:51 +0000
commit1234abf691b69a9e70737247516054e4701e712d (patch)
treec6a76f30646f25a6d0092f0fc0d0507a5ff4c646
parent28b3501d12c875b9f5a9d391c9386e7d9bf91ab7 (diff)
downloadaspectj-1234abf691b69a9e70737247516054e4701e712d.tar.gz
aspectj-1234abf691b69a9e70737247516054e4701e712d.zip
-Xlint:xxx and -Xlintfile:xxx in aop.xml
-rw-r--r--docs/adk15ProgGuideDB/ltw.xml10
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java38
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/Options.java13
3 files changed, 58 insertions, 3 deletions
diff --git a/docs/adk15ProgGuideDB/ltw.xml b/docs/adk15ProgGuideDB/ltw.xml
index ae36255ac..5fcc30777 100644
--- a/docs/adk15ProgGuideDB/ltw.xml
+++ b/docs/adk15ProgGuideDB/ltw.xml
@@ -309,9 +309,15 @@
</row>
<row>
<entry>
- <literal>-Xlint, -Xlint:ignore, ...</literal>
+ <literal>-Xlintfile:pathToAResource</literal>
</entry>
- <entry>Configure lint messages</entry><!--FIXME AV - default to blabla, see link X -->
+ <entry>Configure lint messages as specified in the given resource (visible from this aop.xml file' classloader)</entry>
+ </row>
+ <row>
+ <entry>
+ <literal>-Xlint:default, -Xlint:ignore, ...</literal>
+ </entry>
+ <entry>Configure lint messages, refer to documentation for meaningfull values</entry>
</row>
<row>
<entry>
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
index e3abb3f00..123a28e6b 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
@@ -30,11 +30,14 @@ import org.aspectj.weaver.tools.GeneratedClassHandler;
import org.aspectj.weaver.tools.WeavingAdaptor;
import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
/**
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
@@ -121,7 +124,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
MessageUtil.info(messageHandler, "using " + xml.getFile());
definitions.add(DocumentParser.parse(xml));
}
-
+
// still go thru if definitions is empty since we will configure
// the default message handler in there
registerOptions(weaver, loader, definitions);
@@ -161,6 +164,39 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
weaver.setReweavableMode(weaverOption.reWeavable, false);
world.setXnoInline(weaverOption.noInline);
world.setBehaveInJava5Way(weaverOption.java5);//TODO should be autodetected ?
+ //-Xlintfile: first so that lint wins
+ if (weaverOption.lintFile != null) {
+ InputStream resource = null;
+ try {
+ resource = loader.getResourceAsStream(weaverOption.lintFile);
+ Exception failure = null;
+ if (resource != null) {
+ try {
+ Properties properties = new Properties();
+ properties.load(resource);
+ world.getLint().setFromProperties(properties);
+ } catch (IOException e) {
+ failure = e;
+ }
+ }
+ if (failure != null || resource == null) {
+ world.getMessageHandler().handleMessage(new Message(
+ "Cannot access resource for -Xlintfile:"+weaverOption.lintFile,
+ IMessage.WARNING,
+ failure,
+ null));
+ }
+ } finally {
+ try { resource.close(); } catch (Throwable t) {;}
+ }
+ }
+ if (weaverOption.lint != null) {
+ if (weaverOption.lint.equals("default")) {//FIXME should be AjBuildConfig.AJLINT_DEFAULT but yetanother deps..
+ bcelWorld.getLint().loadDefaultProperties();
+ } else {
+ bcelWorld.getLint().setAll(weaverOption.lint);
+ }
+ }
//TODO proceedOnError option
}
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/Options.java b/loadtime/src/org/aspectj/weaver/loadtime/Options.java
index 507afe990..7385fd482 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/Options.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/Options.java
@@ -39,6 +39,9 @@ public class Options {
private final static String OPTION_noinline = "-Xnoinline";
private final static String OPTION_showWeaveInfo = "-showWeaveInfo";
private final static String OPTIONVALUED_messageHandler = "-XmessageHandlerClass:";
+ private static final String OPTIONVALUED_Xlintfile = "-Xlintfile:";
+ private static final String OPTIONVALUED_Xlint = "-Xlint:";
+
public static WeaverOption parse(String options, ClassLoader laoder) {
if (LangUtil.isEmpty(options)) {
@@ -94,6 +97,14 @@ public class Options {
weaverOption.verbose = true;
} else if (arg.startsWith(OPTIONVALUED_messageHandler)) {
;// handled in first round
+ } else if (arg.startsWith(OPTIONVALUED_Xlintfile)) {
+ if (arg.length() > OPTIONVALUED_Xlintfile.length()) {
+ weaverOption.lintFile = arg.substring(OPTIONVALUED_Xlintfile.length()).trim();
+ }
+ } else if (arg.startsWith(OPTIONVALUED_Xlint)) {
+ if (arg.length() > OPTIONVALUED_Xlint.length()) {
+ weaverOption.lint = arg.substring(OPTIONVALUED_Xlint.length()).trim();
+ }
} else {
weaverOption.messageHandler.handleMessage(
new Message(
@@ -130,6 +141,8 @@ public class Options {
boolean noInline;
boolean showWeaveInfo;
IMessageHandler messageHandler;
+ String lint;
+ String lintFile;
public WeaverOption() {
messageHandler = new DefaultMessageHandler();//default