]> source.dussan.org Git - aspectj.git/commitdiff
141556: lint message sort out and memory leak resolution
authoraclement <aclement>
Fri, 18 Aug 2006 14:59:13 +0000 (14:59 +0000)
committeraclement <aclement>
Fri, 18 Aug 2006 14:59:13 +0000 (14:59 +0000)
ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
asm/src/org/aspectj/asm/AsmManager.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
tests/src/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml
weaver/src/org/aspectj/weaver/Lint.java
weaver/src/org/aspectj/weaver/LintMessage.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java

index 9d54bdd6a3bfd93f214c56b903549e9b77a0290d..b569d202d8de21527576a50a94544f6500353cd0 100644 (file)
@@ -634,7 +634,7 @@ public class CompilerAdapter {
                 }
                        
                        taskListManager.addSourcelineTask(message);
-                       return true;
+                       return true;// return super.handleMessage(message); // also store...    
                }
                
                private boolean handleAbort(IMessage abortMessage) {
index 87b5a347ae1c870d7ea0861aa7817734fcb92a0e..c5eca41e4805964263537d183179a000883aedb2 100644 (file)
@@ -393,6 +393,8 @@ public class AsmManager {
        public static void setDontReport() {
                reporting = false;
                dumpDeltaProcessing=false;
+               dumpModel=false;
+               dumpRelationships=false;
        }
        
 
index f0f26f325b78e1a9dd63ead2d5e1d32f7968d19c..a57c61f1a6659b871133710e50e3b2d14412d597 100644 (file)
@@ -26,6 +26,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.Compiler;
 import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
 import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
 import org.aspectj.org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
+import org.aspectj.weaver.LintMessage;
 
 /**
  * @author colyer
@@ -127,6 +128,10 @@ public class WeaverMessageHandler implements IMessageHandler {
                if (message.getDeclared()) {
                        details.append("[deow=true]");
                }
+               if (message instanceof LintMessage) {
+                       String lintMessageName = ((LintMessage)message).getLintKind();
+                       details.append("[Xlint:").append(lintMessageName).append("]");
+               }
                if (details.length()!=0) { 
                        problem.setSupplementaryMessageInfo(details.toString());
                }
index efdefe0d172aab6f9023c286c62a6d26e9083f57..c87a226d870b2c4bb6c8aee926d68a9347785021 100644 (file)
@@ -693,6 +693,15 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                state.setWeaver(bcelWeaver);
                state.clearBinarySourceFiles();
                
+               if (buildConfig.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT)) {
+                       bcelWorld.getLint().loadDefaultProperties();
+               } else {
+                       bcelWorld.getLint().setAll(buildConfig.getLintMode());
+               }
+               if (buildConfig.getLintSpecFile() != null) {
+                       bcelWorld.getLint().setFromProperties(buildConfig.getLintSpecFile());
+               }
+               
                for (Iterator i = buildConfig.getAspectpath().iterator(); i.hasNext();) {
                        File f = (File) i.next();
                        if (!f.exists()) {
@@ -705,15 +714,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                
 //             String lintMode = buildConfig.getLintMode();
                
-               if (buildConfig.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT)) {
-                       bcelWorld.getLint().loadDefaultProperties();
-               } else {
-                       bcelWorld.getLint().setAll(buildConfig.getLintMode());
-               }
                
-               if (buildConfig.getLintSpecFile() != null) {
-                       bcelWorld.getLint().setFromProperties(buildConfig.getLintSpecFile());
-               }
                
                //??? incremental issues
                for (Iterator i = buildConfig.getInJars().iterator(); i.hasNext(); ) {
@@ -957,7 +958,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                                        IProblem[] problems = unitResult.getAllProblems();
                                        for (int i=0; i < problems.length; i++) {
                                                IMessage message =
-                                                       EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i]);
+                                                       EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i],getBcelWorld());
                                                handler.handleMessage(message);
                                        }
                                }
index d9a75b79f9d8f0b99fa52abb30501796c2e34a63..a9c853bece491cf4253efe4a29a0b6a6144b5efc 100644 (file)
@@ -21,10 +21,9 @@ import org.aspectj.bridge.Message;
 import org.aspectj.bridge.SourceLocation;
 import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
 import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.aspectj.weaver.LintMessage;
+import org.aspectj.weaver.World;
 
-/**
- * 
- */
 public class EclipseAdapterUtils {
 
     //XXX some cut-and-paste from eclipse sources
@@ -127,8 +126,9 @@ public class EclipseAdapterUtils {
 
     /** 
      * Extract message text and source location, including context. 
+     * @param world 
      */
-    public static IMessage makeMessage(ICompilationUnit unit, IProblem problem) { 
+    public static IMessage makeMessage(ICompilationUnit unit, IProblem problem, World world) { 
         ISourceLocation sourceLocation = makeSourceLocation(unit, problem);
         IProblem[] seeAlso = problem.seeAlso();
         ISourceLocation[] seeAlsoLocations = new ISourceLocation[seeAlso.length];
@@ -143,10 +143,18 @@ public class EclipseAdapterUtils {
                // in the extraDetails.
                String extraDetails = problem.getSupplementaryMessageInfo();
                boolean declared = false;
+               boolean isLintMessage = false;
+               String lintkey = null;
                if (extraDetails!=null && extraDetails.endsWith("[deow=true]")) {
                        declared = true;
                        extraDetails = extraDetails.substring(0,extraDetails.length()-"[deow=true]".length());
                }
+               if (extraDetails!=null && extraDetails.indexOf("[Xlint:")!=-1) {
+                       isLintMessage = true;
+                       lintkey = extraDetails.substring(extraDetails.indexOf("[Xlint:"));
+                       lintkey = lintkey.substring("[Xlint:".length());
+                       lintkey = lintkey.substring(0,lintkey.indexOf("]"));
+               }
                
                // If the 'problem' represents a TO DO kind of thing then use the message kind that
                // represents this so AJDT sees it correctly.
@@ -157,7 +165,21 @@ public class EclipseAdapterUtils {
                  if (problem.isError()) { kind = IMessage.ERROR; }
                  else                   { kind = IMessage.WARNING; }
                }
-        IMessage msg = new Message(problem.getMessage(), 
+               IMessage msg = null;
+               if (isLintMessage) {
+                 msg = new LintMessage(
+                                  problem.getMessage(), 
+                                  extraDetails,
+                                  world.getLint().fromKey(lintkey),
+                                  kind,
+                                  sourceLocation, 
+                                  null,
+                                  seeAlsoLocations,
+                                  declared,
+                                  problem.getID(),
+                                  problem.getSourceStart(),problem.getSourceEnd());
+               } else {
+          msg = new Message(problem.getMessage(), 
                                                           extraDetails,
                                                                   kind,
                                                                   sourceLocation, 
@@ -166,7 +188,8 @@ public class EclipseAdapterUtils {
                                                                   declared,
                                                                   problem.getID(),
                                                                   problem.getSourceStart(),problem.getSourceEnd());
-        return msg;
+               }
+               return msg;
     }               
 
     public static IMessage makeErrorMessage(ICompilationUnit unit, String text, Exception ex) {
index 345681de0ef6ce7a7b910431e69283efbc8bfa6d..3dc02895c60c2c59d6b87c0f0bb99ac38e70af72 100644 (file)
@@ -36,7 +36,7 @@ import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.IMessageHandler;
 import org.aspectj.bridge.IMessageHolder;
 import org.aspectj.tools.ajc.Ajc;
-import org.aspectj.weaver.Lint.LintMessage;
+import org.aspectj.weaver.LintMessage;
 
 /**
  * The superclass knows all about talking through Ajde to the compiler.
@@ -953,6 +953,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
        
 
        public void testPr133117() {
+//             System.gc();
+//             System.exit();
                configureNonStandardCompileOptions("-Xlint:warning");
                initialiseProject("PR133117");
                build("PR133117");
@@ -1426,33 +1428,33 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                configureBuildStructureModel(false);
        }
        
-//     public void testDontLoseXlintWarnings_pr141556() {
-//             configureNonStandardCompileOptions("-Xlint:warning");
-//             initialiseProject("PR141556");
-//             build("PR141556");
-//             checkWasFullBuild();
-//             String warningMessage = "can not build thisJoinPoint " +
-//                             "lazily for this advice since it has no suitable guard " +
-//                             "[Xlint:noGuardForLazyTjp]";
-//             assertEquals("warning message should be '" + warningMessage + "'",
-//                             warningMessage,
-//                             ((IMessage)MyTaskListManager.getWarningMessages().get(0))
-//                                     .getMessage());
-//
-//             // add a space to the Aspect but dont do a build
-//             alter("PR141556","inc1");
-//             // remove the space so that the Aspect is exactly as it was
-//             alter("PR141556","inc2");
-//             // build the project and we should not have lost the xlint warning
-//             build("PR141556");
-//             checkWasntFullBuild();
-//             assertTrue("there should still be a warning message ",
-//                             !MyTaskListManager.getWarningMessages().isEmpty());
-//             assertEquals("warning message should be '" + warningMessage + "'",
-//                             warningMessage,
-//                             ((IMessage)MyTaskListManager.getWarningMessages().get(0))
-//                                     .getMessage());
-//     }
+       public void testDontLoseXlintWarnings_pr141556() {
+               configureNonStandardCompileOptions("-Xlint:warning");
+               initialiseProject("PR141556");
+               build("PR141556");
+               checkWasFullBuild();
+               String warningMessage = "can not build thisJoinPoint " +
+                               "lazily for this advice since it has no suitable guard " +
+                               "[Xlint:noGuardForLazyTjp]";
+               assertEquals("warning message should be '" + warningMessage + "'",
+                               warningMessage,
+                               ((IMessage)MyTaskListManager.getWarningMessages().get(0))
+                                       .getMessage());
+
+               // add a space to the Aspect but dont do a build
+               alter("PR141556","inc1");
+               // remove the space so that the Aspect is exactly as it was
+               alter("PR141556","inc2");
+               // build the project and we should not have lost the xlint warning
+               build("PR141556");
+               checkWasntFullBuild();
+               assertTrue("there should still be a warning message ",
+                               !MyTaskListManager.getWarningMessages().isEmpty());
+               assertEquals("warning message should be '" + warningMessage + "'",
+                               warningMessage,
+                               ((IMessage)MyTaskListManager.getWarningMessages().get(0))
+                                       .getMessage());
+       }
 
        public void testLintMessage_pr141564() {
                configureNonStandardCompileOptions("-Xlint:warning");
@@ -1472,7 +1474,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                                msg instanceof LintMessage);
                assertTrue("expected message to be noGuardForLazyTjp xlint message but" +
                                " instead was " + ((LintMessage)msg).getKind().toString(),
-                               ((LintMessage)msg).isNoGuardForLazyTjp());
+                               ((LintMessage)msg).getLintKind().equals("noGuardForLazyTjp"));
+                               
                assertTrue("expected message to be against file in project 'PR141556' but wasn't",
                                msg.getSourceLocation().getSourceFile().getAbsolutePath().indexOf("PR141556") != -1);
        }
index 2700af07f2e3d281a6d6239487c1cf7c8e40dbb3..dbafe9044512204bce99c004eb37202a4c1fab77 100644 (file)
                pr="41181">
                <compile files="ClinitTest.java, Util.java"/>
         <run class="ClinitTest"/>
-               <compile files="ClinitTest.java, Util.java, TJP.aj" options="-Xlint:warning"/>
+               <compile files="ClinitTest.java, Util.java, TJP.aj" options="-Xlint:warning">
+                 <message kind="warning" line="24" text="can not build"/>
+                 <message kind="warning" line="31" text="can not build"/>
+               </compile>
         <run class="Util" options="-read"/>
        </ajc-test>
 
index ab12e7aac629cf4dd47da395fd98c449a60085ff..5dc5bf065ca40dad0b956bfa8a032976feab608c 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Properties;
 
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.Message;
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.weaver.tools.Trace;
 import org.aspectj.weaver.tools.TraceFactory;
@@ -239,8 +238,10 @@ public class Lint {
                                WeaverMessages.format(WeaverMessages.XLINT_VALUE_ERROR,v));
                return null;
        }
-       
-       
+
+       public Kind fromKey(String lintkey) {
+               return (Lint.Kind)kinds.get(lintkey);
+       }
        
        public class Kind {
                private String name;
@@ -290,41 +291,12 @@ public class Lint {
                public void signal(String[] infos, ISourceLocation location, ISourceLocation[] extraLocations) {
             if (kind == null) return;
             
-            String text = MessageFormat.format(message, infos );
+            String text = MessageFormat.format(message, (Object[])infos );
             text += " [Xlint:" + name + "]";
             world.getMessageHandler().handleMessage(
                     new LintMessage(text, kind, location,extraLocations,getLintKind(name)));
                }
-       }
-       
-       public class LintMessage extends Message {
-               
-               private Lint.Kind lintKind;
-               
-               public LintMessage(
-                               String message, 
-                               IMessage.Kind messageKind, 
-                               ISourceLocation location, 
-                               ISourceLocation[] extraLocations,
-                               Lint.Kind lintKind) {  
-                       super(message,"",messageKind,location,null,extraLocations);
-                       this.lintKind = lintKind;
-               }
-               
-               /**
-                * @return Returns the Lint kind of this message
-                */
-               public Lint.Kind getLintKind() {
-                       return lintKind;
-               }
-               
-               /**
-                * @return true if this message is a noGuardForLazyTjp xlint
-                * message and false otherwise
-                */
-               public boolean isNoGuardForLazyTjp() {
-                       return lintKind.equals(noGuardForLazyTjp);
-               }
+
        }
        
 }
diff --git a/weaver/src/org/aspectj/weaver/LintMessage.java b/weaver/src/org/aspectj/weaver/LintMessage.java
new file mode 100644 (file)
index 0000000..3a93af9
--- /dev/null
@@ -0,0 +1,47 @@
+/* *******************************************************************
+ * Copyright (c) 2002-2006 Contributors
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *     PARC     initial implementation 
+ *     AndyClement extracted as self contained type from Lint type (4-Aug-06)
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.Message;
+
+public class LintMessage extends Message {
+       
+       // private Lint.Kind lintKind;
+       private String lintKind;
+       
+       public LintMessage(
+                       String message, 
+                       IMessage.Kind messageKind, 
+                       ISourceLocation location, 
+                       ISourceLocation[] extraLocations,
+                       Lint.Kind lintKind) {  
+               super(message,"",messageKind,location,null,extraLocations);
+               this.lintKind = lintKind.getName();
+       }
+       
+       public LintMessage(String message, String extraDetails, org.aspectj.weaver.Lint.Kind kind2, Kind kind, ISourceLocation sourceLocation, Throwable object, 
+                       ISourceLocation[] seeAlsoLocations, boolean declared, int id, int sourceStart, int sourceEnd) {
+               super(message,extraDetails,kind,sourceLocation,object,seeAlsoLocations,declared,id,sourceStart,sourceEnd);
+               this.lintKind = kind2.getName();
+       }
+
+       /**
+        * @return Returns the Lint kind of this message
+        */
+       public String getLintKind() {
+               return lintKind;
+       }
+       
+}
\ No newline at end of file
index 64d43967185e35993038833dbb5364de5f5a9d81..ab61031f6bf3357ec0037283d3544b3f52822ba2 100644 (file)
@@ -58,7 +58,6 @@ public class BcelAdvice extends Advice {
        private ExposedState exposedState;
     
     private boolean hasMatchedAtLeastOnce = false;
-    private boolean hasReportedNoGuardForLazyTJP = false;
 
        public BcelAdvice(
                AjAttribute.AdviceAttribute attribute,
@@ -86,6 +85,17 @@ public class BcelAdvice extends Advice {
                suppressLintWarnings(world);
                ShadowMunger ret = super.concretize(fromType, world, clause);
                clearLintSuppressions(world,this.suppressedLintKinds);
+               IfFinder ifinder = new IfFinder();
+               ret.getPointcut().accept(ifinder,null);
+               boolean hasGuardTest = ifinder.hasIf && getKind() != AdviceKind.Around;
+               boolean isAround = getKind() == AdviceKind.Around;
+               if ((getExtraParameterFlags() & ThisJoinPoint) != 0) {
+                 if (!isAround && !hasGuardTest && world.getLint().noGuardForLazyTjp.isEnabled()) {
+                       // can't build tjp lazily, no suitable test...
+                       // ... only want to record it once against the advice(bug 133117)
+                       world.getLint().noGuardForLazyTjp.signal("",getSourceLocation());       
+                 }
+               }
                return ret;
        }
        
@@ -159,15 +169,6 @@ public class BcelAdvice extends Advice {
                                // collect up the problematic advice
                                ((BcelShadow)shadow).addAdvicePreventingLazyTjp(this);
                        }
-                       if (!hasReportedNoGuardForLazyTJP && !isAround && !hasGuardTest && world.getLint().noGuardForLazyTjp.isEnabled()) {
-                               // can't build tjp lazily, no suitable test...
-                               // ... only want to record it once against the advice(bug 133117)
-                               world.getLint().noGuardForLazyTjp.signal(
-                                               "",
-                                           getSourceLocation()
-                               );      
-                               hasReportedNoGuardForLazyTJP = true;
-                       }
         }
         
         if ((getExtraParameterFlags() & ThisEnclosingJoinPointStaticPart) != 0) {