]> source.dussan.org Git - aspectj.git/commitdiff
-Xlint:xxx and -Xlintfile:xxx in aop.xml
authoravasseur <avasseur>
Fri, 12 Aug 2005 13:38:51 +0000 (13:38 +0000)
committeravasseur <avasseur>
Fri, 12 Aug 2005 13:38:51 +0000 (13:38 +0000)
docs/adk15ProgGuideDB/ltw.xml
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
loadtime/src/org/aspectj/weaver/loadtime/Options.java

index ae36255acdd069ffccb289264153987485fb93fc..5fcc307771828c6af01b3f20545b3d7bc1691a79 100644 (file)
                         </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>
index e3abb3f009f1d47735003b12c8a1c065ec473449..123a28e6bc83a671a33ee27f98a601b36aff4900 100644 (file)
@@ -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
     }
 
index 507afe9900052a505c9df66b61221f561879dec1..7385fd482a04e20bf08928c997180ae551e4feb1 100644 (file)
@@ -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