Browse Source

fixes for 118715 from Matthew.

tags/V1_5_0RC1
aclement 18 years ago
parent
commit
1e1bbb3f2e

+ 18
- 13
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java View File

@@ -25,9 +25,7 @@ import java.util.Properties;
import java.util.StringTokenizer;

import org.aspectj.asm.IRelationship;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
import org.aspectj.util.LangUtil;
import org.aspectj.weaver.ICrossReferenceHandler;
import org.aspectj.weaver.Lint;
@@ -220,7 +218,14 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
world.setXnoInline(weaverOption.noInline);
// AMC - autodetect as per line below, needed for AtAjLTWTests.testLTWUnweavable
world.setBehaveInJava5Way(LangUtil.is15VMOrGreater());
//-Xlintfile: first so that lint wins

/* First load defaults */
bcelWorld.getLint().loadDefaultProperties();
/* Second overlay LTW defaults */
bcelWorld.getLint().adviceDidNotMatch.setKind(null);
/* Third load user file using -Xlintfile so that -Xlint wins */
if (weaverOption.lintFile != null) {
InputStream resource = null;
try {
@@ -236,20 +241,20 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
}
}
if (failure != null || resource == null) {
world.getMessageHandler().handleMessage(new Message(
"Cannot access resource for -Xlintfile:"+weaverOption.lintFile,
IMessage.WARNING,
failure,
null));
warn("Cannot access resource for -Xlintfile:"+weaverOption.lintFile,failure);
// 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) {
bcelWorld.getLint().loadDefaultProperties();
bcelWorld.getLint().adviceDidNotMatch.setKind(IMessage.INFO);
} else {
}
/* Fourth override with -Xlint */
if (weaverOption.lint != null) {
if (weaverOption.lint.equals("default")) {//FIXME should be AjBuildConfig.AJLINT_DEFAULT but yetanother deps..
bcelWorld.getLint().loadDefaultProperties();
} else {

+ 2
- 1
testing/newsrc/org/aspectj/testing/OutputSpec.java View File

@@ -35,7 +35,8 @@ public class OutputSpec {
String line = (String) iter.next();
lineNo++;
String outputLine = strTok.nextToken().trim();
if (!line.equals(outputLine)) {
/* Avoid trying to match on ajSandbox source names that appear in messages */
if (outputLine.indexOf(line) == -1) {
matches = false;
break;
}

+ 23
- 0
testing/newsrc/org/aspectj/testing/RunSpec.java View File

@@ -37,6 +37,7 @@ public class RunSpec implements ITestStep {
private OutputSpec stdErrSpec;
private OutputSpec stdOutSpec;
private String ltwFile;
private String xlintFile;
public RunSpec() {
}
@@ -51,6 +52,7 @@ public class RunSpec implements ITestStep {
String[] args = buildArgs();
// System.err.println("? execute() inTestCase='" + inTestCase + "', ltwFile=" + ltwFile);
boolean useLtw = copyLtwFile(inTestCase.getSandboxDirectory());
copyXlintFile(inTestCase.getSandboxDirectory());
AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(),args,getClasspath(),useLtw);
if (stdErrSpec != null) {
stdErrSpec.matchAgainst(rr.getStdErr());
@@ -147,4 +149,25 @@ public class RunSpec implements ITestStep {
return useLtw;
}

public String getXlintFile() {
return xlintFile;
}

public void setXlintFile(String xlintFile) {
this.xlintFile = xlintFile;
}

private void copyXlintFile (File sandboxDirectory) {
if (xlintFile != null) {
File from = new File(baseDir,xlintFile);
File to = new File(sandboxDirectory, File.separator + xlintFile);
try {
FileUtil.copyFile(from,to);
}
catch (IOException ex) {
AjcTestCase.fail(ex.toString());
}
}
}
}

+ 1
- 0
testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java View File

@@ -167,6 +167,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
digester.addObjectCreate("suite/ajc-test/run",RunSpec.class);
digester.addSetProperties("suite/ajc-test/run","class","classToRun");
digester.addSetProperties("suite/ajc-test/run","ltw","ltwFile");
digester.addSetProperties("suite/ajc-test/run","xlintfile","xlintFile");
digester.addSetNext("suite/ajc-test/run","addTestStep","org.aspectj.testing.ITestStep");
digester.addObjectCreate("*/message",ExpectedMessageSpec.class);
digester.addSetProperties("*/message");

+ 19
- 0
tests/ltw/Aspect3.aj View File

@@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
*
* Contributors:
* Matthew Webster initial implementation
*******************************************************************************/
import org.aspectj.lang.JoinPoint;

public aspect Aspect3 {
before () : execution(void Main.test999()) {
System.err.println("Aspect1.before_" + thisJoinPoint.getSignature().getName());
}
}

+ 0
- 0
tests/ltw/Xlint-empty.properties View File


+ 1
- 0
tests/ltw/Xlint-nomatch.properties View File

@@ -0,0 +1 @@
adviceDidNotMatch = warning

+ 7
- 0
tests/ltw/aop-nomatch.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<aspects>
<aspect name="Aspect3"/>
</aspects>
<weaver options="-verbose -showWeaveInfo"/>
</aspectj>

+ 7
- 0
tests/ltw/aop-nomatchxlint.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<aspects>
<aspect name="Aspect3"/>
</aspects>
<weaver options="-verbose -showWeaveInfo -Xlint:warning"/>
</aspectj>

+ 7
- 0
tests/ltw/aop-nomatchxlintfile.xml View File

@@ -0,0 +1,7 @@
<aspectj>
<aspects>
<aspect name="Aspect3"/>
</aspects>
<weaver options="-verbose -showWeaveInfo -Xlintfile:Xlint-nomatch.properties"/>
</aspectj>

+ 3
- 0
tests/ltw/aop-xlintfile.xml View File

@@ -0,0 +1,3 @@
<aspectj>
<weaver options="-Xlintfile:Xlint-empty.properties"/>
</aspectj>

+ 24
- 0
tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java View File

@@ -65,6 +65,30 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("Ensure weaver lint warning issued when an aspect is not used for weaving");
}

public void testXlintfileEmpty () {
runTest("Empty Xlint.properties file");
}

public void testXlintfileMissing () {
runTest("Warning with missing Xlint.properties file");
}

public void testXlintWarningAdviceDidNotMatchSuppressed () {
runTest("Warning when advice doesn't match suppressed for LTW");
}

public void testXlintfile () {
runTest("Override suppressing of warning when advice doesn't match using -Xlintfile");
}

public void testXlintDefault () {
runTest("Warning when advice doesn't match using -Xlint:default");
}

public void testXlintWarning () {
runTest("Override suppressing of warning when advice doesn't match using -Xlint:warning");
}
/*
* Allow system properties to be set and restored
* TODO maw move to XMLBasedAjcTestCase or RunSpec

+ 107
- 0
tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml View File

@@ -1,3 +1,4 @@

<!-- Load-time weaving tests -->

<ajc-test dir="ltw"
@@ -215,3 +216,109 @@
</run>
</ajc-test>
<ajc-test dir="ltw"
title="Empty Xlint.properties file"
keywords="xlint, ltw">
<compile
files="Main.java"
>
</compile>
<run class="Main" ltw="aop-xlintfile.xml" xlintfile="Xlint-empty.properties">
<stderr>
</stderr>
</run>
</ajc-test>
<ajc-test dir="ltw"
title="Warning with missing Xlint.properties file"
keywords="xlint, ltw">
<compile
files="Main.java"
>
</compile>
<run class="Main" ltw="aop-xlintfile.xml">
<stderr>
<line text="warning Cannot access resource for -Xlintfile:Xlint-empty.properties"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="ltw"
title="Warning when advice doesn't match suppressed for LTW"
keywords="xlint, ltw">
<compile
files="Main.java"
>
</compile>
<compile
files="Aspect3.aj"
>
</compile>
<run class="Main" ltw="aop-nomatch.xml">
<stderr>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="ltw"
title="Override suppressing of warning when advice doesn't match using -Xlintfile"
keywords="xlint, ltw">
<compile
files="Main.java"
>
</compile>
<compile
files="Aspect3.aj"
>
</compile>
<run class="Main" ltw="aop-nomatchxlintfile.xml" xlintfile="Xlint-nomatch.properties">
<stderr>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
<line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="ltw"
title="Warning when advice doesn't match using -Xlint:default"
keywords="xlint, ltw">
<compile
files="Main.java"
>
</compile>
<compile
files="Aspect3.aj"
>
</compile>
<run class="Main" ltw="aop-nomatchxlint.xml">
<stderr>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
<line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="ltw"
title="Override suppressing of warning when advice doesn't match using -Xlint:warning"
keywords="xlint, ltw">
<compile
files="Main.java"
>
</compile>
<compile
files="Aspect3.aj"
>
</compile>
<run class="Main" ltw="aop-nomatchxlint.xml">
<stderr>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
<line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
</stderr>
</run>
</ajc-test>

+ 1
- 1
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java View File

@@ -332,7 +332,7 @@ public class WeavingAdaptor {
}
protected boolean warn (String message, Throwable th) {
return messageHandler.handleMessage(new Message("Register definition failed", IMessage.WARNING, th, null));
return messageHandler.handleMessage(new Message(message, IMessage.WARNING, th, null));
}
protected boolean error (String message) {

+ 0
- 7
weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java View File

@@ -15,25 +15,18 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.util.HashMap;
import java.util.Map;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.AjType;
import org.aspectj.lang.reflect.AjTypeSystem;
import org.aspectj.lang.reflect.Pointcut;
import org.aspectj.weaver.AnnotationX;
import org.aspectj.weaver.BoundedReferenceType;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.TypeFactory;
import org.aspectj.weaver.TypeVariable;
import org.aspectj.weaver.TypeVariableReferenceType;
import org.aspectj.weaver.UnresolvedType;

Loading…
Cancel
Save