diff options
10 files changed, 147 insertions, 90 deletions
diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java index 9d54bdd6a..b569d202d 100644 --- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java +++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java @@ -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) { diff --git a/asm/src/org/aspectj/asm/AsmManager.java b/asm/src/org/aspectj/asm/AsmManager.java index 87b5a347a..c5eca41e4 100644 --- a/asm/src/org/aspectj/asm/AsmManager.java +++ b/asm/src/org/aspectj/asm/AsmManager.java @@ -393,6 +393,8 @@ public class AsmManager { public static void setDontReport() { reporting = false; dumpDeltaProcessing=false; + dumpModel=false; + dumpRelationships=false; } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java index f0f26f325..a57c61f1a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java @@ -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()); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index efdefe0d1..c87a226d8 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -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); } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java index d9a75b79f..a9c853bec 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java @@ -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) { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 345681de0..3dc02895c 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -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); } diff --git a/tests/src/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml b/tests/src/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml index 2700af07f..dbafe9044 100644 --- a/tests/src/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml +++ b/tests/src/org/aspectj/systemtest/serialVerUID/serialVerUID-tests.xml @@ -57,7 +57,10 @@ 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> diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java index ab12e7aac..5dc5bf065 100644 --- a/weaver/src/org/aspectj/weaver/Lint.java +++ b/weaver/src/org/aspectj/weaver/Lint.java @@ -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 index 000000000..3a93af94e --- /dev/null +++ b/weaver/src/org/aspectj/weaver/LintMessage.java @@ -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 diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index 64d439671..ab61031f6 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -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) { |