--- /dev/null
+public class Driver {
+
+ public static void main(String[] args) {
+ ReturnTypeTester rtt = new ReturnTypeTester();
+ rtt.hashCode();
+ System.out.println(rtt.getId());
+ if (rtt.hashCode() != "id".hashCode()) throw new RuntimeException("dispatch failure");
+ }
+
+}
\ No newline at end of file
--- /dev/null
+public aspect ReturnTypeTest {
+ private interface Test {
+ Object getId();
+ int hashCode();
+ }
+
+ public int Test.hashCode() {
+ System.out.println("in Test.hashCode()");
+ return getId().hashCode();
+ }
+
+ declare parents : ReturnTypeTester implements Test;
+}
\ No newline at end of file
--- /dev/null
+import java.util.HashSet;
+import java.util.Set;
+
+public class ReturnTypeTester {
+ static Set<ReturnTypeTester> set = new HashSet<ReturnTypeTester>();
+ static {
+ ReturnTypeTester tester = new ReturnTypeTester();
+ set.add(tester);
+ }
+
+ public String getId() {
+ return "id";
+ }
+}
\ No newline at end of file
--- /dev/null
+import java.util.HashSet;
+import java.util.Set;
+
+aspect ReturnTypeTest {
+ private interface Test {
+ Object getId();
+ int hashCode();
+ }
+
+ public int Test.hashCode() {
+ System.out.println("in Test.hashCode()");
+ return getId().hashCode();
+ }
+
+ declare parents : ReturnTypeTester implements Test;
+}
+
+class ReturnTypeTester {
+ static Set<ReturnTypeTester> set = new HashSet<ReturnTypeTester>();
+ static {
+ ReturnTypeTester tester = new ReturnTypeTester();
+ set.add(tester);
+ }
+
+ public String getId() {
+ return "id";
+ }
+}
+
+public class pr105479part2 {
+
+ public static void main(String[] args) {
+ ReturnTypeTester rtt = new ReturnTypeTester();
+ rtt.hashCode();
+ System.out.println(rtt.getId());
+ if (rtt.hashCode() != "id".hashCode()) throw new RuntimeException("dispatch failure");
+ }
+
+}
\ No newline at end of file
--- /dev/null
+// "Two Xlint warnings wth cflow?"
+
+aspect A {
+ before(): call(* *(..)) && cflow(execution(* *(..))) {
+ }
+}
runTest("parse generic type signature with parameterized type in interface");
}
+ public void testOverrideAndCovarianceWithDecPRuntime() {
+ runTest("override and covariance with decp - runtime");
+ }
+
+ public void testOverrideAndCovarianceWithDecPRuntimeMultiFiles() {
+ runTest("override and covariance with decp - runtime separate files");
+ }
// helper methods.....
public SyntheticRepository createRepos(File cpentry) {
<ajc-test dir="bugs150" pr="108602" title="parse generic type signature with parameterized type in interface">
<compile files="pr108602.java" options="-1.5"/>
</ajc-test>
-
+
+ <ajc-test dir="bugs150" pr="105479" title="override and covariance with decp - runtime">
+ <compile files="pr105479part2.aj" options="-1.5"/>
+ <run class="pr105479part2">
+ <stdout>
+ <line text="in Test.hashCode()"/>
+ <line text="in Test.hashCode()"/>
+ <line text="id"/>
+ <line text="in Test.hashCode()"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs150/pr105479" pr="105479" title="override and covariance with decp - runtime separate files">
+ <compile files="ReturnTypeTest.aj,ReturnTypeTester.java,Driver.java" options="-1.5"/>
+ <run class="Driver">
+ <stdout>
+ <line text="in Test.hashCode()"/>
+ <line text="in Test.hashCode()"/>
+ <line text="id"/>
+ <line text="in Test.hashCode()"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
<!-- ============================================================================ -->
<!-- ============================================================================ -->
// if (is15VMOrGreater)
// runTest("7 lint warnings");
// }
+
+ public void testBug99136(){
+ runTest("Two Xlint warnings wth cflow?");
+ if(ajc.getLastCompilationResult().getWarningMessages().size() != 1){
+ fail();
+ }
+ }
}
</compile>
</ajc-test>
-->
+
+ <ajc-test dir="harness"
+ title="Two Xlint warnings wth cflow?">
+ <compile files="XLintcflow.java" options="-1.5">
+ <message kind="warning" line="4" text="advice defined in A has not been applied [Xlint:adviceDidNotMatch]"/>
+ </compile>
+ </ajc-test>
\ No newline at end of file
deletedTypenames = new ArrayList();
+ warnOnUnmatchedAdvice();
+
+ requestor.weaveCompleted();
+ return wovenClassNames;
+ }
+
+ /**
+ * In 1.5 mode and with XLint:adviceDidNotMatch enabled, put out messages for any
+ * mungers that did not match anything.
+ */
+ private void warnOnUnmatchedAdvice() {
+
+ class AdviceLocation {
+ private int lineNo;
+ private UnresolvedType inAspect;
+
+ public AdviceLocation(BcelAdvice advice) {
+ this.lineNo = advice.getSourceLocation().getLine();
+ this.inAspect = advice.getDeclaringAspect();
+ }
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof AdviceLocation)) return false;
+ AdviceLocation other = (AdviceLocation) obj;
+ if (this.lineNo != other.lineNo) return false;
+ if (!this.inAspect.equals(other.inAspect)) return false;
+ return true;
+ }
+
+ public int hashCode() {
+ return 37 + 17*lineNo + 17*inAspect.hashCode();
+ };
+ }
+
// FIXME asc Should be factored out into Xlint code and done automatically for all xlint messages, ideally.
// if a piece of advice hasn't matched anywhere and we are in -1.5 mode, put out a warning
if (world.isInJava5Mode() &&
world.getLint().adviceDidNotMatch.isEnabled()) {
List l = world.getCrosscuttingMembersSet().getShadowMungers();
+ Set alreadyWarnedLocations = new HashSet();
+
for (Iterator iter = l.iterator(); iter.hasNext();) {
ShadowMunger element = (ShadowMunger) iter.next();
if (element instanceof BcelAdvice) { // This will stop us incorrectly reporting deow Checkers
// Because we implement some features of AJ itself by creating our own kind of mungers, you sometimes
// find that ba.getSignature() is not a BcelMethod - for example it might be a cflow entry munger.
if (ba.getSignature()!=null) {
+
+ // check we haven't already warned on this advice and line
+ // (cflow creates multiple mungers for the same advice)
+ AdviceLocation loc = new AdviceLocation(ba);
+ if (alreadyWarnedLocations.contains(loc)) {
+ continue;
+ } else {
+ alreadyWarnedLocations.add(loc);
+ }
+
if (!(ba.getSignature() instanceof BcelMethod)
|| !Utility.isSuppressing((AnnotationX[])ba.getSignature().getAnnotations(),"adviceDidNotMatch")) {
world.getLint().adviceDidNotMatch.signal(ba.getDeclaringAspect().toString(),element.getSourceLocation());
}
}
}
-
- requestor.weaveCompleted();
- return wovenClassNames;
- }
+ }
/**
* 'typeToWeave' is one from the 'typesForWeaving' list. This routine ensures we process