From 1234abf691b69a9e70737247516054e4701e712d Mon Sep 17 00:00:00 2001 From: avasseur Date: Fri, 12 Aug 2005 13:38:51 +0000 Subject: [PATCH] -Xlint:xxx and -Xlintfile:xxx in aop.xml --- docs/adk15ProgGuideDB/ltw.xml | 10 ++++- .../loadtime/ClassLoaderWeavingAdaptor.java | 38 ++++++++++++++++++- .../org/aspectj/weaver/loadtime/Options.java | 13 +++++++ 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 @@ - -Xlint, -Xlint:ignore, ... + -Xlintfile:pathToAResource - Configure lint messages + Configure lint messages as specified in the given resource (visible from this aop.xml file' classloader) + + + + -Xlint:default, -Xlint:ignore, ... + + Configure lint messages, refer to documentation for meaningfull values 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 Alexandre Vasseur @@ -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 -- 2.39.5